Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 44 additions & 33 deletions .github/scripts/csat.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,21 @@ const CONSTANT_VALUES = {
QUESTION: 'question',
JAVASCRIPT: 'javascript',
STATUS_IN_PROGRESS: 'status/in-progress',
NEEDS_REVIEW: 'needs review'
NEEDS_REVIEW: 'needs review',
},
STATE: { CLOSED: 'closed' },
STATE: {CLOSED: 'closed'},
},
MODULE: {
CSAT: {
YES: 'Yes',
NO: 'No',
BASE_URL: 'https://docs.google.com/forms/d/e/1FAIpQLSeuqIP8vcNJv0Gv84ruyxmvrMQElhB2L0saRtuapK7c28QMWQ/viewform?',
BASE_URL:
'https://docs.google.com/forms/d/e/1FAIpQLSeuqIP8vcNJv0Gv84ruyxmvrMQElhB2L0saRtuapK7c28QMWQ/viewform?',
SATISFACTION_PARAM: 'entry.2064764942=',
ISSUEID_PARAM: '&entry.666097176=',
MSG: 'Are you satisfied with the resolution of your issue?',
}
}
},
},
};

/**
Expand All @@ -37,37 +38,47 @@ const CONSTANT_VALUES = {
* context Information about the workflow run.
* @return {null}
*/
module.exports = async ({ github, context }) => {
const issue = context.payload.issue.html_url;

// Check if any label matches (case-insensitive) the supported CSAT labels.
const supportedLabels = Object.values(CONSTANT_VALUES.GLOBALS.LABELS);
const hasMatchingLabel = context.payload.issue.labels.some(label => {
const name = label.name.toLowerCase();
return supportedLabels.some(supportedLabel => name.includes(supportedLabel));
});
module.exports = async ({github, context}) => {
const issue = context.payload.issue.html_url;

if (hasMatchingLabel) {
console.log(`Posting CSAT survey for issue =${issue}`);
const baseUrl = CONSTANT_VALUES.MODULE.CSAT.BASE_URL;
// Check if any label matches (case-insensitive) the supported CSAT labels.
const supportedLabels = Object.values(CONSTANT_VALUES.GLOBALS.LABELS);
const hasMatchingLabel = context.payload.issue.labels.some((label) => {
const name = label.name.toLowerCase();
return supportedLabels.some((supportedLabel) =>
name.includes(supportedLabel),
);
});

const yesCsat = `<a href="${baseUrl + CONSTANT_VALUES.MODULE.CSAT.SATISFACTION_PARAM +
CONSTANT_VALUES.MODULE.CSAT.YES +
CONSTANT_VALUES.MODULE.CSAT.ISSUEID_PARAM + encodeURIComponent(issue)}"> ${CONSTANT_VALUES.MODULE.CSAT.YES}</a>`;
if (hasMatchingLabel) {
console.log(`Posting CSAT survey for issue =${issue}`);
const baseUrl = CONSTANT_VALUES.MODULE.CSAT.BASE_URL;

const noCsat = `<a href="${baseUrl + CONSTANT_VALUES.MODULE.CSAT.SATISFACTION_PARAM +
CONSTANT_VALUES.MODULE.CSAT.NO +
CONSTANT_VALUES.MODULE.CSAT.ISSUEID_PARAM + encodeURIComponent(issue)}"> ${CONSTANT_VALUES.MODULE.CSAT.NO}</a>`;
const yesCsat = `<a href="${
baseUrl +
CONSTANT_VALUES.MODULE.CSAT.SATISFACTION_PARAM +
CONSTANT_VALUES.MODULE.CSAT.YES +
CONSTANT_VALUES.MODULE.CSAT.ISSUEID_PARAM +
encodeURIComponent(issue)
}"> ${CONSTANT_VALUES.MODULE.CSAT.YES}</a>`;

const comment = CONSTANT_VALUES.MODULE.CSAT.MSG + '\n' + yesCsat + '\n' +
noCsat + '\n';
const issueNumber = context.issue.number ?? context.payload.issue.number;
const noCsat = `<a href="${
baseUrl +
CONSTANT_VALUES.MODULE.CSAT.SATISFACTION_PARAM +
CONSTANT_VALUES.MODULE.CSAT.NO +
CONSTANT_VALUES.MODULE.CSAT.ISSUEID_PARAM +
encodeURIComponent(issue)
}"> ${CONSTANT_VALUES.MODULE.CSAT.NO}</a>`;

await github.rest.issues.createComment({
issue_number: issueNumber,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});
}
const comment =
CONSTANT_VALUES.MODULE.CSAT.MSG + '\n' + yesCsat + '\n' + noCsat + '\n';
const issueNumber = context.issue.number ?? context.payload.issue.number;

await github.rest.issues.createComment({
issue_number: issueNumber,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment,
});
}
};
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
dist/
node_modules/
dev/src/browser
api-reference/
24 changes: 12 additions & 12 deletions .prettierrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
*/

export default {
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": true,
"quoteProps": "preserve",
"bracketSpacing": false,
"trailingComma": "all",
"arrowParens": "always",
"bracketSameLine": true,
"endOfLine": "auto",
"plugins": ["prettier-plugin-organize-imports"],
'printWidth': 80,
'tabWidth': 2,
'useTabs': false,
'semi': true,
'singleQuote': true,
'quoteProps': 'preserve',
'bracketSpacing': false,
'trailingComma': 'all',
'arrowParens': 'always',
'bracketSameLine': true,
'endOfLine': 'auto',
'plugins': ['prettier-plugin-organize-imports'],
};
34 changes: 17 additions & 17 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,36 @@
* SPDX-License-Identifier: Apache-2.0
*/

import js from "@eslint/js";
import globals from "globals";
import tseslint from "typescript-eslint";
import { defineConfig } from "eslint/config";
import js from '@eslint/js';
import {defineConfig} from 'eslint/config';
import globals from 'globals';
import tseslint from 'typescript-eslint';

export default defineConfig([
{
ignores: ["**/dist/**", "dev/src/browser/**"],
ignores: ['**/dist/**', 'dev/src/browser/**'],
},
tseslint.configs.recommended,
{
files: ["**/*.ts"],
plugins: { js },
extends: ["js/recommended"],
files: ['**/*.ts'],
plugins: {js},
extends: ['js/recommended'],
languageOptions: {
globals: {
...globals.node,
...globals.vitest
...globals.vitest,
},
},
rules: {
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
"error",
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_",
"caughtErrorsIgnorePattern": "^_"
}
]
'argsIgnorePattern': '^_',
'varsIgnorePattern': '^_',
'caughtErrorsIgnorePattern': '^_',
},
],
},
},
]);
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"ts:check": "tsc --noEmit",
"lint": "eslint \"**/*.ts\"",
"lint:fix": "eslint --fix \"**/*.ts\"",
"format": "prettier \"**/*.ts\" --write",
"format:check": "prettier \"**/*.ts\" --check",
"format": "prettier \"**/*.{ts,js,cjs,mjs}\" --write",
"format:check": "prettier \"**/*.{ts,js,cjs,mjs}\" --check",
"docs": "npm run docs:clean && npm run docs:generate && npm run docs:serve",
"docs:clean": "rm -rf ./api-reference",
"docs:generate": "typedoc",
Expand Down Expand Up @@ -66,10 +66,13 @@
"*": [
"secretlint"
],
"**/*.{js,ts}": [
"**/*.{js,mjs,ts}": [
"eslint --fix",
"prettier --write"
],
"**/*.cjs": [
"prettier --write"
],
"**/*.{json,md}": [
"prettier --write"
]
Expand Down
6 changes: 4 additions & 2 deletions scripts/auto-assignment.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

export default async function autoAssign({ github, context }) {
export default async function autoAssign({github, context}) {
console.log('Auto-assignment script started');

let issueNumber;
Expand All @@ -23,7 +23,9 @@ export default async function autoAssign({ github, context }) {
issueNumber = context.payload.pull_request.number;

// Skip PRs from forks to prevent 403 errors
if (context.repo.owner !== context.payload.pull_request.head.repo.owner.login) {
if (
context.repo.owner !== context.payload.pull_request.head.repo.owner.login
) {
console.log('PR from fork detected: skipping auto-assignment');
return;
}
Expand Down