@rushstack/eslint-config 2.5.1 → 2.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,85 +1,85 @@
1
- // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2
- // See LICENSE in the project root for license information.
3
-
4
- // For the first 5 years of Rush, our lint rules required explicit types for most declarations
5
- // such as function parameters, function return values, and exported variables. Although more verbose,
6
- // declaring types (instead of relying on type inference) encourages engineers to create interfaces
7
- // that inspire discussions about data structure design. It also makes source files easier
8
- // to understand for code reviewers who may be unfamiliar with a particular project. Once developers get
9
- // used to the extra work of declaring types, it turns out to be a surprisingly popular practice.
10
- //
11
- // However in 2020, to make adoption easier for existing projects, this rule was relaxed. Explicit
12
- // type declarations are now optional for local variables (although still required in other contexts).
13
- // See this GitHub issue for background:
14
- //
15
- // https://github.com/microsoft/rushstack/issues/2206
16
- //
17
- // If you are onboarding a large existing code base, this new default will make adoption easier.
18
- //
19
- // On the other hand, if your top priority is to make source files more friendly for other
20
- // people to read, enable the "@rushstack/eslint-config/mixins/friendly-locals" mixin.
21
- // It will restore the requirement that local variables should have explicit type declarations.
22
- //
23
- // IMPORTANT: Your .eslintrc.js "extends" field must load mixins AFTER the profile.
24
- module.exports = {
25
- overrides: [
26
- {
27
- files: ['*.ts', '*.tsx'],
28
- rules: {
29
- '@rushstack/typedef-var': 'off', // <--- disabled by the mixin
30
-
31
- '@typescript-eslint/typedef': [
32
- 'warn',
33
- {
34
- arrayDestructuring: false,
35
- arrowParameter: false,
36
- memberVariableDeclaration: true,
37
- objectDestructuring: false,
38
- parameter: true,
39
- propertyDeclaration: true,
40
-
41
- variableDeclaration: true, // <--- reenabled by the mixin
42
-
43
- variableDeclarationIgnoreFunction: true
44
- }
45
- ]
46
- }
47
- },
48
- // Note that the above block also applies to *.test.ts, so we need to
49
- // reapply those overrides.
50
- {
51
- files: [
52
- // Test files
53
- '*.test.ts',
54
- '*.test.tsx',
55
- '*.spec.ts',
56
- '*.spec.tsx',
57
-
58
- // Facebook convention
59
- '**/__mocks__/*.ts',
60
- '**/__mocks__/*.tsx',
61
- '**/__tests__/*.ts',
62
- '**/__tests__/*.tsx',
63
-
64
- // Microsoft convention
65
- '**/test/*.ts',
66
- '**/test/*.tsx'
67
- ],
68
- rules: {
69
- '@typescript-eslint/typedef': [
70
- 'warn',
71
- {
72
- arrayDestructuring: false,
73
- arrowParameter: false,
74
- memberVariableDeclaration: true,
75
- objectDestructuring: false,
76
- parameter: true,
77
- propertyDeclaration: true,
78
- variableDeclaration: false, // <--- special case for test files
79
- variableDeclarationIgnoreFunction: true
80
- }
81
- ]
82
- }
83
- }
84
- ]
85
- };
1
+ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2
+ // See LICENSE in the project root for license information.
3
+
4
+ // For the first 5 years of Rush, our lint rules required explicit types for most declarations
5
+ // such as function parameters, function return values, and exported variables. Although more verbose,
6
+ // declaring types (instead of relying on type inference) encourages engineers to create interfaces
7
+ // that inspire discussions about data structure design. It also makes source files easier
8
+ // to understand for code reviewers who may be unfamiliar with a particular project. Once developers get
9
+ // used to the extra work of declaring types, it turns out to be a surprisingly popular practice.
10
+ //
11
+ // However in 2020, to make adoption easier for existing projects, this rule was relaxed. Explicit
12
+ // type declarations are now optional for local variables (although still required in other contexts).
13
+ // See this GitHub issue for background:
14
+ //
15
+ // https://github.com/microsoft/rushstack/issues/2206
16
+ //
17
+ // If you are onboarding a large existing code base, this new default will make adoption easier.
18
+ //
19
+ // On the other hand, if your top priority is to make source files more friendly for other
20
+ // people to read, enable the "@rushstack/eslint-config/mixins/friendly-locals" mixin.
21
+ // It will restore the requirement that local variables should have explicit type declarations.
22
+ //
23
+ // IMPORTANT: Your .eslintrc.js "extends" field must load mixins AFTER the profile.
24
+ module.exports = {
25
+ overrides: [
26
+ {
27
+ files: ['*.ts', '*.tsx'],
28
+ rules: {
29
+ '@rushstack/typedef-var': 'off', // <--- disabled by the mixin
30
+
31
+ '@typescript-eslint/typedef': [
32
+ 'warn',
33
+ {
34
+ arrayDestructuring: false,
35
+ arrowParameter: false,
36
+ memberVariableDeclaration: true,
37
+ objectDestructuring: false,
38
+ parameter: true,
39
+ propertyDeclaration: true,
40
+
41
+ variableDeclaration: true, // <--- reenabled by the mixin
42
+
43
+ variableDeclarationIgnoreFunction: true
44
+ }
45
+ ]
46
+ }
47
+ },
48
+ // Note that the above block also applies to *.test.ts, so we need to
49
+ // reapply those overrides.
50
+ {
51
+ files: [
52
+ // Test files
53
+ '*.test.ts',
54
+ '*.test.tsx',
55
+ '*.spec.ts',
56
+ '*.spec.tsx',
57
+
58
+ // Facebook convention
59
+ '**/__mocks__/*.ts',
60
+ '**/__mocks__/*.tsx',
61
+ '**/__tests__/*.ts',
62
+ '**/__tests__/*.tsx',
63
+
64
+ // Microsoft convention
65
+ '**/test/*.ts',
66
+ '**/test/*.tsx'
67
+ ],
68
+ rules: {
69
+ '@typescript-eslint/typedef': [
70
+ 'warn',
71
+ {
72
+ arrayDestructuring: false,
73
+ arrowParameter: false,
74
+ memberVariableDeclaration: true,
75
+ objectDestructuring: false,
76
+ parameter: true,
77
+ propertyDeclaration: true,
78
+ variableDeclaration: false, // <--- special case for test files
79
+ variableDeclarationIgnoreFunction: true
80
+ }
81
+ ]
82
+ }
83
+ }
84
+ ]
85
+ };
@@ -1,21 +1,21 @@
1
- // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2
- // See LICENSE in the project root for license information.
3
-
4
- // This mixin implements the "packlet" formalism for organizing source files.
5
- // For more information, see the documentation here:
6
- // https://www.npmjs.com/package/@rushstack/eslint-plugin-packlets
7
- module.exports = {
8
- plugins: ['@rushstack/eslint-plugin-packlets'],
9
-
10
- overrides: [
11
- {
12
- // Declare an override that applies to TypeScript files only
13
- files: ['*.ts', '*.tsx'],
14
-
15
- rules: {
16
- '@rushstack/packlets/mechanics': 'warn',
17
- '@rushstack/packlets/circular-deps': 'warn'
18
- }
19
- }
20
- ]
21
- };
1
+ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2
+ // See LICENSE in the project root for license information.
3
+
4
+ // This mixin implements the "packlet" formalism for organizing source files.
5
+ // For more information, see the documentation here:
6
+ // https://www.npmjs.com/package/@rushstack/eslint-plugin-packlets
7
+ module.exports = {
8
+ plugins: ['@rushstack/eslint-plugin-packlets'],
9
+
10
+ overrides: [
11
+ {
12
+ // Declare an override that applies to TypeScript files only
13
+ files: ['*.ts', '*.tsx'],
14
+
15
+ rules: {
16
+ '@rushstack/packlets/mechanics': 'warn',
17
+ '@rushstack/packlets/circular-deps': 'warn'
18
+ }
19
+ }
20
+ ]
21
+ };
package/mixins/react.js CHANGED
@@ -1,77 +1,77 @@
1
- // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2
- // See LICENSE in the project root for license information.
3
-
4
- // This mixin applies some additional checks for projects using the React library. For more information,
5
- // please see the README.md for "@rushstack/eslint-config".
6
- module.exports = {
7
- // Plugin documentation: https://www.npmjs.com/package/eslint-plugin-react
8
- plugins: ['eslint-plugin-react'],
9
-
10
- settings: {
11
- react: {
12
- // The default value is "detect". Automatic detection works by loading the entire React library
13
- // into the linter's process, which is inefficient. It is recommended to specify the version
14
- // explicity. For details, see README.md for "@rushstack/eslint-config".
15
- version: 'detect'
16
- }
17
- },
18
-
19
- overrides: [
20
- {
21
- // Declare an override that applies to TypeScript files only
22
- files: ['*.ts', '*.tsx'],
23
-
24
- rules: {
25
- // RATIONALE: When React components are added to an array, they generally need a "key".
26
- 'react/jsx-key': 'warn',
27
-
28
- // RATIONALE: Catches a common coding practice that significantly impacts performance.
29
- 'react/jsx-no-bind': 'warn',
30
-
31
- // RATIONALE: Catches a common coding mistake.
32
- 'react/jsx-no-comment-textnodes': 'warn',
33
-
34
- // RATIONALE: Security risk.
35
- 'react/jsx-no-target-blank': 'warn',
36
-
37
- // RATIONALE: Fixes the no-unused-vars rule to make it compatible with React
38
- 'react/jsx-uses-react': 'warn',
39
-
40
- // RATIONALE: Fixes the no-unused-vars rule to make it compatible with React
41
- 'react/jsx-uses-vars': 'warn',
42
-
43
- // RATIONALE: Catches a common coding mistake.
44
- 'react/no-children-prop': 'warn',
45
-
46
- // RATIONALE: Catches a common coding mistake.
47
- 'react/no-danger-with-children': 'warn',
48
-
49
- // RATIONALE: Avoids usage of deprecated APIs.
50
- //
51
- // Note that the set of deprecated APIs is determined by the "react.version" setting.
52
- 'react/no-deprecated': 'warn',
53
-
54
- // RATIONALE: Catches a common coding mistake.
55
- 'react/no-direct-mutation-state': 'warn',
56
-
57
- // RATIONALE: Catches some common coding mistakes.
58
- 'react/no-unescaped-entities': 'warn',
59
-
60
- // RATIONALE: Avoids a potential performance problem.
61
- 'react/no-find-dom-node': 'warn',
62
-
63
- // RATIONALE: Deprecated API.
64
- 'react/no-is-mounted': 'warn',
65
-
66
- // RATIONALE: Deprecated API.
67
- 'react/no-render-return-value': 'warn',
68
-
69
- // RATIONALE: Deprecated API.
70
- 'react/no-string-refs': 'warn',
71
-
72
- // RATIONALE: Improves syntax for some cases that are not already handled by Prettier.
73
- 'react/self-closing-comp': 'warn'
74
- }
75
- }
76
- ]
77
- };
1
+ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2
+ // See LICENSE in the project root for license information.
3
+
4
+ // This mixin applies some additional checks for projects using the React library. For more information,
5
+ // please see the README.md for "@rushstack/eslint-config".
6
+ module.exports = {
7
+ // Plugin documentation: https://www.npmjs.com/package/eslint-plugin-react
8
+ plugins: ['eslint-plugin-react'],
9
+
10
+ settings: {
11
+ react: {
12
+ // The default value is "detect". Automatic detection works by loading the entire React library
13
+ // into the linter's process, which is inefficient. It is recommended to specify the version
14
+ // explicity. For details, see README.md for "@rushstack/eslint-config".
15
+ version: 'detect'
16
+ }
17
+ },
18
+
19
+ overrides: [
20
+ {
21
+ // Declare an override that applies to TypeScript files only
22
+ files: ['*.ts', '*.tsx'],
23
+
24
+ rules: {
25
+ // RATIONALE: When React components are added to an array, they generally need a "key".
26
+ 'react/jsx-key': 'warn',
27
+
28
+ // RATIONALE: Catches a common coding practice that significantly impacts performance.
29
+ 'react/jsx-no-bind': 'warn',
30
+
31
+ // RATIONALE: Catches a common coding mistake.
32
+ 'react/jsx-no-comment-textnodes': 'warn',
33
+
34
+ // RATIONALE: Security risk.
35
+ 'react/jsx-no-target-blank': 'warn',
36
+
37
+ // RATIONALE: Fixes the no-unused-vars rule to make it compatible with React
38
+ 'react/jsx-uses-react': 'warn',
39
+
40
+ // RATIONALE: Fixes the no-unused-vars rule to make it compatible with React
41
+ 'react/jsx-uses-vars': 'warn',
42
+
43
+ // RATIONALE: Catches a common coding mistake.
44
+ 'react/no-children-prop': 'warn',
45
+
46
+ // RATIONALE: Catches a common coding mistake.
47
+ 'react/no-danger-with-children': 'warn',
48
+
49
+ // RATIONALE: Avoids usage of deprecated APIs.
50
+ //
51
+ // Note that the set of deprecated APIs is determined by the "react.version" setting.
52
+ 'react/no-deprecated': 'warn',
53
+
54
+ // RATIONALE: Catches a common coding mistake.
55
+ 'react/no-direct-mutation-state': 'warn',
56
+
57
+ // RATIONALE: Catches some common coding mistakes.
58
+ 'react/no-unescaped-entities': 'warn',
59
+
60
+ // RATIONALE: Avoids a potential performance problem.
61
+ 'react/no-find-dom-node': 'warn',
62
+
63
+ // RATIONALE: Deprecated API.
64
+ 'react/no-is-mounted': 'warn',
65
+
66
+ // RATIONALE: Deprecated API.
67
+ 'react/no-render-return-value': 'warn',
68
+
69
+ // RATIONALE: Deprecated API.
70
+ 'react/no-string-refs': 'warn',
71
+
72
+ // RATIONALE: Improves syntax for some cases that are not already handled by Prettier.
73
+ 'react/self-closing-comp': 'warn'
74
+ }
75
+ }
76
+ ]
77
+ };
package/mixins/tsdoc.js CHANGED
@@ -1,20 +1,20 @@
1
- // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2
- // See LICENSE in the project root for license information.
3
-
4
- // This mixin validates code comments to ensure that they follow the TSDoc standard. For more
5
- // information please see the README.md for @rushstack/eslint-config.
6
- module.exports = {
7
- // The plugin documentation is here: https://www.npmjs.com/package/eslint-plugin-tsdoc
8
- plugins: ['eslint-plugin-tsdoc'],
9
-
10
- overrides: [
11
- {
12
- // Declare an override that applies to TypeScript files only
13
- files: ['*.ts', '*.tsx'],
14
-
15
- rules: {
16
- 'tsdoc/syntax': 'warn'
17
- }
18
- }
19
- ]
20
- };
1
+ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2
+ // See LICENSE in the project root for license information.
3
+
4
+ // This mixin validates code comments to ensure that they follow the TSDoc standard. For more
5
+ // information please see the README.md for @rushstack/eslint-config.
6
+ module.exports = {
7
+ // The plugin documentation is here: https://www.npmjs.com/package/eslint-plugin-tsdoc
8
+ plugins: ['eslint-plugin-tsdoc'],
9
+
10
+ overrides: [
11
+ {
12
+ // Declare an override that applies to TypeScript files only
13
+ files: ['*.ts', '*.tsx'],
14
+
15
+ rules: {
16
+ 'tsdoc/syntax': 'warn'
17
+ }
18
+ }
19
+ ]
20
+ };
package/package.json CHANGED
@@ -1,45 +1,47 @@
1
1
  {
2
- "name": "@rushstack/eslint-config",
3
- "version": "2.5.1",
4
- "description": "A TypeScript ESLint ruleset designed for large teams and projects",
5
- "license": "MIT",
6
- "repository": {
7
- "url": "https://github.com/microsoft/rushstack.git",
8
- "type": "git",
9
- "directory": "stack/eslint-config"
10
- },
11
- "homepage": "https://rushstack.io",
12
- "keywords": [
13
- "eslint",
14
- "eslint-config",
15
- "monorepo",
16
- "rush",
17
- "scalable",
18
- "scale",
19
- "typescript"
20
- ],
21
- "peerDependencies": {
22
- "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0",
23
- "typescript": ">=3.0.0"
24
- },
25
- "dependencies": {
26
- "@rushstack/eslint-patch": "1.1.0",
27
- "@rushstack/eslint-plugin": "0.8.4",
28
- "@rushstack/eslint-plugin-packlets": "0.3.4",
29
- "@rushstack/eslint-plugin-security": "0.2.4",
30
- "@typescript-eslint/eslint-plugin": "~5.6.0",
31
- "@typescript-eslint/experimental-utils": "~5.6.0",
32
- "@typescript-eslint/parser": "~5.6.0",
33
- "@typescript-eslint/typescript-estree": "~5.6.0",
34
- "eslint-plugin-promise": "~6.0.0",
35
- "eslint-plugin-react": "~7.27.1",
36
- "eslint-plugin-tsdoc": "~0.2.14"
37
- },
38
- "devDependencies": {
39
- "eslint": "~8.3.0",
40
- "typescript": "~4.5.2"
41
- },
42
- "scripts": {
43
- "build": ""
44
- }
45
- }
2
+ "name": "@rushstack/eslint-config",
3
+ "version": "2.5.2",
4
+ "description": "A TypeScript ESLint ruleset designed for large teams and projects",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "url": "https://github.com/microsoft/rushstack.git",
8
+ "type": "git",
9
+ "directory": "eslint/eslint-config"
10
+ },
11
+ "homepage": "https://rushstack.io",
12
+ "keywords": [
13
+ "eslint",
14
+ "eslint-config",
15
+ "monorepo",
16
+ "rush",
17
+ "scalable",
18
+ "scale",
19
+ "typescript"
20
+ ],
21
+ "peerDependencies": {
22
+ "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0",
23
+ "typescript": ">=3.0.0"
24
+ },
25
+ "dependencies": {
26
+ "@rushstack/eslint-patch": "1.1.1",
27
+ "@rushstack/eslint-plugin": "0.8.5",
28
+ "@rushstack/eslint-plugin-packlets": "0.3.5",
29
+ "@rushstack/eslint-plugin-security": "0.2.5",
30
+ "@typescript-eslint/eslint-plugin": "~5.6.0",
31
+ "@typescript-eslint/experimental-utils": "~5.6.0",
32
+ "@typescript-eslint/parser": "~5.6.0",
33
+ "@typescript-eslint/typescript-estree": "~5.6.0",
34
+ "eslint-plugin-promise": "~6.0.0",
35
+ "eslint-plugin-react": "~7.27.1",
36
+ "eslint-plugin-tsdoc": "~0.2.14"
37
+ },
38
+ "devDependencies": {
39
+ "eslint": "~8.7.0",
40
+ "typescript": "~4.5.2"
41
+ },
42
+ "scripts": {
43
+ "build": "",
44
+ "_phase:build": ""
45
+ },
46
+ "readme": "# @rushstack/eslint-config\n\nA TypeScript ESLint ruleset designed for large teams and projects.\n\n## Philosophy\n\nWhen you work in a small repo, you spend most of your time writing code. You know what each file does. You want lint\nrules that keep things concise and won't slow you down. That's the situation for the 99% of open source projects\nthat shape popular coding conventions.\n\nBut as your organization scales up, things may change. People come and go. Projects frequently get handed off between\nteams. Every day, you find yourself working with files that you've never seen before, created by strangers whom\nyou may never meet. It's annoying to constantly come across inconsistent styles. It can be frustrating to decipher\nexpressions that seem to require a TypeScript Ph.D. -- especially for newcomers and junior contributors. When\nrefactoring in bulk, you may edit lots of files without reading them very carefully. In short, the linting needs\nreflect different priorities:\n\n**Small scale:** We can assume developers are _familiar_ with the project. We want code to be _easy to write_.\n\n**Large scale:** Developers are generally _unfamiliar_ with projects. Code must be _easy to read_. If not,\nthere's a risk of fragmentation, duplication of efforts, and costly rewrites. (Enabling people to churn out\nlots of code really fast is still a goal of course; just not the #1 priority.)\n\nWelcome to the world of [Rush Stack](https://rushstack.io/)! The `@rushstack/eslint-config` package was specifically\ndesigned around the the requirements of large teams and projects.\n\n\n## Implementation\n\n- **Monorepo friendly:** The `@rushstack/eslint-config` package has direct dependencies on all the ESLint plugins\n that it needs. This avoids encumbering each consuming project with the obligation to satisfy a peer dependencies.\n It also ensures that the installed plugin versions were tested for compatibility together.\n\n- **Battle tested:** The `@rushstack/eslint-config` rules have been vetted on large production monorepos, across\n a broad set of projects, teams, and requirements. These rules embody a way of working that scales. Quite\n a lot of discussion and evolution went into them.\n\n- **Designed for Prettier:** The `@rushstack/eslint-config` ruleset is designed to be used together with\n the [Prettier](https://prettier.io/) code formatter. This separation of workflows avoids hassling developers with\n lint \"errors\" for frivolous issues like spaces and commas. Instead, those issues get fixed automatically whenever\n you save or commit a file. Prettier also avoids frivolous debates: its defaults have already been debated\n at length and adopted by a sizeable community. No need to reinvent the wheel!\n\n- **Explicit:** The ruleset does not import any \"recommended\" templates from other ESLint packages. This avoids\n worrying about precedence issues due to import order. It also eliminates confusion caused by files\n overriding/undoing settings from another file. Each rule is configured once, in one\n [easy-to-read file](https://github.com/microsoft/rushstack/blob/master/stack/eslint-config/profile/_common.js).\n\n- **Minimal configuration:** To use this ruleset, your **.eslintrc.js** will need to choose one **\"profile\"**\n and possibly one or two **\"mixins\"** that cover special cases. Beyond that, our goal is to reduce monorepo\n maintenance by providing a small set of **.eslintrc.js** recipes that can be reused across many different projects.\n (This sometimes means that rules will be included which have no effect for a particular project, however in practice\n the installation/execution cost for unused rules turns out to be negligible.)\n\n\n## Getting started in 3 steps\n\nApplying the ruleset to your project is quick and easy. You install the package, then create an **.eslintrc.js** file\nand select an appropriate project profile. Optionally you can also add some \"mixins\" to enable additional rules.\nLet's walk through those three steps in more detail.\n\n### 1. Install the package\n\nTo install the package, do this:\n\n```sh\n$ cd your-project-folder\n$ npm install --save-dev eslint\n$ npm install --save-dev typescript\n$ npm install --save-dev @rushstack/eslint-config\n```\n\n### 2. Choose one profile\n\nThe ruleset currently supports three different \"profile\" strings, which select lint rules applicable for\nyour project:\n\n- `@rushstack/eslint-config/profile/node` - This profile enables lint rules intended for a general Node.js project,\n typically a web service. It enables security rules that assume the service could receive malicious inputs from an\n untrusted user.\n\n- `@rushstack/eslint-config/profile/node-trusted-tool` - This profile enables lint rules intended for a Node.js project\n whose inputs will always come from a developer or other trusted source. Most build system tasks are like this,\n since they operate exclusively on files prepared by a developer. This profile disables certain security rules that\n would otherwise prohibit APIs that could cause a denial-of-service by consuming too many resources, or which might\n interact with the filesystem in unsafe ways. Such activities are safe and commonplace for a trusted tool.\n **DO NOT use this profile for a library project that might also be loaded by a Node.js service.**\n\n- `@rushstack/eslint-config/profile/web-app` - This profile enables lint rules intended for a web application, for\n example security rules that are relevant to web browser APIs such as DOM.\n _Also use this profile if you are creating a library that can be consumed by both Node.js and web applications._\n\nAfter choosing a profile, create an **.eslintrc.js** config file that provides the NodeJS `__dirname` context\nfor TypeScript. Add your profile string in the `extends` field, as shown below:\n\n**.eslintrc.js**\n```ts\n// This is a workaround for https://github.com/eslint/eslint/issues/3458\nrequire('@rushstack/eslint-config/patch/modern-module-resolution');\n\nmodule.exports = {\n extends: [ \"@rushstack/eslint-config/profile/node\" ], // <---- put your profile string here\n parserOptions: { tsconfigRootDir: __dirname }\n};\n```\n\nThe `@rushstack/eslint-config` ruleset is intended to be used with the Prettier code formatter. For general\ninstructions on setting that up, please refer to the [Prettier docs](https://prettier.io/docs/en/index.html).\nFor Rush-specific settings, see the article\n[Rush: Enabling Prettier](https://rushjs.io/pages/maintainer/enabling_prettier/).\n\n\n### 3. Add any relevant mixins\n\nOptionally, you can add some \"mixins\" to your `extends` array to opt-in to some extra behaviors.\n\nImportant: Your **.eslintrc.js** `\"extends\"` field must load mixins after the profile entry.\n\n\n#### `@rushstack/eslint-config/mixins/friendly-locals`\n\nRequires explicit type declarations for local variables.\n\nFor the first 5 years of Rush, our lint rules required explicit types for most declarations\nsuch as function parameters, function return values, and exported variables. Although more verbose,\ndeclaring types (instead of relying on type inference) encourages engineers to create interfaces\nthat inspire discussions about data structure design. It also makes source files easier\nto understand for code reviewers who may be unfamiliar with a particular project. Once developers get\nused to the extra work of declaring types, it turns out to be a surprisingly popular practice.\n\nHowever in 2020, to make adoption easier for existing projects, this rule was relaxed. Explicit\ntype declarations are now optional for local variables (although still required in other contexts).\nSee [GitHub #2206](https://github.com/microsoft/rushstack/issues/2206) for background.\n\nIf you are onboarding a large existing code base, this new default will make adoption easier:\n\nExample source file without `mixins/friendly-locals`:\n```ts\nexport class MyDataService {\n . . .\n public queryResult(provider: IProvider): IResult {\n // Type inference is concise, but what are \"item\", \"index\", and \"data\"?\n const item = provider.getItem(provider.title);\n const index = item.fetchIndex();\n const data = index.get(provider.state);\n return data.results.filter(x => x.title === provider.title);\n }\n}\n```\n\nOn the other hand, if your priority is make source files more friendly for other people to read, you can enable\nthe `\"@rushstack/eslint-config/mixins/friendly-locals\"` mixin. This restores the requirement that local variables\nshould have explicit type declarations.\n\nExample source file with `mixins/friendly-locals`:\n```ts\nexport class MyDataService {\n . . .\n public queryResult(provider: IProvider): IResult {\n // This is more work for the person writing the code... but definitely easier to understand\n // for a code reviewer if they are unfamiliar with your project\n const item: ISalesReport = provider.getItem(provider.title);\n const index: Map<string, IGeographicData> = item.fetchIndex();\n const data: IGeographicData | undefined = index.get(provider.state);\n return data.results.filter(x => x.title === provider.title);\n }\n}\n```\n\nAdd the mixin to your `\"extends\"` field like this:\n\n**.eslintrc.js**\n```ts\n// This is a workaround for https://github.com/eslint/eslint/issues/3458\nrequire('@rushstack/eslint-config/patch/modern-module-resolution');\n\nmodule.exports = {\n extends: [\n \"@rushstack/eslint-config/profile/node\",\n \"@rushstack/eslint-config/mixins/friendly-locals\" // <----\n ],\n parserOptions: { tsconfigRootDir: __dirname }\n};\n```\n\n\n#### `@rushstack/eslint-config/mixins/packlets`\n\nPacklets provide a lightweight alternative to NPM packages for organizing source files within a single project.\nThis system is described in the [@rushstack/eslint-plugin-packlets](https://www.npmjs.com/package/@rushstack/eslint-plugin-packlets)\ndocumentation.\n\nTo use packlets, add the mixin to your `\"extends\"` field like this:\n\n**.eslintrc.js**\n```ts\n// This is a workaround for https://github.com/eslint/eslint/issues/3458\nrequire('@rushstack/eslint-config/patch/modern-module-resolution');\n\nmodule.exports = {\n extends: [\n \"@rushstack/eslint-config/profile/node\",\n \"@rushstack/eslint-config/mixins/packlets\" // <----\n ],\n parserOptions: { tsconfigRootDir: __dirname }\n};\n```\n\n\n#### `@rushstack/eslint-config/mixins/tsdoc`\n\nIf your project is using [API Extractor](https://api-extractor.com/) or another tool that uses\nthe [TSDoc](https://github.com/Microsoft/tsdoc) standard for doc comments, it's recommended to use the\n`\"@rushstack/eslint-config/mixins/tsdoc\"` mixin. It will enable\n[eslint-plugin-tsdoc](https://www.npmjs.com/package/eslint-plugin-tsdoc) validation for TypeScript doc comments.\n\nAdd the mixin to your `\"extends\"` field like this:\n\n**.eslintrc.js**\n```ts\n// This is a workaround for https://github.com/eslint/eslint/issues/3458\nrequire('@rushstack/eslint-config/patch/modern-module-resolution');\n\nmodule.exports = {\n extends: [\n \"@rushstack/eslint-config/profile/node\",\n \"@rushstack/eslint-config/mixins/tsdoc\" // <----\n ],\n parserOptions: { tsconfigRootDir: __dirname }\n};\n```\n\n\n#### `@rushstack/eslint-config/mixins/react`\n\nFor projects using the [React](https://reactjs.org/) library, the `\"@rushstack/eslint-config/mixins/react\"` mixin\nenables some recommended additional rules. These rules are selected via a mixin because they require you to:\n\n- Add `\"jsx\": \"react\"` to your **tsconfig.json**\n- Configure your `settings.react.version` as shown below. This determines which React APIs will be considered\n to be deprecated. (If you omit this, the React version will be detected automatically by\n [loading the entire React library](https://github.com/yannickcr/eslint-plugin-react/blob/4da74518bd78f11c9c6875a159ffbae7d26be693/lib/util/version.js#L23)\n into the linter's process, which is costly.)\n\nAdd the mixin to your `\"extends\"` field like this:\n\n**.eslintrc.js**\n```ts\n// This is a workaround for https://github.com/eslint/eslint/issues/3458\nrequire('@rushstack/eslint-config/patch/modern-module-resolution');\n\nmodule.exports = {\n extends: [\n \"@rushstack/eslint-config/profile/web-app\",\n \"@rushstack/eslint-config/mixins/react\" // <----\n ],\n parserOptions: { tsconfigRootDir: __dirname },\n\n settings: {\n react: {\n \"version\": \"16.9\" // <----\n }\n }\n};\n```\n\n\n## Links\n\n- [CHANGELOG.md](\n https://github.com/microsoft/rushstack/blob/master/stack/eslint-config/CHANGELOG.md) - Find\n out what's new in the latest version\n\n`@rushstack/eslint-config` is part of the [Rush Stack](https://rushstack.io/) family of projects.\n"
47
+ }
@@ -1,4 +1,4 @@
1
- // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2
- // See LICENSE in the project root for license information.
3
-
4
- require('@rushstack/eslint-patch/modern-module-resolution');
1
+ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2
+ // See LICENSE in the project root for license information.
3
+
4
+ require('@rushstack/eslint-patch/modern-module-resolution');
package/patch-eslint6.js CHANGED
@@ -1,8 +1,8 @@
1
- // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2
- // See LICENSE in the project root for license information.
3
-
4
- throw new Error(
5
- 'The patch-eslint6.js script has been rewritten to support both ESLint 6.x and 7.x.' +
6
- ' Please update your ESLint configuration to use this path instead:\n\n' +
7
- ' require("@rushstack/eslint-config/patch/modern-module-resolution");'
8
- );
1
+ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2
+ // See LICENSE in the project root for license information.
3
+
4
+ throw new Error(
5
+ 'The patch-eslint6.js script has been rewritten to support both ESLint 6.x and 7.x.' +
6
+ ' Please update your ESLint configuration to use this path instead:\n\n' +
7
+ ' require("@rushstack/eslint-config/patch/modern-module-resolution");'
8
+ );