From e2c98550a90f824b563de94333754ef4250423a9 Mon Sep 17 00:00:00 2001 From: Moreno Feltscher Date: Wed, 18 Oct 2023 15:01:32 +0200 Subject: [PATCH 1/5] feat: add new ESLint rules Add new rules for @typescript-eslint/no-explicit-any, prefer-const, no-else-return, no-extra-semi, curly, eqeqeq, default-case-last BREAKING CHANGE: Add new rules for @typescript-eslint/no-explicit-any, prefer-const, no-else-return, no-extra-semi, curly, eqeqeq, default-case-last --- .eslintrc.js | 7 +++++++ .github/workflows/main.yml | 1 + .releaserc.json | 26 +++++++++++++++----------- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index cbd543f..ce33b32 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -6,12 +6,19 @@ module.exports = { '@typescript-eslint/no-var-requires': 'warn', '@typescript-eslint/no-unused-vars': ['error'], '@typescript-eslint/no-floating-promises': ['error'], + '@typescript-eslint/no-explicit-any': ['error', { fixToUnknown: true }], 'no-constant-binary-expression': 'error', 'array-callback-return': 'error', 'no-debugger': 'error', 'no-alert': 'error', 'no-console': ['error', { allow: ['info', 'warn', 'error', 'trace', 'time', 'timeEnd'] }], 'newline-before-return': 'error', + 'prefer-const': 'error', + 'no-else-return': 'error', + 'no-extra-semi': 'error', + curly: 'error', + eqeqeq: 'error', + 'default-case-last': 'error', 'prettier/prettier': [ 'error', { diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 87e5572..7c0768c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,6 +4,7 @@ on: push: branches: - main + - next jobs: release: diff --git a/.releaserc.json b/.releaserc.json index 82af23e..5e5e5fa 100644 --- a/.releaserc.json +++ b/.releaserc.json @@ -1,12 +1,16 @@ { - "branches": [ - "main" - ], - "plugins": [ - "@semantic-release/commit-analyzer", - "@semantic-release/release-notes-generator", - "@semantic-release/changelog", - "@semantic-release/npm", - "@semantic-release/github" - ] - } \ No newline at end of file + "branches": [ + "main", + { + "name": "next", + "prerelease": true + } + ], + "plugins": [ + "@semantic-release/commit-analyzer", + "@semantic-release/release-notes-generator", + "@semantic-release/changelog", + "@semantic-release/npm", + "@semantic-release/github" + ] +} From 2a993bae6e178b722a848bcf07eabe34a59e2e18 Mon Sep 17 00:00:00 2001 From: Moreno Feltscher Date: Fri, 20 Oct 2023 13:52:58 +0200 Subject: [PATCH 2/5] feat: use type checked recommended rules BREAKING CHANGE: Use @typescript-eslint/recommended-type-checked and @typescript-eslint/stylistic-type-checked rules instead of @typescript-eslint/recommended --- .eslintrc.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.eslintrc.js b/.eslintrc.js index ce33b32..db521bf 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -42,11 +42,13 @@ module.exports = { 'plugin:import/errors', 'plugin:import/warnings', 'plugin:import/typescript', - 'plugin:@typescript-eslint/recommended', + 'plugin:@typescript-eslint/recommended-type-checked', + 'plugin:@typescript-eslint/stylistic-type-checked', ], globals: { Atomics: 'readonly', SharedArrayBuffer: 'readonly', }, + parser: '@typescript-eslint/parser', plugins: ['@typescript-eslint', 'prettier'], }; From d63e040ca7900fce41564972257043041207c868 Mon Sep 17 00:00:00 2001 From: Moreno Feltscher Date: Fri, 20 Oct 2023 15:24:41 +0200 Subject: [PATCH 3/5] fix: disable rule @typescript-eslint/consistent-type-definitions --- .eslintrc.js | 1 + 1 file changed, 1 insertion(+) diff --git a/.eslintrc.js b/.eslintrc.js index db521bf..cb475a6 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,6 +1,7 @@ /** @type {import('eslint').Linter.Config} */ module.exports = { rules: { + '@typescript-eslint/consistent-type-definitions': 'off', '@typescript-eslint/explicit-function-return-type': 'off', '@typescript-eslint/explicit-module-boundary-types': 'off', '@typescript-eslint/no-var-requires': 'warn', From 9c7bc6b1e66935f8976e7fd91356f795e516fa44 Mon Sep 17 00:00:00 2001 From: Moreno Feltscher Date: Fri, 17 Nov 2023 23:06:38 +0200 Subject: [PATCH 4/5] fix: disable @typescript-eslint/no-unsafe-enum-comparison rule --- .eslintrc.js | 1 + 1 file changed, 1 insertion(+) diff --git a/.eslintrc.js b/.eslintrc.js index cb475a6..3e1678a 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,6 +1,7 @@ /** @type {import('eslint').Linter.Config} */ module.exports = { rules: { + '@typescript-eslint/no-unsafe-enum-comparison': 'off', '@typescript-eslint/consistent-type-definitions': 'off', '@typescript-eslint/explicit-function-return-type': 'off', '@typescript-eslint/explicit-module-boundary-types': 'off', From 425d2941bd6b2c99963b0f5cb1badeb834468f26 Mon Sep 17 00:00:00 2001 From: Moreno Feltscher Date: Fri, 8 Dec 2023 14:57:25 +0100 Subject: [PATCH 5/5] docs: add documentation about TypeScript setup --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 54f1a57..44ec663 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,8 @@ Create a `.eslintrc` file in the root of your project's directory (it should liv } ``` +### NPM scripts + To use eslint add the following to your package.json: ```json @@ -40,3 +42,7 @@ To use eslint add the following to your package.json: "lint:fix": "eslint . --fix" } ``` + +### TypeScript configuration + +Since there are some rules which require type information please make sure to set up a `tsconfig.json` configuration file in the root directory of your project. If your TypeScript configuration file is placed in another location you have to configure it using `parserOptions.project` in your ESLint configuration file. For more information have a look at the [typescript-eslint documentation](https://typescript-eslint.io/packages/parser/#project).