You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[Propose a New Rule](https://eslint.org/docs/latest/contribute/propose-new-rule)
15
+
-[Propose a Rule Change](https://eslint.org/docs/latest/contribute/propose-rule-change)
16
+
-[Request a Change](https://eslint.org/docs/latest/contribute/request-change)
17
17
18
18
To report a security vulnerability in ESLint, please use our [create an advisory form](https://github.com/eslint/eslint/security/advisories/new) on GitHub.
Copy file name to clipboardExpand all lines: README.md
+36-36Lines changed: 36 additions & 36 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,9 +20,9 @@
20
20
21
21
ESLint is a tool for identifying and reporting on patterns found in ECMAScript/JavaScript code. In many ways, it is similar to JSLint and JSHint with a few exceptions:
22
22
23
-
-ESLint uses [Espree](https://github.com/eslint/js/tree/main/packages/espree) for JavaScript parsing.
24
-
-ESLint uses an AST to evaluate patterns in code.
25
-
-ESLint is completely pluggable, every single rule is a plugin and you can add more at runtime.
23
+
- ESLint uses [Espree](https://github.com/eslint/js/tree/main/packages/espree) for JavaScript parsing.
24
+
- ESLint uses an AST to evaluate patterns in code.
25
+
- ESLint is completely pluggable, every single rule is a plugin and you can add more at runtime.
26
26
27
27
## Table of Contents
28
28
@@ -87,9 +87,9 @@ export default defineConfig([
87
87
88
88
The names `"prefer-const"` and `"no-constant-binary-expression"` are the names of [rules](https://eslint.org/docs/rules) in ESLint. The first value is the error level of the rule and can be one of these values:
89
89
90
-
-`"off"` or `0` - turn the rule off
91
-
-`"warn"` or `1` - turn the rule on as a warning (doesn't affect exit code)
92
-
-`"error"` or `2` - turn the rule on as an error (exit code will be 1)
90
+
-`"off"` or `0` - turn the rule off
91
+
-`"warn"` or `1` - turn the rule on as a warning (doesn't affect exit code)
92
+
-`"error"` or `2` - turn the rule on as an error (exit code will be 1)
93
93
94
94
The three error levels allow you fine-grained control over how ESLint applies rules (for more configuration options and details, see the [configuration docs](https://eslint.org/docs/latest/use/configure)).
95
95
@@ -109,10 +109,10 @@ ESLint adheres to the [OpenJS Foundation Code of Conduct](https://eslint.org/con
109
109
110
110
Before filing an issue, please be sure to read the guidelines for what you're reporting:
-[Propose a New Rule](https://eslint.org/docs/latest/contribute/propose-new-rule)
114
+
-[Proposing a Rule Change](https://eslint.org/docs/latest/contribute/propose-rule-change)
115
+
-[Request a Change](https://eslint.org/docs/latest/contribute/request-change)
116
116
117
117
## Frequently Asked Questions
118
118
@@ -174,32 +174,32 @@ ESLint takes security seriously. We work hard to ensure that ESLint is safe for
174
174
175
175
ESLint follows [semantic versioning](https://semver.org). However, due to the nature of ESLint as a code quality tool, it's not always clear when a minor or major version bump occurs. To help clarify this for everyone, we've defined the following semantic versioning policy for ESLint:
176
176
177
-
-Patch release (intended to not break your lint build)
178
-
-A bug fix in a rule that results in ESLint reporting fewer linting errors.
179
-
-A bug fix to the CLI or core (including formatters).
180
-
-Improvements to documentation.
181
-
-Non-user-facing changes such as refactoring code, adding, deleting, or modifying tests, and increasing test coverage.
182
-
-Re-releasing after a failed release (i.e., publishing a release that doesn't work for anyone).
183
-
-Minor release (might break your lint build)
184
-
-A bug fix in a rule that results in ESLint reporting more linting errors.
185
-
-A new rule is created.
186
-
-A new option to an existing rule that does not result in ESLint reporting more linting errors by default.
187
-
-A new addition to an existing rule to support a newly-added language feature (within the last 12 months) that will result in ESLint reporting more linting errors by default.
188
-
-An existing rule is deprecated.
189
-
-A new CLI capability is created.
190
-
-New capabilities to the public API are added (new classes, new methods, new arguments to existing methods, etc.).
191
-
-A new formatter is created.
192
-
-`eslint:recommended` is updated and will result in strictly fewer linting errors (e.g., rule removals).
193
-
-Major release (likely to break your lint build)
194
-
-`eslint:recommended` is updated and may result in new linting errors (e.g., rule additions, most rule option updates).
195
-
-A new option to an existing rule that results in ESLint reporting more linting errors by default.
196
-
-An existing formatter is removed.
197
-
-Part of the public API is removed or changed in an incompatible way. The public API includes:
198
-
-Rule schemas
199
-
-Configuration schema
200
-
-Command-line options
201
-
-Node.js API
202
-
-Rule, formatter, parser, plugin APIs
177
+
- Patch release (intended to not break your lint build)
178
+
- A bug fix in a rule that results in ESLint reporting fewer linting errors.
179
+
- A bug fix to the CLI or core (including formatters).
180
+
- Improvements to documentation.
181
+
- Non-user-facing changes such as refactoring code, adding, deleting, or modifying tests, and increasing test coverage.
182
+
- Re-releasing after a failed release (i.e., publishing a release that doesn't work for anyone).
183
+
- Minor release (might break your lint build)
184
+
- A bug fix in a rule that results in ESLint reporting more linting errors.
185
+
- A new rule is created.
186
+
- A new option to an existing rule that does not result in ESLint reporting more linting errors by default.
187
+
- A new addition to an existing rule to support a newly-added language feature (within the last 12 months) that will result in ESLint reporting more linting errors by default.
188
+
- An existing rule is deprecated.
189
+
- A new CLI capability is created.
190
+
- New capabilities to the public API are added (new classes, new methods, new arguments to existing methods, etc.).
191
+
- A new formatter is created.
192
+
-`eslint:recommended` is updated and will result in strictly fewer linting errors (e.g., rule removals).
193
+
- Major release (likely to break your lint build)
194
+
-`eslint:recommended` is updated and may result in new linting errors (e.g., rule additions, most rule option updates).
195
+
- A new option to an existing rule that results in ESLint reporting more linting errors by default.
196
+
- An existing formatter is removed.
197
+
- Part of the public API is removed or changed in an incompatible way. The public API includes:
198
+
- Rule schemas
199
+
- Configuration schema
200
+
- Command-line options
201
+
- Node.js API
202
+
- Rule, formatter, parser, plugin APIs
203
203
204
204
According to our policy, any minor update may report more linting errors than the previous release (ex: from a bug fix). As such, we recommend using the tilde (`~`) in `package.json` e.g. `"eslint": "~3.1.0"` to guarantee the results of your builds.
Copy file name to clipboardExpand all lines: docs/src/contribute/architecture/index.md
+39-39Lines changed: 39 additions & 39 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,14 +13,14 @@ eleventyNavigation:
13
13
14
14
At a high level, there are a few key parts to ESLint:
15
15
16
-
-`bin/eslint.js` - this is the file that actually gets executed with the command line utility. It's a dumb wrapper that does nothing more than bootstrap ESLint, passing the command line arguments to `cli`. This is intentionally small so as not to require heavy testing.
17
-
-`lib/api.js` - this is the entry point of `require("eslint")`. This file exposes an object that contains public classes `Linter`, `ESLint`, `RuleTester`, and `SourceCode`.
18
-
-`lib/cli.js` - this is the heart of the ESLint CLI. It takes an array of arguments and then uses `eslint` to execute the commands. By keeping this as a separate utility, it allows others to effectively call ESLint from within another Node.js program as if it were done on the command line. The main call is `cli.execute()`. This is also the part that does all the file reading, directory traversing, input, and output.
19
-
-`lib/cli-engine/` - this module is `CLIEngine` class that finds source code files and configuration files then does code verifying with the `Linter` class. This includes the loading logic of configuration files, parsers, plugins, and formatters.
20
-
-`lib/linter/` - this module is the core `Linter` class that does code verifying based on configuration options. This file does no file I/O and does not interact with the `console` at all. For other Node.js programs that have JavaScript text to verify, they would be able to use this interface directly.
21
-
-`lib/rule-tester/` - this module is `RuleTester` class that is a wrapper around Mocha so that rules can be unit tested. This class lets us write consistently formatted tests for each rule that is implemented and be confident that each of the rules work. The RuleTester interface was modeled after Mocha and works with Mocha's global testing methods. RuleTester can also be modified to work with other testing frameworks.
22
-
-`lib/source-code/` - this module is `SourceCode` class that is used to represent the parsed source code. It takes in source code and the Program node of the AST representing the code.
23
-
-`lib/rules/` - this contains built-in rules that verify source code.
16
+
-`bin/eslint.js` - this is the file that actually gets executed with the command line utility. It's a dumb wrapper that does nothing more than bootstrap ESLint, passing the command line arguments to `cli`. This is intentionally small so as not to require heavy testing.
17
+
-`lib/api.js` - this is the entry point of `require("eslint")`. This file exposes an object that contains public classes `Linter`, `ESLint`, `RuleTester`, and `SourceCode`.
18
+
-`lib/cli.js` - this is the heart of the ESLint CLI. It takes an array of arguments and then uses `eslint` to execute the commands. By keeping this as a separate utility, it allows others to effectively call ESLint from within another Node.js program as if it were done on the command line. The main call is `cli.execute()`. This is also the part that does all the file reading, directory traversing, input, and output.
19
+
-`lib/cli-engine/` - this module is `CLIEngine` class that finds source code files and configuration files then does code verifying with the `Linter` class. This includes the loading logic of configuration files, parsers, plugins, and formatters.
20
+
-`lib/linter/` - this module is the core `Linter` class that does code verifying based on configuration options. This file does no file I/O and does not interact with the `console` at all. For other Node.js programs that have JavaScript text to verify, they would be able to use this interface directly.
21
+
-`lib/rule-tester/` - this module is `RuleTester` class that is a wrapper around Mocha so that rules can be unit tested. This class lets us write consistently formatted tests for each rule that is implemented and be confident that each of the rules work. The RuleTester interface was modeled after Mocha and works with Mocha's global testing methods. RuleTester can also be modified to work with other testing frameworks.
22
+
-`lib/source-code/` - this module is `SourceCode` class that is used to represent the parsed source code. It takes in source code and the Program node of the AST representing the code.
23
+
-`lib/rules/` - this contains built-in rules that verify source code.
24
24
25
25
## The `cli` object
26
26
@@ -30,17 +30,17 @@ The main method is `cli.execute()`, which accepts an array of strings that repre
30
30
31
31
This object's responsibilities include:
32
32
33
-
-Interpreting command line arguments.
34
-
-Reading from the file system.
35
-
-Outputting to the console.
36
-
-Outputting to the filesystem.
37
-
-Use a formatter.
38
-
-Returning the correct exit code.
33
+
- Interpreting command line arguments.
34
+
- Reading from the file system.
35
+
- Outputting to the console.
36
+
- Outputting to the filesystem.
37
+
- Use a formatter.
38
+
- Returning the correct exit code.
39
39
40
40
This object may not:
41
41
42
-
-Call `process.exit()` directly.
43
-
-Perform any asynchronous operations.
42
+
- Call `process.exit()` directly.
43
+
- Perform any asynchronous operations.
44
44
45
45
## The `CLIEngine` object
46
46
@@ -50,16 +50,16 @@ The main method of the `CLIEngine` is `executeOnFiles()`, which accepts an array
50
50
51
51
This object's responsibilities include:
52
52
53
-
-Managing the execution environment for `Linter`.
54
-
-Reading from the file system.
55
-
-Reading configuration information from config files (including `.eslintrc` and `package.json`).
53
+
- Managing the execution environment for `Linter`.
54
+
- Reading from the file system.
55
+
- Reading configuration information from config files (including `.eslintrc` and `package.json`).
56
56
57
57
This object may not:
58
58
59
-
-Call `process.exit()` directly.
60
-
-Perform any asynchronous operations.
61
-
-Output to the console.
62
-
-Use formatters.
59
+
- Call `process.exit()` directly.
60
+
- Perform any asynchronous operations.
61
+
- Output to the console.
62
+
- Use formatters.
63
63
64
64
## The `Linter` object
65
65
@@ -69,32 +69,32 @@ Once the AST is available, `estraverse` is used to traverse the AST from top to
69
69
70
70
This object's responsibilities include:
71
71
72
-
-Inspecting JavaScript code strings.
73
-
-Creating an AST for the code.
74
-
-Executing rules on the AST.
75
-
-Reporting back the results of the execution.
72
+
- Inspecting JavaScript code strings.
73
+
- Creating an AST for the code.
74
+
- Executing rules on the AST.
75
+
- Reporting back the results of the execution.
76
76
77
77
This object may not:
78
78
79
-
-Call `process.exit()` directly.
80
-
-Perform any asynchronous operations.
81
-
-Use Node.js-specific features.
82
-
-Access the file system.
83
-
-Call `console.log()` or any other similar method.
79
+
- Call `process.exit()` directly.
80
+
- Perform any asynchronous operations.
81
+
- Use Node.js-specific features.
82
+
- Access the file system.
83
+
- Call `console.log()` or any other similar method.
84
84
85
85
## Rules
86
86
87
87
Individual rules are the most specialized part of the ESLint architecture. Rules can do very little, they are simply a set of instructions executed against an AST that is provided. They do get some context information passed in, but the primary responsibility of a rule is to inspect the AST and report warnings.
88
88
89
89
These objects' responsibilities are:
90
90
91
-
-Inspect the AST for specific patterns.
92
-
-Reporting warnings when certain patterns are found.
91
+
- Inspect the AST for specific patterns.
92
+
- Reporting warnings when certain patterns are found.
93
93
94
94
These objects may not:
95
95
96
-
-Call `process.exit()` directly.
97
-
-Perform any asynchronous operations.
98
-
-Use Node.js-specific features.
99
-
-Access the file system.
100
-
-Call `console.log()` or any other similar method.
96
+
- Call `process.exit()` directly.
97
+
- Perform any asynchronous operations.
98
+
- Use Node.js-specific features.
99
+
- Access the file system.
100
+
- Call `console.log()` or any other similar method.
The rule naming conventions for ESLint are as follows:
107
107
108
-
-Use dashes between words.
109
-
-If your rule only disallows something, prefix it with `no-` such as `no-eval` for disallowing `eval()` and `no-debugger` for disallowing `debugger`.
110
-
-If your rule is enforcing the inclusion of something, use a short name without a special prefix.
108
+
- Use dashes between words.
109
+
- If your rule only disallows something, prefix it with `no-` such as `no-eval` for disallowing `eval()` and `no-debugger` for disallowing `debugger`.
110
+
- If your rule is enforcing the inclusion of something, use a short name without a special prefix.
111
111
112
112
## Frozen Rules
113
113
114
114
When rules are feature complete, they are marked as frozen (indicated with ❄️ in the documentation). Rules are considered feature complete when the intended purpose of the rule has been fully implemented such that it catches 80% or more of expected violations and covers the majority of common exceptions. After that point, we expect users to use [disable comments](../use/configure/rules#using-configuration-comments-1) when they find an edge case that isn't covered.
115
115
116
116
When a rule is frozen, it means:
117
117
118
-
-**Bug fixes**: We will still fix confirmed bugs.
119
-
-**New ECMAScript features**: We will ensure compatibility with new ECMAScript features, meaning the rule will not break on new syntax.
120
-
-**New options**: We will **not** add any new options unless an option is the only way to fix a bug or support a newly-added ECMAScript feature.
118
+
-**Bug fixes**: We will still fix confirmed bugs.
119
+
-**New ECMAScript features**: We will ensure compatibility with new ECMAScript features, meaning the rule will not break on new syntax.
120
+
-**New options**: We will **not** add any new options unless an option is the only way to fix a bug or support a newly-added ECMAScript feature.
121
121
122
122
If you find that a frozen rule would work better for you with a change, we recommend copying the rule source code and modifying it to fit your needs.
0 commit comments