diff --git a/.github/scripts/csat.cjs b/.github/scripts/csat.cjs index cc189d463..9f2c10326 100644 --- a/.github/scripts/csat.cjs +++ b/.github/scripts/csat.cjs @@ -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?', - } - } + }, + }, }; /** @@ -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 = ` ${CONSTANT_VALUES.MODULE.CSAT.YES}`; + if (hasMatchingLabel) { + console.log(`Posting CSAT survey for issue =${issue}`); + const baseUrl = CONSTANT_VALUES.MODULE.CSAT.BASE_URL; - const noCsat = ` ${CONSTANT_VALUES.MODULE.CSAT.NO}`; + const yesCsat = ` ${CONSTANT_VALUES.MODULE.CSAT.YES}`; - const comment = CONSTANT_VALUES.MODULE.CSAT.MSG + '\n' + yesCsat + '\n' + - noCsat + '\n'; - const issueNumber = context.issue.number ?? context.payload.issue.number; + const noCsat = ` ${CONSTANT_VALUES.MODULE.CSAT.NO}`; - 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, + }); + } }; diff --git a/.prettierignore b/.prettierignore index b572a242e..76f3f33b3 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,3 +1,4 @@ dist/ node_modules/ dev/src/browser +api-reference/ diff --git a/.prettierrc.js b/.prettierrc.js index 8c14d9d84..520a782e8 100644 --- a/.prettierrc.js +++ b/.prettierrc.js @@ -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'], }; diff --git a/eslint.config.js b/eslint.config.js index 0d0f13deb..858251a85 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -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': '^_', + }, + ], }, }, ]); diff --git a/package.json b/package.json index 36cc0d747..93af29cd7 100644 --- a/package.json +++ b/package.json @@ -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", @@ -66,10 +66,13 @@ "*": [ "secretlint" ], - "**/*.{js,ts}": [ + "**/*.{js,mjs,ts}": [ "eslint --fix", "prettier --write" ], + "**/*.cjs": [ + "prettier --write" + ], "**/*.{json,md}": [ "prettier --write" ] diff --git a/scripts/auto-assignment.mjs b/scripts/auto-assignment.mjs index 28349b82d..0d657325e 100644 --- a/scripts/auto-assignment.mjs +++ b/scripts/auto-assignment.mjs @@ -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; @@ -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; }