diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index 4e0a67d..0000000 --- a/.eslintrc +++ /dev/null @@ -1,55 +0,0 @@ -{ - "root": true, - "parser": "@typescript-eslint/parser", - "parserOptions": { - "project": ["./tsconfig.json"] - }, - "plugins": ["@typescript-eslint", "sonarjs"], - "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 }], - "@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 new file mode 100644 index 0000000..d454c0f --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,59 @@ +/** + * @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"] }, + ], + }, +}; 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 01b981c..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 -``` \ No newline at end of file +``` 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"