From 1e2ac44ed4743df297e9c3f45b782d588ce73912 Mon Sep 17 00:00:00 2001 From: jordan-ae Date: Fri, 19 Apr 2024 12:35:55 +0100 Subject: [PATCH 1/9] chore: add pascal case linter to enforce Erc20Permit and Erc721Permit naming conventions --- .eslintrc | 10 +++++++++- .github/workflows/cypress-testing.yml | 2 +- .github/workflows/jest-testing.yml | 4 ++-- .github/workflows/release-please.yml | 2 +- README.md | 5 +++++ tsconfig.json | 2 +- 6 files changed, 19 insertions(+), 6 deletions(-) diff --git a/.eslintrc b/.eslintrc index ae05460..51a8eb9 100644 --- a/.eslintrc +++ b/.eslintrc @@ -49,7 +49,15 @@ { "selector": "variable", "modifiers": ["destructured"], "format": null }, { "selector": "variable", "types": ["boolean"], "format": ["PascalCase"], "prefix": ["is", "should", "has", "can", "did", "will", "does"] }, { "selector": "variableLike", "format": ["camelCase"] }, - { "selector": ["function", "variable"], "format": ["camelCase"] } + { "selector": ["function", "variable"], "format": ["camelCase"] }, + { + "selector": "variable", + "format": ["PascalCase"], + "filter": { + "regex": "^(Erc20Permit|Erc721Permit)$", + "match": true + } + } ] } } diff --git a/.github/workflows/cypress-testing.yml b/.github/workflows/cypress-testing.yml index eadd68e..1cf9d5a 100644 --- a/.github/workflows/cypress-testing.yml +++ b/.github/workflows/cypress-testing.yml @@ -2,7 +2,7 @@ name: Run Cypress testing suite on: workflow_dispatch: pull_request: - types: [ opened, synchronize ] + types: [opened, synchronize] jobs: cypress-run: diff --git a/.github/workflows/jest-testing.yml b/.github/workflows/jest-testing.yml index 1671cd4..a7e36fa 100644 --- a/.github/workflows/jest-testing.yml +++ b/.github/workflows/jest-testing.yml @@ -2,7 +2,7 @@ name: Run Jest testing suite on: workflow_dispatch: pull_request_target: - types: [ opened, synchronize ] + types: [opened, synchronize] env: NODE_ENV: "test" @@ -14,7 +14,7 @@ jobs: steps: - uses: actions/setup-node@v4 with: - node-version: '20.10.0' + node-version: "20.10.0" - uses: actions/checkout@master with: fetch-depth: 0 diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index 75d28f0..a5b40f7 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -20,7 +20,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-node@v4 with: - node-version: '20.10.0' + node-version: "20.10.0" registry-url: https://registry.npmjs.org/ - run: | yarn install --immutable --immutable-cache --check-cache diff --git a/README.md b/README.md index fb15148..7b0867a 100644 --- a/README.md +++ b/README.md @@ -10,18 +10,23 @@ This template repository includes support for the following: ## Testing ### Cypress + To test with Cypress Studio UI, run + ```shell yarn cy:open ``` Otherwise to simply run the tests through the console, run + ```shell yarn cy:run ``` ### Jest + To start Jest tests, run + ```shell yarn test ``` diff --git a/tsconfig.json b/tsconfig.json index f9ab3da..c6d3097 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -104,7 +104,7 @@ /* Completeness */ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ - "skipLibCheck": true, /* Skip type checking all .d.ts files. */ + "skipLibCheck": true /* Skip type checking all .d.ts files. */, "resolveJsonModule": true } } From 66e9fe83e45ccb5a9d7ae19d507e41584c4d7a5e Mon Sep 17 00:00:00 2001 From: jordan-ae Date: Tue, 23 Apr 2024 02:39:33 +0100 Subject: [PATCH 2/9] chore: enable StrictPascalCase on all Identifiers --- .eslintrc | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/.eslintrc b/.eslintrc index 51a8eb9..43cb02e 100644 --- a/.eslintrc +++ b/.eslintrc @@ -40,24 +40,16 @@ "sonarjs/no-identical-expressions": "error", "@typescript-eslint/naming-convention": [ "error", - { "selector": "interface", "format": ["PascalCase"], "custom": { "regex": "^I[A-Z]", "match": false } }, - { "selector": "memberLike", "modifiers": ["private"], "format": ["camelCase"], "leadingUnderscore": "require" }, - { "selector": "typeLike", "format": ["PascalCase"] }, - { "selector": "typeParameter", "format": ["PascalCase"], "prefix": ["T"] }, - { "selector": "variable", "format": ["camelCase", "UPPER_CASE"], "leadingUnderscore": "allow", "trailingUnderscore": "allow" }, - { "selector": "variable", "format": ["camelCase"], "leadingUnderscore": "allow", "trailingUnderscore": "allow" }, + { "selector": "interface", "format": ["StrictPascalCase"], "custom": { "regex": "^I[A-Z]", "match": false } }, + { "selector": "memberLike", "modifiers": ["private"], "format": ["StrictPascalCase"], "leadingUnderscore": "require" }, + { "selector": "typeLike", "format": ["StrictPascalCase"] }, + { "selector": "typeParameter", "format": ["StrictPascalCase"], "prefix": ["T"] }, + { "selector": "variable", "format": ["StrictPascalCase"], "leadingUnderscore": "allow", "trailingUnderscore": "allow" }, + { "selector": "variable", "format": ["StrictPascalCase"], "leadingUnderscore": "allow", "trailingUnderscore": "allow" }, { "selector": "variable", "modifiers": ["destructured"], "format": null }, { "selector": "variable", "types": ["boolean"], "format": ["PascalCase"], "prefix": ["is", "should", "has", "can", "did", "will", "does"] }, - { "selector": "variableLike", "format": ["camelCase"] }, - { "selector": ["function", "variable"], "format": ["camelCase"] }, - { - "selector": "variable", - "format": ["PascalCase"], - "filter": { - "regex": "^(Erc20Permit|Erc721Permit)$", - "match": true - } - } + { "selector": "variableLike", "format": ["StrictPascalCase"] }, + { "selector": ["function", "variable"], "format": ["StrictPascalCase"] } ] } } From 9385bab27707b0e96b810f52146d63d005958b27 Mon Sep 17 00:00:00 2001 From: jordan-ae Date: Mon, 29 Apr 2024 03:11:04 +0100 Subject: [PATCH 3/9] chore: undo unnecessary changes --- .github/workflows/cypress-testing.yml | 2 +- .github/workflows/jest-testing.yml | 4 ++-- .github/workflows/release-please.yml | 2 +- README.md | 7 +------ tsconfig.json | 2 +- 5 files changed, 6 insertions(+), 11 deletions(-) diff --git a/.github/workflows/cypress-testing.yml b/.github/workflows/cypress-testing.yml index 1cf9d5a..eadd68e 100644 --- a/.github/workflows/cypress-testing.yml +++ b/.github/workflows/cypress-testing.yml @@ -2,7 +2,7 @@ name: Run Cypress testing suite on: workflow_dispatch: pull_request: - types: [opened, synchronize] + types: [ opened, synchronize ] jobs: cypress-run: diff --git a/.github/workflows/jest-testing.yml b/.github/workflows/jest-testing.yml index a7e36fa..1671cd4 100644 --- a/.github/workflows/jest-testing.yml +++ b/.github/workflows/jest-testing.yml @@ -2,7 +2,7 @@ name: Run Jest testing suite on: workflow_dispatch: pull_request_target: - types: [opened, synchronize] + types: [ opened, synchronize ] env: NODE_ENV: "test" @@ -14,7 +14,7 @@ jobs: steps: - uses: actions/setup-node@v4 with: - node-version: "20.10.0" + node-version: '20.10.0' - uses: actions/checkout@master with: fetch-depth: 0 diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index a5b40f7..75d28f0 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -20,7 +20,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-node@v4 with: - node-version: "20.10.0" + node-version: '20.10.0' registry-url: https://registry.npmjs.org/ - run: | yarn install --immutable --immutable-cache --check-cache diff --git a/README.md b/README.md index 7b0867a..01b981c 100644 --- a/README.md +++ b/README.md @@ -10,23 +10,18 @@ This template repository includes support for the following: ## Testing ### Cypress - To test with Cypress Studio UI, run - ```shell yarn cy:open ``` Otherwise to simply run the tests through the console, run - ```shell yarn cy:run ``` ### Jest - To start Jest tests, run - ```shell yarn test -``` +``` \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index c6d3097..f9ab3da 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -104,7 +104,7 @@ /* Completeness */ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ - "skipLibCheck": true /* Skip type checking all .d.ts files. */, + "skipLibCheck": true, /* Skip type checking all .d.ts files. */ "resolveJsonModule": true } } From 3d239c82604c664b31ce33c95be2575a98f7140e Mon Sep 17 00:00:00 2001 From: Keyrxng <106303466+Keyrxng@users.noreply.github.com> Date: Thu, 2 May 2024 12:51:58 +0100 Subject: [PATCH 4/9] chore: add eslint-filename plugin --- .eslintrc | 153 +++++++++++++++++++--- .github/workflows/cypress-testing.yml | 2 +- .github/workflows/jest-testing.yml | 4 +- .github/workflows/release-please.yml | 2 +- README.md | 5 + cypress/support/{e2e.ts => end-to-end.ts} | 0 package.json | 1 + tsconfig.json | 2 +- yarn.lock | 5 + 9 files changed, 150 insertions(+), 24 deletions(-) rename cypress/support/{e2e.ts => end-to-end.ts} (100%) diff --git a/.eslintrc b/.eslintrc index ae05460..84c61e0 100644 --- a/.eslintrc +++ b/.eslintrc @@ -2,20 +2,53 @@ "root": true, "parser": "@typescript-eslint/parser", "parserOptions": { - "project": ["./tsconfig.json"] + "project": [ + "./tsconfig.json" + ] }, - "plugins": ["@typescript-eslint", "sonarjs"], - "extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:sonarjs/recommended"], - "ignorePatterns": ["**/*.js"], + "plugins": [ + "@typescript-eslint", + "sonarjs", + "filename-rules" + ], + "extends": [ + "eslint:recommended", + "plugin:@typescript-eslint/recommended", + "plugin:sonarjs/recommended" + ], + "ignorePatterns": [ + "**/*.js" + ], "rules": { - "prefer-arrow-callback": ["warn", { "allowNamedFunctions": true }], - "func-style": ["warn", "declaration", { "allowArrowFunctions": false }], + "filename-rules/match": [ + 2, + "kebabcase", + "kebab-case" + ], + "prefer-arrow-callback": [ + "warn", + { + "allowNamedFunctions": true + } + ], + "func-style": [ + "warn", + "declaration", + { + "allowArrowFunctions": false + } + ], "@typescript-eslint/no-floating-promises": "error", "@typescript-eslint/no-non-null-assertion": "error", "constructor-super": "error", "no-invalid-this": "off", - "@typescript-eslint/no-invalid-this": ["error"], - "no-restricted-syntax": ["error", "ForInStatement"], + "@typescript-eslint/no-invalid-this": [ + "error" + ], + "no-restricted-syntax": [ + "error", + "ForInStatement" + ], "use-isnan": "error", "no-unneeded-ternary": "error", "no-nested-ternary": "error", @@ -40,16 +73,98 @@ "sonarjs/no-identical-expressions": "error", "@typescript-eslint/naming-convention": [ "error", - { "selector": "interface", "format": ["PascalCase"], "custom": { "regex": "^I[A-Z]", "match": false } }, - { "selector": "memberLike", "modifiers": ["private"], "format": ["camelCase"], "leadingUnderscore": "require" }, - { "selector": "typeLike", "format": ["PascalCase"] }, - { "selector": "typeParameter", "format": ["PascalCase"], "prefix": ["T"] }, - { "selector": "variable", "format": ["camelCase", "UPPER_CASE"], "leadingUnderscore": "allow", "trailingUnderscore": "allow" }, - { "selector": "variable", "format": ["camelCase"], "leadingUnderscore": "allow", "trailingUnderscore": "allow" }, - { "selector": "variable", "modifiers": ["destructured"], "format": null }, - { "selector": "variable", "types": ["boolean"], "format": ["PascalCase"], "prefix": ["is", "should", "has", "can", "did", "will", "does"] }, - { "selector": "variableLike", "format": ["camelCase"] }, - { "selector": ["function", "variable"], "format": ["camelCase"] } + { + "selector": "interface", + "format": [ + "PascalCase" + ], + "custom": { + "regex": "^I[A-Z]", + "match": false + } + }, + { + "selector": "memberLike", + "modifiers": [ + "private" + ], + "format": [ + "camelCase" + ], + "leadingUnderscore": "require" + }, + { + "selector": "typeLike", + "format": [ + "PascalCase" + ] + }, + { + "selector": "typeParameter", + "format": [ + "PascalCase" + ], + "prefix": [ + "T" + ] + }, + { + "selector": "variable", + "format": [ + "camelCase", + "UPPER_CASE" + ], + "leadingUnderscore": "allow", + "trailingUnderscore": "allow" + }, + { + "selector": "variable", + "format": [ + "camelCase" + ], + "leadingUnderscore": "allow", + "trailingUnderscore": "allow" + }, + { + "selector": "variable", + "modifiers": [ + "destructured" + ], + "format": null + }, + { + "selector": "variable", + "types": [ + "boolean" + ], + "format": [ + "PascalCase" + ], + "prefix": [ + "is", + "should", + "has", + "can", + "did", + "will", + "does" + ] + }, + { + "selector": "variableLike", + "format": [ + "camelCase" + ] + }, + { + "selector": [ + "function", + "variable" + ], + "format": [ + "camelCase" + ] + } ] } -} +} \ No newline at end of file diff --git a/.github/workflows/cypress-testing.yml b/.github/workflows/cypress-testing.yml index eadd68e..1cf9d5a 100644 --- a/.github/workflows/cypress-testing.yml +++ b/.github/workflows/cypress-testing.yml @@ -2,7 +2,7 @@ name: Run Cypress testing suite on: workflow_dispatch: pull_request: - types: [ opened, synchronize ] + types: [opened, synchronize] jobs: cypress-run: diff --git a/.github/workflows/jest-testing.yml b/.github/workflows/jest-testing.yml index 1671cd4..a7e36fa 100644 --- a/.github/workflows/jest-testing.yml +++ b/.github/workflows/jest-testing.yml @@ -2,7 +2,7 @@ name: Run Jest testing suite on: workflow_dispatch: pull_request_target: - types: [ opened, synchronize ] + types: [opened, synchronize] env: NODE_ENV: "test" @@ -14,7 +14,7 @@ jobs: steps: - uses: actions/setup-node@v4 with: - node-version: '20.10.0' + node-version: "20.10.0" - uses: actions/checkout@master with: fetch-depth: 0 diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index 75d28f0..a5b40f7 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -20,7 +20,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-node@v4 with: - node-version: '20.10.0' + node-version: "20.10.0" registry-url: https://registry.npmjs.org/ - run: | yarn install --immutable --immutable-cache --check-cache diff --git a/README.md b/README.md index fb15148..7b0867a 100644 --- a/README.md +++ b/README.md @@ -10,18 +10,23 @@ This template repository includes support for the following: ## Testing ### Cypress + To test with Cypress Studio UI, run + ```shell yarn cy:open ``` Otherwise to simply run the tests through the console, run + ```shell yarn cy:run ``` ### Jest + To start Jest tests, run + ```shell yarn test ``` diff --git a/cypress/support/e2e.ts b/cypress/support/end-to-end.ts similarity index 100% rename from cypress/support/e2e.ts rename to cypress/support/end-to-end.ts diff --git a/package.json b/package.json index 675b097..ec1b4ae 100644 --- a/package.json +++ b/package.json @@ -49,6 +49,7 @@ "esbuild": "^0.20.1", "eslint": "^8.56.0", "eslint-config-prettier": "^9.1.0", + "eslint-plugin-filename-rules": "^1.3.1", "eslint-plugin-prettier": "^5.1.3", "eslint-plugin-sonarjs": "^0.24.0", "husky": "^9.0.11", diff --git a/tsconfig.json b/tsconfig.json index f9ab3da..c6d3097 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -104,7 +104,7 @@ /* Completeness */ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ - "skipLibCheck": true, /* Skip type checking all .d.ts files. */ + "skipLibCheck": true /* Skip type checking all .d.ts files. */, "resolveJsonModule": true } } diff --git a/yarn.lock b/yarn.lock index aca8c12..0c43b39 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3376,6 +3376,11 @@ eslint-config-prettier@^9.1.0: resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-9.1.0.tgz#31af3d94578645966c082fcb71a5846d3c94867f" integrity sha512-NSWl5BFQWEPi1j4TjVNItzYV7dZXZ+wP6I6ZhrBGpChQhZRUaElihE9uRRkcbRnNb76UMKDF3r+WTmNcGPKsqw== +eslint-plugin-filename-rules@^1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-filename-rules/-/eslint-plugin-filename-rules-1.3.1.tgz#8fb769f2c19dc832b43c13d76c1442bca4a2f4a4" + integrity sha512-kBMxGFvK3QrRBHMurhFSNa+PFdszezVtBV6egg39TDzlj6D4jL3Xx6oyNjm5xE4C+TdQUBzWwymHJHBPyxOreA== + eslint-plugin-prettier@^5.1.3: version "5.1.3" resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-5.1.3.tgz#17cfade9e732cef32b5f5be53bd4e07afd8e67e1" From 850886a618282f14518c39beab52baf9a5a03d70 Mon Sep 17 00:00:00 2001 From: jordan-ae Date: Thu, 2 May 2024 14:43:02 +0100 Subject: [PATCH 5/9] revert camelCase deletions and change to strictCamelCase --- .eslintrc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.eslintrc b/.eslintrc index 43cb02e..4e0a67d 100644 --- a/.eslintrc +++ b/.eslintrc @@ -41,15 +41,15 @@ "@typescript-eslint/naming-convention": [ "error", { "selector": "interface", "format": ["StrictPascalCase"], "custom": { "regex": "^I[A-Z]", "match": false } }, - { "selector": "memberLike", "modifiers": ["private"], "format": ["StrictPascalCase"], "leadingUnderscore": "require" }, + { "selector": "memberLike", "modifiers": ["private"], "format": ["strictCamelCase"], "leadingUnderscore": "require" }, { "selector": "typeLike", "format": ["StrictPascalCase"] }, { "selector": "typeParameter", "format": ["StrictPascalCase"], "prefix": ["T"] }, - { "selector": "variable", "format": ["StrictPascalCase"], "leadingUnderscore": "allow", "trailingUnderscore": "allow" }, - { "selector": "variable", "format": ["StrictPascalCase"], "leadingUnderscore": "allow", "trailingUnderscore": "allow" }, + { "selector": "variable", "format": ["strictCamelCase", "UPPER_CASE"], "leadingUnderscore": "allow", "trailingUnderscore": "allow" }, + { "selector": "variable", "format": ["strictCamelCase"], "leadingUnderscore": "allow", "trailingUnderscore": "allow" }, { "selector": "variable", "modifiers": ["destructured"], "format": null }, - { "selector": "variable", "types": ["boolean"], "format": ["PascalCase"], "prefix": ["is", "should", "has", "can", "did", "will", "does"] }, - { "selector": "variableLike", "format": ["StrictPascalCase"] }, - { "selector": ["function", "variable"], "format": ["StrictPascalCase"] } + { "selector": "variable", "types": ["boolean"], "format": ["StrictPascalCase"], "prefix": ["is", "should", "has", "can", "did", "will", "does"] }, + { "selector": "variableLike", "format": ["strictCamelCase"] }, + { "selector": ["function", "variable"], "format": ["strictCamelCase"] } ] } } From 67e0375fca861d1d71fdbfac436f667d758b448a Mon Sep 17 00:00:00 2001 From: Keyrxng <106303466+Keyrxng@users.noreply.github.com> Date: Mon, 13 May 2024 10:25:21 +0100 Subject: [PATCH 6/9] fix: use regex and ignore e2e.ts --- .eslintrc | 170 ---------------------- .eslintrc.js | 56 +++++++ cypress/support/{end-to-end.ts => e2e.ts} | 0 3 files changed, 56 insertions(+), 170 deletions(-) delete mode 100644 .eslintrc create mode 100644 .eslintrc.js rename cypress/support/{end-to-end.ts => e2e.ts} (100%) diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index de47198..0000000 --- a/.eslintrc +++ /dev/null @@ -1,170 +0,0 @@ -{ - "root": true, - "parser": "@typescript-eslint/parser", - "parserOptions": { - "project": [ - "./tsconfig.json" - ] - }, - "plugins": [ - "@typescript-eslint", - "sonarjs", - "filename-rules" - ], - "extends": [ - "eslint:recommended", - "plugin:@typescript-eslint/recommended", - "plugin:sonarjs/recommended" - ], - "ignorePatterns": [ - "**/*.js" - ], - "rules": { - "filename-rules/match": [ - 2, - "kebabcase", - "kebab-case" - ], - "prefer-arrow-callback": [ - "warn", - { - "allowNamedFunctions": true - } - ], - "func-style": [ - "warn", - "declaration", - { - "allowArrowFunctions": false - } - ], - "@typescript-eslint/no-floating-promises": "error", - "@typescript-eslint/no-non-null-assertion": "error", - "constructor-super": "error", - "no-invalid-this": "off", - "@typescript-eslint/no-invalid-this": [ - "error" - ], - "no-restricted-syntax": [ - "error", - "ForInStatement" - ], - "use-isnan": "error", - "no-unneeded-ternary": "error", - "no-nested-ternary": "error", - "@typescript-eslint/no-unused-vars": [ - "error", - { - "args": "after-used", - "ignoreRestSiblings": true, - "vars": "all", - "varsIgnorePattern": "^_", - "argsIgnorePattern": "^_" - } - ], - "@typescript-eslint/await-thenable": "error", - "@typescript-eslint/no-misused-new": "error", - "@typescript-eslint/restrict-plus-operands": "error", - "sonarjs/no-all-duplicated-branches": "error", - "sonarjs/no-collection-size-mischeck": "error", - "sonarjs/no-duplicated-branches": "error", - "sonarjs/no-element-overwrite": "error", - "sonarjs/no-identical-conditions": "error", - "sonarjs/no-identical-expressions": "error", - "@typescript-eslint/naming-convention": [ - "error", - { - "selector": "interface", - "format": [ - "StrictPascalCase" - ], - "custom": { - "regex": "^I[A-Z]", - "match": false - } - }, - { - "selector": "memberLike", - "modifiers": [ - "private" - ], - "format": [ - "strictCamelCase" - ], - "leadingUnderscore": "require" - }, - { - "selector": "typeLike", - "format": [ - "StrictPascalCase" - ] - }, - { - "selector": "typeParameter", - "format": [ - "StrictPascalCase" - ], - "prefix": [ - "T" - ] - }, - { - "selector": "variable", - "format": [ - "strictCamelCase", - "UPPER_CASE" - ], - "leadingUnderscore": "allow", - "trailingUnderscore": "allow" - }, - { - "selector": "variable", - "format": [ - "strictCamelCase" - ], - "leadingUnderscore": "allow", - "trailingUnderscore": "allow" - }, - { - "selector": "variable", - "modifiers": [ - "destructured" - ], - "format": null - }, - { - "selector": "variable", - "types": [ - "boolean" - ], - "format": [ - "StrictPascalCase" - ], - "prefix": [ - "is", - "should", - "has", - "can", - "did", - "will", - "does" - ] - }, - { - "selector": "variableLike", - "format": [ - "strictCamelCase" - ] - }, - { - "selector": [ - "function", - "variable" - ], - "format": [ - "strictCamelCase" - ] - } - ] - } -} \ No newline at end of file diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..f652c05 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,56 @@ +module.exports = { + root: true, + parser: "@typescript-eslint/parser", + parserOptions: { + project: ["./tsconfig.json"], + }, + plugins: ["@typescript-eslint", "sonarjs", "filename-rules"], + extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:sonarjs/recommended"], + ignorePatterns: ["**/*.js"], + rules: { + "filename-rules/match": [2, /^(e2e\.ts$|.*\/e2e\.ts$|[a-z]+(?:[-._a-z]+)*\.ts|\.[a-z]+)$/], + "prefer-arrow-callback": ["warn", { allowNamedFunctions: true }], + "func-style": ["warn", "declaration", { allowArrowFunctions: false }], + "@typescript-eslint/no-floating-promises": "error", + "@typescript-eslint/no-non-null-assertion": "error", + "constructor-super": "error", + "no-invalid-this": "off", + "@typescript-eslint/no-invalid-this": ["error"], + "no-restricted-syntax": ["error", "ForInStatement"], + "use-isnan": "error", + "no-unneeded-ternary": "error", + "no-nested-ternary": "error", + "@typescript-eslint/no-unused-vars": [ + "error", + { + args: "after-used", + ignoreRestSiblings: true, + vars: "all", + varsIgnorePattern: "^_", + argsIgnorePattern: "^_", + }, + ], + "@typescript-eslint/await-thenable": "error", + "@typescript-eslint/no-misused-new": "error", + "@typescript-eslint/restrict-plus-operands": "error", + "sonarjs/no-all-duplicated-branches": "error", + "sonarjs/no-collection-size-mischeck": "error", + "sonarjs/no-duplicated-branches": "error", + "sonarjs/no-element-overwrite": "error", + "sonarjs/no-identical-conditions": "error", + "sonarjs/no-identical-expressions": "error", + "@typescript-eslint/naming-convention": [ + "error", + { selector: "interface", format: ["StrictPascalCase"], custom: { regex: "^I[A-Z]", match: false } }, + { selector: "memberLike", modifiers: ["private"], format: ["strictCamelCase"], leadingUnderscore: "require" }, + { selector: "typeLike", format: ["StrictPascalCase"] }, + { selector: "typeParameter", format: ["StrictPascalCase"], prefix: ["T"] }, + { selector: "variable", format: ["strictCamelCase", "UPPER_CASE"], leadingUnderscore: "allow", trailingUnderscore: "allow" }, + { selector: "variable", format: ["strictCamelCase"], leadingUnderscore: "allow", trailingUnderscore: "allow" }, + { selector: "variable", modifiers: ["destructured"], format: null }, + { selector: "variable", types: ["boolean"], format: ["StrictPascalCase"], prefix: ["is", "should", "has", "can", "did", "will", "does"] }, + { selector: "variableLike", format: ["strictCamelCase"] }, + { selector: ["function", "variable"], format: ["strictCamelCase"] }, + ], + }, +}; diff --git a/cypress/support/end-to-end.ts b/cypress/support/e2e.ts similarity index 100% rename from cypress/support/end-to-end.ts rename to cypress/support/e2e.ts From b92db6761b8b83ece385b9a0de17fddba774a126 Mon Sep 17 00:00:00 2001 From: Keyrxng <106303466+Keyrxng@users.noreply.github.com> Date: Mon, 13 May 2024 11:47:30 +0100 Subject: [PATCH 7/9] chore: eslint config type inference --- .eslintrc.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.eslintrc.js b/.eslintrc.js index f652c05..d454c0f 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,3 +1,6 @@ +/** + * @type {import("eslint").Linter.Config} + */ module.exports = { root: true, parser: "@typescript-eslint/parser", From 269bd8630bba167b8a19456d48ae984e99b3e4cc Mon Sep 17 00:00:00 2001 From: Korrrba Date: Fri, 24 May 2024 09:12:41 +0200 Subject: [PATCH 8/9] chore: update knip configuration in the template to run on pull_request --- .github/workflows/knip-reporter.yml | 38 +++++++++++++++++++++++++++++ .github/workflows/knip.yml | 29 +++++++++++++--------- 2 files changed, 56 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/knip-reporter.yml diff --git a/.github/workflows/knip-reporter.yml b/.github/workflows/knip-reporter.yml new file mode 100644 index 0000000..cf58ea8 --- /dev/null +++ b/.github/workflows/knip-reporter.yml @@ -0,0 +1,38 @@ +name: Knip-reporter + +on: + workflow_run: + workflows: ["Knip"] + types: + - completed + +jobs: + knip-reporter: + runs-on: ubuntu-latest + steps: + - uses: actions/download-artifact@v4 + with: + name: knip-results + run-id: ${{ github.event.workflow_run.id }} + github-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Read pr number + id: pr-number + uses: juliangruber/read-file-action@v1 + with: + path: ./pr-number.txt + trim: true + + - name: Report knip results to pull request + if: ${{ github.event.workflow_run.conclusion != 'success' }} + uses: gitcoindev/knip-reporter@main + with: + verbose: true + comment_id: ${{ github.workflow }}-reporter + command_script_name: knip-ci + annotations: true + ignore_results: false + json_input: true + json_input_file_name: knip-results.json + pull_request_number: ${{ steps.pr-number.outputs.content }} + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/knip.yml b/.github/workflows/knip.yml index 50a1a2a..809976b 100644 --- a/.github/workflows/knip.yml +++ b/.github/workflows/knip.yml @@ -1,10 +1,7 @@ name: Knip on: - pull_request_target: - workflow_dispatch: - -permissions: write-all + pull_request: jobs: run-knip: @@ -13,6 +10,10 @@ jobs: - name: Checkout uses: actions/checkout@v4 + # needed to use yarn v4 + - name: Enable corepack + run: corepack enable + - name: Setup Node uses: actions/setup-node@v4 with: @@ -21,11 +22,17 @@ jobs: - name: Install toolchain run: yarn install - - name: Report knip results to pull request - uses: Codex-/knip-reporter@v2 + - name: Store PR number + run: echo ${{ github.event.number }} > pr-number.txt + + - name: Run Knip + run: yarn knip || yarn knip --reporter json > knip-results.json + + - name: Upload knip result + if: failure() + uses: actions/upload-artifact@v4 with: - verbose: true - comment_id: ${{ github.workflow }}-reporter - command_script_name: knip-ci - annotations: true - ignore_results: false + name: knip-results + path: | + knip-results.json + pr-number.txt From b9c377c9b1c2dc8840622027c996cf626f996920 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Tue, 28 May 2024 09:32:42 +0900 Subject: [PATCH 9/9] fix: moved eslint from js to json and accept numbers in file names --- .eslintrc | 56 +++++++++++++++++++++++++++++++++++++++++++++++++ .eslintrc.js | 59 ---------------------------------------------------- 2 files changed, 56 insertions(+), 59 deletions(-) create mode 100644 .eslintrc delete mode 100644 .eslintrc.js diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..5fa69fa --- /dev/null +++ b/.eslintrc @@ -0,0 +1,56 @@ +{ + "root": true, + "parser": "@typescript-eslint/parser", + "parserOptions": { + "project": ["./tsconfig.json"] + }, + "plugins": ["@typescript-eslint", "sonarjs", "filename-rules"], + "extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:sonarjs/recommended"], + "ignorePatterns": ["**/*.js"], + "rules": { + "filename-rules/match": [2, "/^(e2e\\.ts$|.*\/e2e\\.ts$|[a-z0-9]+(?:[-._a-z0-9]+)*\\.ts|\\.[a-z0-9]+)$/"], + "prefer-arrow-callback": ["warn", { "allowNamedFunctions": true }], + "func-style": ["warn", "declaration", { "allowArrowFunctions": false }], + "@typescript-eslint/no-floating-promises": "error", + "@typescript-eslint/no-non-null-assertion": "error", + "constructor-super": "error", + "no-invalid-this": "off", + "@typescript-eslint/no-invalid-this": ["error"], + "no-restricted-syntax": ["error", "ForInStatement"], + "use-isnan": "error", + "no-unneeded-ternary": "error", + "no-nested-ternary": "error", + "@typescript-eslint/no-unused-vars": [ + "error", + { + "args": "after-used", + "ignoreRestSiblings": true, + "vars": "all", + "varsIgnorePattern": "^_", + "argsIgnorePattern": "^_" + } + ], + "@typescript-eslint/await-thenable": "error", + "@typescript-eslint/no-misused-new": "error", + "@typescript-eslint/restrict-plus-operands": "error", + "sonarjs/no-all-duplicated-branches": "error", + "sonarjs/no-collection-size-mischeck": "error", + "sonarjs/no-duplicated-branches": "error", + "sonarjs/no-element-overwrite": "error", + "sonarjs/no-identical-conditions": "error", + "sonarjs/no-identical-expressions": "error", + "@typescript-eslint/naming-convention": [ + "error", + { "selector": "interface", "format": ["StrictPascalCase"], "custom": { "regex": "^I[A-Z]", "match": false } }, + { "selector": "memberLike", "modifiers": ["private"], "format": ["strictCamelCase"], "leadingUnderscore": "require" }, + { "selector": "typeLike", "format": ["StrictPascalCase"] }, + { "selector": "typeParameter", "format": ["StrictPascalCase"], "prefix": ["T"] }, + { "selector": "variable", "format": ["strictCamelCase", "UPPER_CASE"], "leadingUnderscore": "allow", "trailingUnderscore": "allow" }, + { "selector": "variable", "format": ["strictCamelCase"], "leadingUnderscore": "allow", "trailingUnderscore": "allow" }, + { "selector": "variable", "modifiers": ["destructured"], "format": null }, + { "selector": "variable", "types": ["boolean"], "format": ["StrictPascalCase"], "prefix": ["is", "should", "has", "can", "did", "will", "does"] }, + { "selector": "variableLike", "format": ["strictCamelCase"] }, + { "selector": ["function", "variable"], "format": ["strictCamelCase"] } + ] + } +} diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index d454c0f..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1,59 +0,0 @@ -/** - * @type {import("eslint").Linter.Config} - */ -module.exports = { - root: true, - parser: "@typescript-eslint/parser", - parserOptions: { - project: ["./tsconfig.json"], - }, - plugins: ["@typescript-eslint", "sonarjs", "filename-rules"], - extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:sonarjs/recommended"], - ignorePatterns: ["**/*.js"], - rules: { - "filename-rules/match": [2, /^(e2e\.ts$|.*\/e2e\.ts$|[a-z]+(?:[-._a-z]+)*\.ts|\.[a-z]+)$/], - "prefer-arrow-callback": ["warn", { allowNamedFunctions: true }], - "func-style": ["warn", "declaration", { allowArrowFunctions: false }], - "@typescript-eslint/no-floating-promises": "error", - "@typescript-eslint/no-non-null-assertion": "error", - "constructor-super": "error", - "no-invalid-this": "off", - "@typescript-eslint/no-invalid-this": ["error"], - "no-restricted-syntax": ["error", "ForInStatement"], - "use-isnan": "error", - "no-unneeded-ternary": "error", - "no-nested-ternary": "error", - "@typescript-eslint/no-unused-vars": [ - "error", - { - args: "after-used", - ignoreRestSiblings: true, - vars: "all", - varsIgnorePattern: "^_", - argsIgnorePattern: "^_", - }, - ], - "@typescript-eslint/await-thenable": "error", - "@typescript-eslint/no-misused-new": "error", - "@typescript-eslint/restrict-plus-operands": "error", - "sonarjs/no-all-duplicated-branches": "error", - "sonarjs/no-collection-size-mischeck": "error", - "sonarjs/no-duplicated-branches": "error", - "sonarjs/no-element-overwrite": "error", - "sonarjs/no-identical-conditions": "error", - "sonarjs/no-identical-expressions": "error", - "@typescript-eslint/naming-convention": [ - "error", - { selector: "interface", format: ["StrictPascalCase"], custom: { regex: "^I[A-Z]", match: false } }, - { selector: "memberLike", modifiers: ["private"], format: ["strictCamelCase"], leadingUnderscore: "require" }, - { selector: "typeLike", format: ["StrictPascalCase"] }, - { selector: "typeParameter", format: ["StrictPascalCase"], prefix: ["T"] }, - { selector: "variable", format: ["strictCamelCase", "UPPER_CASE"], leadingUnderscore: "allow", trailingUnderscore: "allow" }, - { selector: "variable", format: ["strictCamelCase"], leadingUnderscore: "allow", trailingUnderscore: "allow" }, - { selector: "variable", modifiers: ["destructured"], format: null }, - { selector: "variable", types: ["boolean"], format: ["StrictPascalCase"], prefix: ["is", "should", "has", "can", "did", "will", "does"] }, - { selector: "variableLike", format: ["strictCamelCase"] }, - { selector: ["function", "variable"], format: ["strictCamelCase"] }, - ], - }, -};