From cdb42d9934c902a592278ee85073b9a79b6cdb57 Mon Sep 17 00:00:00 2001 From: Gabriel CM Date: Thu, 7 Dec 2023 08:04:10 -0300 Subject: [PATCH 1/9] docs: base Testing Rules documentation --- .../local-development/Local_Linking.mdx | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/docs/contributing/local-development/Local_Linking.mdx b/docs/contributing/local-development/Local_Linking.mdx index 00908758485c..4d14a3669aa2 100644 --- a/docs/contributing/local-development/Local_Linking.mdx +++ b/docs/contributing/local-development/Local_Linking.mdx @@ -8,6 +8,7 @@ The general strategy to do so is: 1. [Global linking](#global-linking): Use your package manager's global link command to make `@typescript-eslint/*` packages available as global symlinks. 2. [Repository linking](#repository-linking): Use your package manager's link command to reference those global symlinks in the local downstream repository. +3. [Testing rules](#testing): Test your local rules and plugins by enabling them in the local downstream repository. ## Global Linking @@ -45,6 +46,24 @@ Now, you should be able to run ESLint in the local downstream repository as you To check that the local package is being used, consider adding a `console.log("Hello, world!");` to a file such as `./packages/eslint-plugin/dist/index.js` and making sure that log appears when linting the local downstream repository. ::: +## Testing Rules + +Now that you've linked the `@typescript-eslint/*` packages with your local downstream repository, the next step would be to include the rule on the local repository ESLint configuration file, e.g: + +```json +{ + "rules": { + "@typescript-eslint/your-awesome-rule": "error" + } + // etc +} +``` + +After that, you just need to run your repository `lint` script. + +- `npm run lint` +- `yarn lint` + ## Troubleshooting ### Packages Not Found (`Cannot find module`) From d24fb948cd8592fa9213332295caa13d90f6e01a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josh=20Goldberg=20=E2=9C=A8?= Date: Thu, 7 Dec 2023 15:14:43 -0500 Subject: [PATCH 2/9] fix(eslint-plugin): add no-unsafe-unary-minus, prefer-destructuring to disable-type-checked (#8038) fix: add no-unsafe-unary-minus, prefer-destructuring to disable-type-checked --- packages/eslint-plugin/src/configs/all.ts | 2 +- packages/eslint-plugin/src/configs/disable-type-checked.ts | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/eslint-plugin/src/configs/all.ts b/packages/eslint-plugin/src/configs/all.ts index 7717b386cc9f..5142a24bd540 100644 --- a/packages/eslint-plugin/src/configs/all.ts +++ b/packages/eslint-plugin/src/configs/all.ts @@ -143,9 +143,9 @@ export = { '@typescript-eslint/padding-line-between-statements': 'error', '@typescript-eslint/parameter-properties': 'error', '@typescript-eslint/prefer-as-const': 'error', - '@typescript-eslint/prefer-enum-initializers': 'error', 'prefer-destructuring': 'off', '@typescript-eslint/prefer-destructuring': 'error', + '@typescript-eslint/prefer-enum-initializers': 'error', '@typescript-eslint/prefer-for-of': 'error', '@typescript-eslint/prefer-function-type': 'error', '@typescript-eslint/prefer-includes': 'error', diff --git a/packages/eslint-plugin/src/configs/disable-type-checked.ts b/packages/eslint-plugin/src/configs/disable-type-checked.ts index 38a7ffd079d8..4bacae681569 100644 --- a/packages/eslint-plugin/src/configs/disable-type-checked.ts +++ b/packages/eslint-plugin/src/configs/disable-type-checked.ts @@ -34,7 +34,9 @@ export = { '@typescript-eslint/no-unsafe-enum-comparison': 'off', '@typescript-eslint/no-unsafe-member-access': 'off', '@typescript-eslint/no-unsafe-return': 'off', + '@typescript-eslint/no-unsafe-unary-minus': 'off', '@typescript-eslint/non-nullable-type-assertion-style': 'off', + '@typescript-eslint/prefer-destructuring': 'off', '@typescript-eslint/prefer-includes': 'off', '@typescript-eslint/prefer-nullish-coalescing': 'off', '@typescript-eslint/prefer-optional-chain': 'off', From 1b0875b9ca8824b02c47569fe4d7079eb8cd853d Mon Sep 17 00:00:00 2001 From: Gabriel CM Date: Thu, 7 Dec 2023 20:22:59 -0300 Subject: [PATCH 3/9] docs: testing rules review changes + build callout --- .../local-development/Local_Linking.mdx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/contributing/local-development/Local_Linking.mdx b/docs/contributing/local-development/Local_Linking.mdx index 4d14a3669aa2..e2687223c400 100644 --- a/docs/contributing/local-development/Local_Linking.mdx +++ b/docs/contributing/local-development/Local_Linking.mdx @@ -8,7 +8,7 @@ The general strategy to do so is: 1. [Global linking](#global-linking): Use your package manager's global link command to make `@typescript-eslint/*` packages available as global symlinks. 2. [Repository linking](#repository-linking): Use your package manager's link command to reference those global symlinks in the local downstream repository. -3. [Testing rules](#testing): Test your local rules and plugins by enabling them in the local downstream repository. +3. [Testing rules](#testing-rules): Test your local rules and plugins by enabling them in the local downstream repository. ## Global Linking @@ -50,19 +50,20 @@ To check that the local package is being used, consider adding a `console.log("H Now that you've linked the `@typescript-eslint/*` packages with your local downstream repository, the next step would be to include the rule on the local repository ESLint configuration file, e.g: -```json +```json title=".eslintrc.json" { "rules": { "@typescript-eslint/your-awesome-rule": "error" } - // etc + // ... } ``` -After that, you just need to run your repository `lint` script. +After that, you need to run your repository's `lint` script and your changes should be reflected on the project. -- `npm run lint` -- `yarn lint` +:::caution +It's important to note that changes inside `@typescript-eslint` will not be reflected automatically inside your local repository! To update your linked repository, you'll need to run `yarn build` to build these changes. +::: ## Troubleshooting From 0fdf55a80f8c1982c27f0ffedbf4ab834b75845c Mon Sep 17 00:00:00 2001 From: auvred <61150013+auvred@users.noreply.github.com> Date: Wed, 13 Dec 2023 17:07:31 +0300 Subject: [PATCH 4/9] docs(eslint-plugin): [require-array-sort-compare] sync rule description (#8061) --- packages/eslint-plugin/docs/rules/require-array-sort-compare.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-plugin/docs/rules/require-array-sort-compare.md b/packages/eslint-plugin/docs/rules/require-array-sort-compare.md index 8bb7d3fe9e03..a96ad7446161 100644 --- a/packages/eslint-plugin/docs/rules/require-array-sort-compare.md +++ b/packages/eslint-plugin/docs/rules/require-array-sort-compare.md @@ -1,5 +1,5 @@ --- -description: 'Require `Array#sort` calls to always provide a `compareFunction`.' +description: 'Require `Array#sort` and `Array#toSorted` calls to always provide a `compareFunction`.' --- > 🛑 This file is source code, not the primary documentation location! 🛑 From 763e6bc1b7043a9c149705817936e22466631904 Mon Sep 17 00:00:00 2001 From: auvred <61150013+auvred@users.noreply.github.com> Date: Wed, 13 Dec 2023 17:12:17 +0300 Subject: [PATCH 5/9] chore: resolve internal lint issues with new no-useless-template-literals rule (#8060) --- packages/rule-schema-to-typescript-types/src/printAST.ts | 2 +- packages/scope-manager/tests/util/serializers/TSESTreeNode.ts | 2 +- packages/scope-manager/tests/util/serializers/baseSerializer.ts | 2 +- packages/website/src/pages/index.tsx | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/rule-schema-to-typescript-types/src/printAST.ts b/packages/rule-schema-to-typescript-types/src/printAST.ts index 70dd47924f4e..f2ff982fb3ab 100644 --- a/packages/rule-schema-to-typescript-types/src/printAST.ts +++ b/packages/rule-schema-to-typescript-types/src/printAST.ts @@ -162,7 +162,7 @@ function printAndMaybeParenthesise(ast: AST): CodeWithComments { }; } return { - code: `${printed.code}`, + code: printed.code, commentLines: printed.commentLines, }; } diff --git a/packages/scope-manager/tests/util/serializers/TSESTreeNode.ts b/packages/scope-manager/tests/util/serializers/TSESTreeNode.ts index ace1e809da69..06e00228653b 100644 --- a/packages/scope-manager/tests/util/serializers/TSESTreeNode.ts +++ b/packages/scope-manager/tests/util/serializers/TSESTreeNode.ts @@ -37,7 +37,7 @@ const serializer: NewPlugin = { const keys = Object.keys(node).filter(k => !EXCLUDED_KEYS.has(k)); if (keys.length === 0) { - return `${node.type}`; + return node.type; } if (SEEN_NODES.has(node)) { diff --git a/packages/scope-manager/tests/util/serializers/baseSerializer.ts b/packages/scope-manager/tests/util/serializers/baseSerializer.ts index 4a2932341b3f..733e4971c78b 100644 --- a/packages/scope-manager/tests/util/serializers/baseSerializer.ts +++ b/packages/scope-manager/tests/util/serializers/baseSerializer.ts @@ -45,7 +45,7 @@ function createSerializer( if (thing.$id) { if (SEEN_THINGS.has(thing)) { - return `${name}`; + return name; } SEEN_THINGS.add(thing); } diff --git a/packages/website/src/pages/index.tsx b/packages/website/src/pages/index.tsx index 4b1623c7c756..6305491c2629 100644 --- a/packages/website/src/pages/index.tsx +++ b/packages/website/src/pages/index.tsx @@ -133,7 +133,7 @@ function Feature({ title, description }: FeatureItem): React.JSX.Element { function Home(): React.JSX.Element { const { siteConfig } = useDocusaurusContext(); return ( - +
From 47390bb41930f274504cab0d5e5296369fe741a6 Mon Sep 17 00:00:00 2001 From: James <5511220+Zamiell@users.noreply.github.com> Date: Wed, 13 Dec 2023 11:32:40 -0500 Subject: [PATCH 6/9] docs(eslint-plugin): [require-array-sort-compare] generalize sort method names (#8062) docs: streamline --- .../eslint-plugin/docs/rules/require-array-sort-compare.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/eslint-plugin/docs/rules/require-array-sort-compare.md b/packages/eslint-plugin/docs/rules/require-array-sort-compare.md index a96ad7446161..ddef5a699839 100644 --- a/packages/eslint-plugin/docs/rules/require-array-sort-compare.md +++ b/packages/eslint-plugin/docs/rules/require-array-sort-compare.md @@ -15,11 +15,11 @@ For example, when sorting numbers, this results in a "10 before 2" order: [1, 2, 3, 10, 20, 30].sort(); //→ [1, 10, 2, 20, 3, 30] ``` -This rule reports on any call to the `Array#sort()` method that doesn't provide a `compare` argument. +This rule reports on any call to the sort methods that do not provide a `compare` argument. ## Examples -This rule aims to ensure all calls of the native `Array#sort` method provide a `compareFunction`, while ignoring calls to user-defined `sort` methods. +This rule aims to ensure all calls of the native sort methods provide a `compareFunction`, while ignoring calls to user-defined methods. From 3158881792aa7ed1f80f0aee458f3a82d23c13f7 Mon Sep 17 00:00:00 2001 From: "typescript-eslint[bot]" <53356952+typescript-eslint[bot]@users.noreply.github.com> Date: Fri, 15 Dec 2023 13:33:50 +1030 Subject: [PATCH 7/9] chore: update sponsors (#8069) Co-authored-by: typescript-eslint[bot] --- packages/website/data/sponsors.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/website/data/sponsors.json b/packages/website/data/sponsors.json index 60c272040f0a..2b2604e9524d 100644 --- a/packages/website/data/sponsors.json +++ b/packages/website/data/sponsors.json @@ -1,4 +1,11 @@ [ + { + "id": "ESLint", + "image": "https://images.opencollective.com/eslint/96b09dc/logo.png", + "name": "ESLint", + "totalDonations": 2820000, + "website": "https://eslint.org/" + }, { "id": "Indeed", "image": "https://images.opencollective.com/indeed/4b8725e/logo.png", @@ -13,13 +20,6 @@ "totalDonations": 825000, "website": "https://nx.dev" }, - { - "id": "ESLint", - "image": "https://images.opencollective.com/eslint/96b09dc/logo.png", - "name": "ESLint", - "totalDonations": 410000, - "website": "https://eslint.org/" - }, { "id": "Hugging Face", "image": "https://images.opencollective.com/huggingface/5c934ee/logo.png", From b9d08d526ef912b14ba3863ffb2f9add04f30593 Mon Sep 17 00:00:00 2001 From: Gabriel Costa Date: Wed, 27 Dec 2023 21:08:26 -0300 Subject: [PATCH 8/9] Update docs/contributing/local-development/Local_Linking.mdx MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Josh Goldberg ✨ --- docs/contributing/local-development/Local_Linking.mdx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/contributing/local-development/Local_Linking.mdx b/docs/contributing/local-development/Local_Linking.mdx index e2687223c400..0a67518825c7 100644 --- a/docs/contributing/local-development/Local_Linking.mdx +++ b/docs/contributing/local-development/Local_Linking.mdx @@ -62,7 +62,9 @@ Now that you've linked the `@typescript-eslint/*` packages with your local downs After that, you need to run your repository's `lint` script and your changes should be reflected on the project. :::caution -It's important to note that changes inside `@typescript-eslint` will not be reflected automatically inside your local repository! To update your linked repository, you'll need to run `yarn build` to build these changes. +Changes to `@typescript-eslint/` packages will not be reflected inside your linked repository until they're built locally. +To re-build all packages, run `yarn build` from the root. +To start a watch mode builder on just the ESLint plugin, run `yarn build --watch` from `./packages/eslint-plugin`. ::: ## Troubleshooting From 62fc3877129f8ce98920b7615d5873c75ccef9e2 Mon Sep 17 00:00:00 2001 From: Gabriel Costa Moura Date: Wed, 3 Jan 2024 09:41:24 -0300 Subject: [PATCH 9/9] docs: changed section name + callout type from caution to note --- docs/contributing/local-development/Local_Linking.mdx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/contributing/local-development/Local_Linking.mdx b/docs/contributing/local-development/Local_Linking.mdx index 0a67518825c7..7c7b6cdaf086 100644 --- a/docs/contributing/local-development/Local_Linking.mdx +++ b/docs/contributing/local-development/Local_Linking.mdx @@ -8,7 +8,7 @@ The general strategy to do so is: 1. [Global linking](#global-linking): Use your package manager's global link command to make `@typescript-eslint/*` packages available as global symlinks. 2. [Repository linking](#repository-linking): Use your package manager's link command to reference those global symlinks in the local downstream repository. -3. [Testing rules](#testing-rules): Test your local rules and plugins by enabling them in the local downstream repository. +3. [Trying rules](#trying-rules): Test your local rules and plugins by enabling them in the local downstream repository. ## Global Linking @@ -46,7 +46,7 @@ Now, you should be able to run ESLint in the local downstream repository as you To check that the local package is being used, consider adding a `console.log("Hello, world!");` to a file such as `./packages/eslint-plugin/dist/index.js` and making sure that log appears when linting the local downstream repository. ::: -## Testing Rules +## Trying Rules Now that you've linked the `@typescript-eslint/*` packages with your local downstream repository, the next step would be to include the rule on the local repository ESLint configuration file, e.g: @@ -61,7 +61,7 @@ Now that you've linked the `@typescript-eslint/*` packages with your local downs After that, you need to run your repository's `lint` script and your changes should be reflected on the project. -:::caution +:::note Changes to `@typescript-eslint/` packages will not be reflected inside your linked repository until they're built locally. To re-build all packages, run `yarn build` from the root. To start a watch mode builder on just the ESLint plugin, run `yarn build --watch` from `./packages/eslint-plugin`.