From e233920857e282ba22116ad5f1dcc6dfabc8ef5b Mon Sep 17 00:00:00 2001 From: Bryan Mishkin <698306+bmish@users.noreply.github.com> Date: Mon, 29 Nov 2021 20:07:24 -0600 Subject: [PATCH] docs: enable a few more markdownlint rules and fix violations (#15368) --- .markdownlint.yml | 4 --- .markdownlintignore | 2 ++ CONTRIBUTING.md | 2 +- README.md | 16 ++--------- docs/developer-guide/code-path-analysis.md | 2 -- .../contributing/pull-requests.md | 26 ++++++++--------- .../development-environment.md | 6 ++-- docs/developer-guide/nodejs-api.md | 6 ++-- docs/developer-guide/shareable-configs.md | 9 +++--- .../working-with-custom-formatters.md | 3 +- docs/rules/accessor-pairs.md | 1 - docs/rules/array-bracket-newline.md | 1 - docs/rules/array-callback-return.md | 1 - docs/rules/arrow-parens.md | 1 - docs/rules/callback-return.md | 1 - docs/rules/class-methods-use-this.md | 4 +-- docs/rules/comma-spacing.md | 2 -- docs/rules/comma-style.md | 2 -- docs/rules/function-call-argument-newline.md | 3 -- docs/rules/indent.md | 1 - docs/rules/line-comment-position.md | 3 -- docs/rules/linebreak-style.md | 3 +- docs/rules/lines-around-comment.md | 3 -- docs/rules/max-lines-per-function.md | 2 +- docs/rules/no-compare-neg-zero.md | 2 -- docs/rules/no-empty-function.md | 20 ++++++------- docs/rules/no-empty-label.md | 1 - docs/rules/no-implied-eval.md | 1 - docs/rules/no-loop-func.md | 1 - docs/rules/no-mixed-operators.md | 1 - docs/rules/no-mixed-spaces-and-tabs.md | 1 - docs/rules/no-multiple-empty-lines.md | 4 +-- docs/rules/no-param-reassign.md | 1 - docs/rules/no-process-env.md | 1 - docs/rules/no-restricted-imports.md | 2 +- docs/rules/no-restricted-modules.md | 3 +- docs/rules/no-restricted-properties.md | 1 - docs/rules/no-template-curly-in-string.md | 1 - docs/rules/no-undef-init.md | 1 - docs/rules/no-undefined.md | 1 - docs/rules/no-unused-vars.md | 1 - docs/rules/no-void.md | 2 +- docs/rules/no-wrap-func.md | 1 - docs/rules/object-shorthand.md | 1 - docs/rules/prefer-destructuring.md | 1 - docs/rules/prefer-named-capture-group.md | 1 - docs/rules/prefer-promise-reject-errors.md | 1 - docs/rules/prefer-reflect.md | 2 +- docs/rules/radix.md | 1 - docs/rules/require-await.md | 1 - docs/rules/sort-imports.md | 1 - docs/rules/space-after-function-name.md | 1 - docs/rules/space-in-brackets.md | 1 - docs/rules/spaced-comment.md | 5 ++-- docs/rules/spaced-line-comment.md | 1 - docs/rules/switch-colon-spacing.md | 1 - docs/rules/symbol-description.md | 4 --- docs/user-guide/command-line-interface.md | 8 +++--- .../configuring/configuration-files.md | 2 +- docs/user-guide/configuring/ignoring-code.md | 1 - .../configuring/language-options.md | 2 -- docs/user-guide/configuring/plugins.md | 1 - docs/user-guide/configuring/rules.md | 1 - docs/user-guide/getting-started.md | 6 ++-- docs/user-guide/migrating-from-jscs.md | 28 +++++++++---------- docs/user-guide/migrating-to-2.0.0.md | 2 +- docs/user-guide/migrating-to-4.0.0.md | 10 +++---- docs/user-guide/migrating-to-5.0.0.md | 6 ++-- docs/user-guide/migrating-to-6.0.0.md | 6 ++-- docs/user-guide/migrating-to-8.0.0.md | 3 -- package.json | 4 +-- templates/bug-report.md | 3 +- templates/rule-change-proposal.md | 5 ---- templates/rule-proposal.md | 4 +-- 74 files changed, 90 insertions(+), 174 deletions(-) diff --git a/.markdownlint.yml b/.markdownlint.yml index 975106df0fd..c37cf77fbbc 100644 --- a/.markdownlint.yml +++ b/.markdownlint.yml @@ -1,11 +1,9 @@ default: true # Exclusions for deliberate/widespread violations -MD001: false # Header levels should only increment by one level at a time MD002: false # First header should be a h1 header MD007: # Unordered list indentation indent: 4 -MD012: false # Multiple consecutive blank lines MD013: false # Line length MD014: false # Dollar signs used before commands without showing output MD019: false # Multiple spaces after hash on atx style header @@ -15,7 +13,5 @@ MD026: false # Trailing punctuation in header MD029: false # Ordered list item prefix MD030: false # Spaces after list markers MD033: false # Allow inline HTML -MD034: false # Bare URL used -MD040: false # Fenced code blocks should have a language specified MD041: false # First line in file should be a top level header MD046: false # Code block style diff --git a/.markdownlintignore b/.markdownlintignore index 1b763b1bae0..251c083e056 100644 --- a/.markdownlintignore +++ b/.markdownlintignore @@ -1 +1,3 @@ CHANGELOG.md +node_modules +tmp diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9260dfefa5e..8f2246f3b4e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -24,4 +24,4 @@ Please sign our [Contributor License Agreement](https://cla.js.foundation/eslint ## Full Documentation Our full contribution guidelines can be found at: -https://eslint.org/docs/developer-guide/contributing/ + diff --git a/README.md b/README.md index f8f89e317bf..c27c1053f1e 100644 --- a/README.md +++ b/README.md @@ -47,19 +47,19 @@ Prerequisites: [Node.js](https://nodejs.org/) (`^12.22.0`, `^14.17.0`, or `>=16. You can install ESLint using npm: -``` +```sh $ npm install eslint --save-dev ``` You should then set up a configuration file: -``` +```sh $ ./node_modules/.bin/eslint --init ``` After that, you can run ESLint on any file or directory like this: -``` +```sh $ ./node_modules/.bin/eslint yourfile.js ``` @@ -207,8 +207,6 @@ These folks keep the project moving and are resources for help. - - ### Technical Steering Committee (TSC) @@ -232,7 +230,6 @@ Milos Djermanovic - ### Reviewers The people who review and implement new features. @@ -249,9 +246,6 @@ Toru Nagashima - - - ### Committers The people who review and fix bugs and help triage issues. @@ -288,12 +282,8 @@ Nitin Kumar - - - - ## Sponsors The following companies, organizations, and individuals support ESLint's ongoing maintenance and development. [Become a Sponsor](https://opencollective.com/eslint) to get your logo on our README and website. diff --git a/docs/developer-guide/code-path-analysis.md b/docs/developer-guide/code-path-analysis.md index f22eb8f3497..2b01bc77e81 100644 --- a/docs/developer-guide/code-path-analysis.md +++ b/docs/developer-guide/code-path-analysis.md @@ -189,8 +189,6 @@ bar(); ![Loop Event's Example 5](./code-path-analysis/loop-event-example-for-5.svg) - - ## Usage Examples ### To check whether or not this is reachable diff --git a/docs/developer-guide/contributing/pull-requests.md b/docs/developer-guide/contributing/pull-requests.md index dde1c31446f..58fe6f9c02a 100644 --- a/docs/developer-guide/contributing/pull-requests.md +++ b/docs/developer-guide/contributing/pull-requests.md @@ -30,7 +30,7 @@ Details about each step are found below. The first step to sending a pull request is to create a new branch in your ESLint fork. Give the branch a descriptive name that describes what it is you're fixing, such as: -``` +```sh $ git checkout -b issue1234 ``` @@ -42,14 +42,14 @@ You should do all of your development for the issue in this branch. Make the changes to the code and tests, following the [code conventions](../code-conventions.md) as you go. Once you have finished, commit the changes to your branch: -``` +```sh $ git add -A $ git commit ``` All ESLint projects follow [Conventional Commits](https://www.conventionalcommits.org/) for our commit messages. Here's an example commit message: -``` +```pt tag: Short description of what you did Longer description here if necessary @@ -79,7 +79,7 @@ The message summary should be a one-sentence description of the change, and it m Here are some good commit message summary examples: -``` +```pt build: Update Travis to only test Node 0.10 fix: Semi rule incorrectly flagging extra semicolon chore: Upgrade Esprima to 1.2, switch to using comment attachment @@ -91,7 +91,7 @@ The commit message format is important because these messages are used to create Before you send the pull request, be sure to rebase onto the upstream source. This ensures your code is running on the latest available code. -``` +```sh git fetch upstream git rebase upstream/main ``` @@ -100,7 +100,7 @@ git rebase upstream/main After rebasing, be sure to run all of the tests once again to make sure nothing broke: -``` +```sh npm test ``` @@ -123,13 +123,13 @@ With your code ready to go, this is a good time to double-check your submission Next, push your changes to your clone: -``` +```sh git push origin issue1234 ``` If you are unable to push because some references are old, do a forced push instead: -``` +```sh git push -f origin issue1234 ``` @@ -149,13 +149,13 @@ Once your pull request is sent, it's time for the team to review it. As such, pl If your commit message is in the incorrect format, you'll be asked to update it. You can do so via: -``` +```sh $ git commit --amend ``` This will open up your editor so you can make changes. After that, you'll need to do a forced push to your branch: -``` +```sh $ git push origin issue1234 -f ``` @@ -163,7 +163,7 @@ $ git push origin issue1234 -f If we ask you to make code changes, there's no need to close the pull request and create a new one. Just go back to the branch on your fork and make your changes. Then, when you're ready, you can add your changes into the branch: -``` +```sh $ git add -A $ git commit $ git push origin issue1234 @@ -177,13 +177,13 @@ The commit messages in subsequent commits do not need to be in any specific form If your code is out-of-date, we might ask you to rebase. That means we want you to apply your changes on top of the latest upstream code. Make sure you have set up a [development environment](../development-environment.md) and then you can rebase using these commands: -``` +```sh $ git fetch upstream $ git rebase upstream/main ``` You might find that there are merge conflicts when you attempt to rebase. Please [resolve the conflicts](https://help.github.com/articles/resolving-merge-conflicts-after-a-git-rebase/) and then do a forced push to your branch: -``` +```sh $ git push origin issue1234 -f ``` diff --git a/docs/developer-guide/development-environment.md b/docs/developer-guide/development-environment.md index 7981c66e685..4828476aac8 100644 --- a/docs/developer-guide/development-environment.md +++ b/docs/developer-guide/development-environment.md @@ -14,7 +14,7 @@ Go to and click the "Fork" button. Follow the Once you've cloned the repository, run `npm install` to get all the necessary dependencies: -``` +```sh $ cd eslint $ npm install ``` @@ -27,7 +27,7 @@ The *upstream source* is the main ESLint repository where active development hap To add the upstream source for ESLint, run the following in your repository: -``` +```sh git remote add upstream git@github.com:eslint/eslint.git ``` @@ -49,7 +49,7 @@ Please see the [generator documentation](https://github.com/eslint/generator-esl Running the tests is the best way to ensure you have correctly set up your development environment. Make sure you're in the `eslint` directory and run: -``` +```sh npm test ``` diff --git a/docs/developer-guide/nodejs-api.md b/docs/developer-guide/nodejs-api.md index e4a3a1e42c1..ca07415cd2b 100644 --- a/docs/developer-guide/nodejs-api.md +++ b/docs/developer-guide/nodejs-api.md @@ -473,7 +473,7 @@ const linter2 = new Linter(); ``` In this example, rules run on `linter1` will get `path/to/project` when calling `context.getCwd()`. -Those run on `linter2` will get `process.cwd()` if the global `process` object is defined or `undefined` otherwise (e.g. on the browser https://eslint.org/demo). +Those run on `linter2` will get `process.cwd()` if the global `process` object is defined or `undefined` otherwise (e.g. on the browser ). ### Linter#verify @@ -783,7 +783,7 @@ Any additional properties of a test case will be passed directly to the linter a If a valid test case only uses the `code` property, it can optionally be provided as a string containing the code, rather than an object with a `code` key. -#### Testing errors with `messageId` +### Testing errors with `messageId` If the rule under test uses `messageId`s, you can use `messageId` property in a test case to assert reported error's `messageId` instead of its `message`. @@ -805,7 +805,7 @@ For messages with placeholders, a test case can also use `data` property to addi Please note that `data` in a test case does not assert `data` passed to `context.report`. Instead, it is used to form the expected message text which is then compared with the received `message`. -#### Testing Suggestions +### Testing Suggestions Suggestions can be tested by defining a `suggestions` key on an errors object. The options to check for the suggestions are the following (all are optional): diff --git a/docs/developer-guide/shareable-configs.md b/docs/developer-guide/shareable-configs.md index 7b57f3fbf28..15032d9e7a0 100644 --- a/docs/developer-guide/shareable-configs.md +++ b/docs/developer-guide/shareable-configs.md @@ -32,9 +32,11 @@ Once your shareable config is ready, you can [publish to npm](https://docs.npmjs You should declare your dependency on ESLint in `package.json` using the [peerDependencies](https://docs.npmjs.com/files/package.json#peerdependencies) field. The recommended way to declare a dependency for future proof compatibility is with the ">=" range syntax, using the lowest required ESLint version. For example: -``` -"peerDependencies": { - "eslint": ">= 3" +```json +{ + "peerDependencies": { + "eslint": ">= 3" + } } ``` @@ -76,7 +78,6 @@ You can also omit the `eslint-config-` and it will be automatically assumed by E npm [scoped modules](https://docs.npmjs.com/misc/scope) are also supported in a number of ways. - By using the module name: ```json diff --git a/docs/developer-guide/working-with-custom-formatters.md b/docs/developer-guide/working-with-custom-formatters.md index 181aa69cec5..96b0f8fd537 100644 --- a/docs/developer-guide/working-with-custom-formatters.md +++ b/docs/developer-guide/working-with-custom-formatters.md @@ -29,7 +29,7 @@ eslint -f ./my-awesome-formatter.js src/ In order to use a local file as a custom formatter, you must begin the filename with a dot (such as `./my-awesome-formatter.js` or `../formatters/my-awesome-formatter.js`). -### The `data` Argument +## The `data` Argument The exported function receives an optional second argument named `data`. The `data` object provides extended information related to the analysis results. Currently, the `data` object consists of a single property named `rulesMeta`. This property is a dictionary of rule metadata, keyed with `ruleId`. The value for each entry is the `meta` property from the corresponding rule object. The dictionary contains an entry for each rule that was run during the analysis. @@ -358,7 +358,6 @@ error semi src/configs/bundler.js:6:10 ``` - ### Complex Argument Passing If you find the custom formatter pattern doesn't provide enough options for the way you'd like to format ESLint results, the best option is to use ESLint's built-in [JSON formatter](https://eslint.org/docs/user-guide/formatters/) and pipe the output to a second program. For example: diff --git a/docs/rules/accessor-pairs.md b/docs/rules/accessor-pairs.md index 25028d9ef73..22cf28ab982 100644 --- a/docs/rules/accessor-pairs.md +++ b/docs/rules/accessor-pairs.md @@ -232,7 +232,6 @@ const Quux = class { } ``` - ## Known Limitations Due to the limits of static analysis, this rule does not account for possible side effects and in certain cases diff --git a/docs/rules/array-bracket-newline.md b/docs/rules/array-bracket-newline.md index eed32295f43..bb990c75bf8 100644 --- a/docs/rules/array-bracket-newline.md +++ b/docs/rules/array-bracket-newline.md @@ -267,7 +267,6 @@ var e = [ ]; ``` - ## When Not To Use It If you don't want to enforce line breaks after opening and before closing array brackets, don't enable this rule. diff --git a/docs/rules/array-callback-return.md b/docs/rules/array-callback-return.md index 84bf0e7710d..568e014cd74 100644 --- a/docs/rules/array-callback-return.md +++ b/docs/rules/array-callback-return.md @@ -144,7 +144,6 @@ myArray.forEach(item => { }); ``` - ## Known Limitations This rule checks callback functions of methods with the given names, *even if* the object which has the method is *not* an array. diff --git a/docs/rules/arrow-parens.md b/docs/rules/arrow-parens.md index 144ebdf0710..8a133cdf452 100644 --- a/docs/rules/arrow-parens.md +++ b/docs/rules/arrow-parens.md @@ -20,7 +20,6 @@ a => {} Following this style will help you find arrow functions (`=>`) which may be mistakenly included in a condition when a comparison such as `>=` was the intent. - ```js /*eslint-env es6*/ diff --git a/docs/rules/callback-return.md b/docs/rules/callback-return.md index f425ccd3f25..c4e7277c457 100644 --- a/docs/rules/callback-return.md +++ b/docs/rules/callback-return.md @@ -165,7 +165,6 @@ There are some cases where you might want to call a callback function more than may lead to incorrect behavior. In those cases you may want to reserve a special name for those callbacks and not include that in the list of callbacks that trigger warnings. - ## Further Reading * [The Art Of Node: Callbacks](https://github.com/maxogden/art-of-node#callbacks) diff --git a/docs/rules/class-methods-use-this.md b/docs/rules/class-methods-use-this.md index 73efc9dba54..7e25b069a8b 100644 --- a/docs/rules/class-methods-use-this.md +++ b/docs/rules/class-methods-use-this.md @@ -99,7 +99,7 @@ This rule has two options: ### exceptMethods -``` +```js "class-methods-use-this": [, { "exceptMethods": [<...exceptions>] }] ``` @@ -131,7 +131,7 @@ class A { ## enforceForClassFields -``` +```js "class-methods-use-this": [, { "enforceForClassFields": true | false }] ``` diff --git a/docs/rules/comma-spacing.md b/docs/rules/comma-spacing.md index 23107719a32..3160f86a8f5 100644 --- a/docs/rules/comma-spacing.md +++ b/docs/rules/comma-spacing.md @@ -110,13 +110,11 @@ var arr = [,2 ,3] If your project will not be following a consistent comma-spacing pattern, turn this rule off. - ## Further Reading * [JavaScript](http://javascript.crockford.com/code.html) * [Dojo Style Guide](https://dojotoolkit.org/reference-guide/1.9/developer/styleguide.html) - ## Related Rules * [array-bracket-spacing](array-bracket-spacing.md) diff --git a/docs/rules/comma-style.md b/docs/rules/comma-style.md index 24b5515743d..f71e3105aa8 100644 --- a/docs/rules/comma-style.md +++ b/docs/rules/comma-style.md @@ -157,7 +157,6 @@ var o = {fst:1, This rule can safely be turned off if your project does not care about enforcing a consistent comma style. - ## Further Reading For more information on the Comma First style: @@ -165,7 +164,6 @@ For more information on the Comma First style: * [A better coding convention for lists and object literals in JavaScript by isaacs](https://gist.github.com/isaacs/357981) * [npm coding style guideline](https://docs.npmjs.com/misc/coding-style) - ## Related Rules * [operator-linebreak](operator-linebreak.md) diff --git a/docs/rules/function-call-argument-newline.md b/docs/rules/function-call-argument-newline.md index 01c1ff42604..abe0d495651 100644 --- a/docs/rules/function-call-argument-newline.md +++ b/docs/rules/function-call-argument-newline.md @@ -14,7 +14,6 @@ This rule has a string option: * `"never"` disallows line breaks between arguments * `"consistent"` requires consistent usage of line breaks between arguments - ### always Examples of **incorrect** code for this rule with the default `"always"` option: @@ -69,7 +68,6 @@ baz( ); ``` - ### never Examples of **incorrect** code for this rule with the `"never"` option: @@ -189,7 +187,6 @@ baz( ); ``` - ## When Not To Use It If you don't want to enforce line breaks between arguments, don't enable this rule. diff --git a/docs/rules/indent.md b/docs/rules/indent.md index 74fb0e7e2ac..bd4e86ea945 100644 --- a/docs/rules/indent.md +++ b/docs/rules/indent.md @@ -842,7 +842,6 @@ if (foo) { } ``` - ## Compatibility * **JSHint**: `indent` diff --git a/docs/rules/line-comment-position.md b/docs/rules/line-comment-position.md index 734453411c9..2e0eef8530a 100644 --- a/docs/rules/line-comment-position.md +++ b/docs/rules/line-comment-position.md @@ -11,7 +11,6 @@ var foo = "bar"; // beside comment This rule enforces consistent position of line comments. Block comments are not affected by this rule. By default, this rule ignores comments starting with the following words: `eslint`, `jshint`, `jslint`, `istanbul`, `global`, `exported`, `jscs`, `falls through`. - ## Options This rule takes one argument, which can be a string or an object. The string settings are the same as those of the `position` property (explained below). The object option has the following properties: @@ -33,7 +32,6 @@ Examples of **correct** code for the `{ "position": "above" }` option: 1 + 1; ``` - Examples of **incorrect** code for the `{ "position": "above" }` option: ```js @@ -50,7 +48,6 @@ Examples of **correct** code for the `{ "position": "beside" }` option: 1 + 1; // valid comment ``` - Examples of **incorrect** code for the `{ "position": "beside" }` option: ```js diff --git a/docs/rules/linebreak-style.md b/docs/rules/linebreak-style.md index d2aa5a1aa8e..a4eb620acc3 100644 --- a/docs/rules/linebreak-style.md +++ b/docs/rules/linebreak-style.md @@ -19,7 +19,6 @@ This rule has a string option: * `"unix"` (default) enforces the usage of Unix line endings: `\n` for LF. * `"windows"` enforces the usage of Windows line endings: `\r\n` for CRLF. - ### unix Examples of **incorrect** code for this rule with the default `"unix"` option: @@ -73,7 +72,7 @@ Version control systems sometimes have special behavior for linebreaks. To make For example, the default behavior of [git](https://git-scm.com/) on Windows systems is to convert LF linebreaks to CRLF when checking out files, but to store the linebreaks as LF when committing a change. This will cause the `linebreak-style` rule to report errors if configured with the `"unix"` setting, because the files that ESLint sees will have CRLF linebreaks. If you use git, you may want to add a line to your [`.gitattributes` file](https://git-scm.com/docs/gitattributes) to prevent git from converting linebreaks in `.js` files: -``` +```pt *.js text eol=lf ``` diff --git a/docs/rules/lines-around-comment.md b/docs/rules/lines-around-comment.md index fb016110272..b13d525326a 100644 --- a/docs/rules/lines-around-comment.md +++ b/docs/rules/lines-around-comment.md @@ -26,7 +26,6 @@ This rule has an object option: * `"applyDefaultIgnorePatterns"` enables or disables the default comment patterns to be ignored by the rule * `"ignorePattern"` custom patterns to be ignored by the rule - ### beforeBlockComment Examples of **incorrect** code for this rule with the default `{ "beforeBlockComment": true }` option: @@ -515,7 +514,6 @@ const [ ] = ["great", "not great"]; ``` - ### ignorePattern By default this rule ignores comments starting with the following words: `eslint`, `jshint`, `jslint`, `istanbul`, `global`, `exported`, `jscs`. To ignore more comments in addition to the defaults, set the `ignorePattern` option to a string pattern that will be passed to the [`RegExp` constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/RegExp). @@ -568,7 +566,6 @@ foo(); ``` - ## When Not To Use It Many people enjoy a terser code style and don't mind comments bumping up against code. If you fall into that category this rule is not for you. diff --git a/docs/rules/max-lines-per-function.md b/docs/rules/max-lines-per-function.md index d3b13615b42..f2af93b8d48 100644 --- a/docs/rules/max-lines-per-function.md +++ b/docs/rules/max-lines-per-function.md @@ -10,7 +10,7 @@ This rule enforces a maximum number of lines per function, in order to aid in ma Nested long method chains like the below example are often broken onto separate lines for readability: -``` +```js function() { return m("div", [ m("table", {className: "table table-striped latest-data"}, [ diff --git a/docs/rules/no-compare-neg-zero.md b/docs/rules/no-compare-neg-zero.md index e9de786e8cd..cfbe545e285 100644 --- a/docs/rules/no-compare-neg-zero.md +++ b/docs/rules/no-compare-neg-zero.md @@ -31,5 +31,3 @@ if (Object.is(x, -0)) { // doSomething()... } ``` - - diff --git a/docs/rules/no-empty-function.md b/docs/rules/no-empty-function.md index 0f8691c82d3..19110312a64 100644 --- a/docs/rules/no-empty-function.md +++ b/docs/rules/no-empty-function.md @@ -180,7 +180,7 @@ This rule has an option to allow specific kinds of functions to be empty. * `"asyncFunctions"` - Async functions. * `"asyncMethods"` - Async class methods and method shorthands of object literals. -#### allow: functions +### allow: functions Examples of **correct** code for the `{ "allow": ["functions"] }` option: @@ -196,7 +196,7 @@ var obj = { }; ``` -#### allow: arrowFunctions +### allow: arrowFunctions Examples of **correct** code for the `{ "allow": ["arrowFunctions"] }` option: @@ -207,7 +207,7 @@ Examples of **correct** code for the `{ "allow": ["arrowFunctions"] }` option: var foo = () => {}; ``` -#### allow: generatorFunctions +### allow: generatorFunctions Examples of **correct** code for the `{ "allow": ["generatorFunctions"] }` option: @@ -224,7 +224,7 @@ var obj = { }; ``` -#### allow: methods +### allow: methods Examples of **correct** code for the `{ "allow": ["methods"] }` option: @@ -242,7 +242,7 @@ class A { } ``` -#### allow: generatorMethods +### allow: generatorMethods Examples of **correct** code for the `{ "allow": ["generatorMethods"] }` option: @@ -260,7 +260,7 @@ class A { } ``` -#### allow: getters +### allow: getters Examples of **correct** code for the `{ "allow": ["getters"] }` option: @@ -278,7 +278,7 @@ class A { } ``` -#### allow: setters +### allow: setters Examples of **correct** code for the `{ "allow": ["setters"] }` option: @@ -296,7 +296,7 @@ class A { } ``` -#### allow: constructors +### allow: constructors Examples of **correct** code for the `{ "allow": ["constructors"] }` option: @@ -309,7 +309,7 @@ class A { } ``` -#### allow: asyncFunctions +### allow: asyncFunctions Examples of **correct** code for the `{ "allow": ["asyncFunctions"] }` options: @@ -320,7 +320,7 @@ Examples of **correct** code for the `{ "allow": ["asyncFunctions"] }` options: async function a(){} ``` -#### allow: asyncMethods +### allow: asyncMethods Examples of **correct** code for the `{ "allow": ["asyncMethods"] }` options: diff --git a/docs/rules/no-empty-label.md b/docs/rules/no-empty-label.md index 3f8850199b7..b887c87a590 100644 --- a/docs/rules/no-empty-label.md +++ b/docs/rules/no-empty-label.md @@ -4,7 +4,6 @@ Labeled statements are only used in conjunction with labeled break and continue statements. ECMAScript has no goto statement. - ## Rule Details This error occurs when a label is used to mark a statement that is not an iteration or switch diff --git a/docs/rules/no-implied-eval.md b/docs/rules/no-implied-eval.md index d300ff61d3f..cbf7c67c2b8 100644 --- a/docs/rules/no-implied-eval.md +++ b/docs/rules/no-implied-eval.md @@ -19,7 +19,6 @@ setTimeout(function() { The best practice is to always use a function for the first argument of `setTimeout()` and `setInterval()` (and avoid `execScript()`). - ## Rule Details This rule aims to eliminate implied `eval()` through the use of `setTimeout()`, `setInterval()` or `execScript()`. As such, it will warn when either function is used with a string as the first argument. diff --git a/docs/rules/no-loop-func.md b/docs/rules/no-loop-func.md index 65c75327815..f39b868e5e3 100644 --- a/docs/rules/no-loop-func.md +++ b/docs/rules/no-loop-func.md @@ -26,7 +26,6 @@ for (let i = 0; i < 10; i++) { In this case, each function created within the loop returns a different number as expected. - ## Rule Details This error is raised to highlight a piece of code that may not work as you expect it to and could also indicate a misunderstanding of how the language works. Your code may run without any problems if you do not fix this error, but in some situations it could behave unexpectedly. diff --git a/docs/rules/no-mixed-operators.md b/docs/rules/no-mixed-operators.md index 33ce7f65831..1dca581e81c 100644 --- a/docs/rules/no-mixed-operators.md +++ b/docs/rules/no-mixed-operators.md @@ -36,7 +36,6 @@ will generate 1:18 Unexpected mix of '&&' and '?:'. (no-mixed-operators) ``` - ## Rule Details This rule checks `BinaryExpression`, `LogicalExpression` and `ConditionalExpression`. diff --git a/docs/rules/no-mixed-spaces-and-tabs.md b/docs/rules/no-mixed-spaces-and-tabs.md index ba34dbe4929..9f156bb2b3f 100644 --- a/docs/rules/no-mixed-spaces-and-tabs.md +++ b/docs/rules/no-mixed-spaces-and-tabs.md @@ -59,7 +59,6 @@ function main() { } ``` - ## Further Reading * [Smart Tabs](https://www.emacswiki.org/emacs/SmartTabs) diff --git a/docs/rules/no-multiple-empty-lines.md b/docs/rules/no-multiple-empty-lines.md index aff6c2e6f1b..1a04841825c 100644 --- a/docs/rules/no-multiple-empty-lines.md +++ b/docs/rules/no-multiple-empty-lines.md @@ -69,7 +69,7 @@ var bar = 3; **Incorrect**: -``` +```js 1 /*eslint no-multiple-empty-lines: ["error", { "max": 2, "maxEOF": 0 }]*/⏎ 2 ⏎ 3 var foo = 5;⏎ @@ -82,7 +82,7 @@ var bar = 3; **Correct**: -``` +```js 1 /*eslint no-multiple-empty-lines: ["error", { "max": 2, "maxEOF": 0 }]*/⏎ 2 ⏎ 3 var foo = 5;⏎ diff --git a/docs/rules/no-param-reassign.md b/docs/rules/no-param-reassign.md index 47a7af3cbe9..29952c370ea 100644 --- a/docs/rules/no-param-reassign.md +++ b/docs/rules/no-param-reassign.md @@ -150,7 +150,6 @@ function foo(barBaz) { } ``` - ## When Not To Use It If you want to allow assignment to function parameters, then you can safely disable this rule. diff --git a/docs/rules/no-process-env.md b/docs/rules/no-process-env.md index 83bfa6d02ac..4655e965ef7 100644 --- a/docs/rules/no-process-env.md +++ b/docs/rules/no-process-env.md @@ -4,7 +4,6 @@ This rule was **deprecated** in ESLint v7.0.0. Please use the corresponding rule The `process.env` object in Node.js is used to store deployment/configuration parameters. Littering it through out a project could lead to maintenance issues as it's another kind of global dependency. As such, it could lead to merge conflicts in a multi-user setup and deployment issues in a multi-server setup. Instead, one of the best practices is to define all those parameters in a single configuration/settings file which could be accessed throughout the project. - ## Rule Details This rule is aimed at discouraging use of `process.env` to avoid global dependencies. As such, it will warn whenever `process.env` is used. diff --git a/docs/rules/no-restricted-imports.md b/docs/rules/no-restricted-imports.md index f1577d7d89d..d8e06101b41 100644 --- a/docs/rules/no-restricted-imports.md +++ b/docs/rules/no-restricted-imports.md @@ -91,7 +91,7 @@ or like this if you want to apply a custom message to pattern matches: The custom message will be appended to the default error message. -To restrict the use of all Node.js core imports (via https://github.com/nodejs/node/tree/master/lib): +To restrict the use of all Node.js core imports (via ): ```json "no-restricted-imports": ["error", diff --git a/docs/rules/no-restricted-modules.md b/docs/rules/no-restricted-modules.md index 3fc412fe5d6..3bce058049e 100644 --- a/docs/rules/no-restricted-modules.md +++ b/docs/rules/no-restricted-modules.md @@ -57,8 +57,7 @@ or like this: The custom message will be appended to the default error message. Please note that you may not specify custom error messages for restricted patterns as a particular module may match more than one pattern. - -To restrict the use of all Node.js core modules (via https://github.com/nodejs/node/tree/master/lib): +To restrict the use of all Node.js core modules (via ): ```json { diff --git a/docs/rules/no-restricted-properties.md b/docs/rules/no-restricted-properties.md index e1824d57925..468d0b36a1b 100644 --- a/docs/rules/no-restricted-properties.md +++ b/docs/rules/no-restricted-properties.md @@ -2,7 +2,6 @@ Certain properties on objects may be disallowed in a codebase. This is useful for deprecating an API or restricting usage of a module's methods. For example, you may want to disallow using `describe.only` when using Mocha or telling people to use `Object.assign` instead of `_.extend`. - ## Rule Details This rule looks for accessing a given property key on a given object name, either when reading the property's value or invoking it as a function. You may specify an optional message to indicate an alternative API or a reason for the restriction. diff --git a/docs/rules/no-template-curly-in-string.md b/docs/rules/no-template-curly-in-string.md index 9c03b67a612..68a237de988 100644 --- a/docs/rules/no-template-curly-in-string.md +++ b/docs/rules/no-template-curly-in-string.md @@ -2,7 +2,6 @@ ECMAScript 6 allows programmers to create strings containing variable or expressions using template literals, instead of string concatenation, by writing expressions like `${variable}` between two backtick quotes (\`). It can be easy to use the wrong quotes when wanting to use template literals, by writing `"${variable}"`, and end up with the literal value `"${variable}"` instead of a string containing the value of the injected expressions. - ## Rule Details This rule aims to warn when a regular string contains what looks like a template literal placeholder. It will warn when it finds a string containing the template literal placeholder (`${something}`) that uses either `"` or `'` for the quotes. diff --git a/docs/rules/no-undef-init.md b/docs/rules/no-undef-init.md index 0cf99c19296..10bde7769bc 100644 --- a/docs/rules/no-undef-init.md +++ b/docs/rules/no-undef-init.md @@ -16,7 +16,6 @@ var foo = undefined; It's considered a best practice to avoid initializing variables to `undefined`. - ## Rule Details This rule aims to eliminate `var` and `let` variable declarations that initialize to `undefined`. diff --git a/docs/rules/no-undefined.md b/docs/rules/no-undefined.md index 0e183f266d5..0e67c21fd86 100644 --- a/docs/rules/no-undefined.md +++ b/docs/rules/no-undefined.md @@ -22,7 +22,6 @@ Because `undefined` can be overwritten or shadowed, reading `undefined` can give As an alternative, you can use the [no-global-assign](no-global-assign.md) and [no-shadow-restricted-names](no-shadow-restricted-names.md) rules to prevent `undefined` from being shadowed or assigned a different value. This ensures that `undefined` will always hold its original, expected value. - ## Rule Details This rule aims to eliminate the use of `undefined`, and as such, generates a warning whenever it is used. diff --git a/docs/rules/no-unused-vars.md b/docs/rules/no-unused-vars.md index 30647031eb1..24eb337c637 100644 --- a/docs/rules/no-unused-vars.md +++ b/docs/rules/no-unused-vars.md @@ -293,7 +293,6 @@ try { } ``` - ## When Not To Use It If you don't want to be notified about unused variables or function arguments, you can safely turn this rule off. diff --git a/docs/rules/no-void.md b/docs/rules/no-void.md index 6b7774805db..3f7837622b8 100644 --- a/docs/rules/no-void.md +++ b/docs/rules/no-void.md @@ -38,7 +38,7 @@ void function(){ foo = 1; }() // will assign foo a value of 1 +function(){ foo = 1; }() // same as above ``` -``` +```js function(){ foo = 1; }() // will throw SyntaxError ``` diff --git a/docs/rules/no-wrap-func.md b/docs/rules/no-wrap-func.md index 6732c92423f..5193d79ec2c 100644 --- a/docs/rules/no-wrap-func.md +++ b/docs/rules/no-wrap-func.md @@ -2,7 +2,6 @@ (removed) This rule was **removed** in ESLint v1.0 and **replaced** by the [no-extra-parens](no-extra-parens.md) rule. The `"functions"` option in the new rule is equivalent to the removed rule. - Although it's possible to wrap functions in parentheses, this can be confusing when the code also contains immediately-invoked function expressions (IIFEs) since parentheses are often used to make this distinction. For example: ```js diff --git a/docs/rules/object-shorthand.md b/docs/rules/object-shorthand.md index 79e76655c5d..fee0e62f4ff 100644 --- a/docs/rules/object-shorthand.md +++ b/docs/rules/object-shorthand.md @@ -43,7 +43,6 @@ properties defined where the key name matches name of the assigned variable. Each of the following properties would warn: - ```js /*eslint object-shorthand: "error"*/ /*eslint-env es6*/ diff --git a/docs/rules/prefer-destructuring.md b/docs/rules/prefer-destructuring.md index 64e914fcee4..b0f887c13a9 100644 --- a/docs/rules/prefer-destructuring.md +++ b/docs/rules/prefer-destructuring.md @@ -179,7 +179,6 @@ var foo = $('body')[0]; var [bar] = $('body'); // fails with a TypeError ``` - ## Further Reading If you want to learn more about destructuring, check out the links below: diff --git a/docs/rules/prefer-named-capture-group.md b/docs/rules/prefer-named-capture-group.md index 2caf9518eab..f48ec8003fc 100644 --- a/docs/rules/prefer-named-capture-group.md +++ b/docs/rules/prefer-named-capture-group.md @@ -1,6 +1,5 @@ # Suggest using named capture group in regular expression (prefer-named-capture-group) - ## Rule Details With the landing of ECMAScript 2018, named capture groups can be used in regular expressions, which can improve their readability. diff --git a/docs/rules/prefer-promise-reject-errors.md b/docs/rules/prefer-promise-reject-errors.md index ac0a227d1e6..9740bc97546 100644 --- a/docs/rules/prefer-promise-reject-errors.md +++ b/docs/rules/prefer-promise-reject-errors.md @@ -2,7 +2,6 @@ It is considered good practice to only pass instances of the built-in `Error` object to the `reject()` function for user-defined errors in Promises. `Error` objects automatically store a stack trace, which can be used to debug an error by determining where it came from. If a Promise is rejected with a non-`Error` value, it can be difficult to determine where the rejection occurred. - ## Rule Details This rule aims to ensure that Promises are only rejected with `Error` objects. diff --git a/docs/rules/prefer-reflect.md b/docs/rules/prefer-reflect.md index 55bc1bbbe77..af0838efba9 100644 --- a/docs/rules/prefer-reflect.md +++ b/docs/rules/prefer-reflect.md @@ -19,7 +19,7 @@ The prefer-reflect rule will flag usage of any older method, suggesting to inste ### Exceptions -``` +```js "prefer-reflect": [, { "exceptions": [<...exceptions>] }] ``` diff --git a/docs/rules/radix.md b/docs/rules/radix.md index da3196c85f0..4453a648f38 100644 --- a/docs/rules/radix.md +++ b/docs/rules/radix.md @@ -29,7 +29,6 @@ There are two options for this rule: * `"always"` enforces providing a radix (default) * `"as-needed"` disallows providing the `10` radix - ### always Examples of **incorrect** code for the default `"always"` option: diff --git a/docs/rules/require-await.md b/docs/rules/require-await.md index 595d0acbf00..9c84d439360 100644 --- a/docs/rules/require-await.md +++ b/docs/rules/require-await.md @@ -81,7 +81,6 @@ In this case, the `fail()` function throws an error that is intended to be caugh If you are throwing an error inside of an asynchronous function for this purpose, then you may want to disable this rule. - ## Related Rules * [require-yield](require-yield.md) diff --git a/docs/rules/sort-imports.md b/docs/rules/sort-imports.md index 637c9fcf3f3..08c2cf36684 100644 --- a/docs/rules/sort-imports.md +++ b/docs/rules/sort-imports.md @@ -22,7 +22,6 @@ import "my-module.js" When declaring multiple imports, a sorted list of import declarations make it easier for developers to read the code and find necessary imports later. This rule is purely a matter of style. - ## Rule Details This rule checks all import declarations and verifies that all imports are first sorted by the used member syntax and then alphabetically by the first member or alias name. diff --git a/docs/rules/space-after-function-name.md b/docs/rules/space-after-function-name.md index 4607ff4a168..6cceaab12f4 100644 --- a/docs/rules/space-after-function-name.md +++ b/docs/rules/space-after-function-name.md @@ -20,7 +20,6 @@ Some style guides may require a consistent spacing for function names. This rule aims to enforce a consistent spacing after function names. It takes one argument. If it is `"always"` then all function names must be followed by at least one space. If `"never"` then there should be no spaces between the name and the parameter list. The default is `"never"`. - Examples of **incorrect** code for this rule: ```js diff --git a/docs/rules/space-in-brackets.md b/docs/rules/space-in-brackets.md index 9bb247727c4..330609acd25 100644 --- a/docs/rules/space-in-brackets.md +++ b/docs/rules/space-in-brackets.md @@ -232,7 +232,6 @@ var arr = [ { Examples of **correct** code when `"objectsInArrays"` is set to `false`: - ```js var arr = [{ 'foo': 'bar' }]; var arr = [{ diff --git a/docs/rules/spaced-comment.md b/docs/rules/spaced-comment.md index 5a885f9821b..66f8f708667 100644 --- a/docs/rules/spaced-comment.md +++ b/docs/rules/spaced-comment.md @@ -24,7 +24,7 @@ The rule takes two options. * The `"exceptions"` value is an array of string patterns which are considered exceptions to the rule. The rule will not warn when the pattern starts from the beginning of the comment and repeats until the end of the line or `*/` if the comment is a single line comment. Please note that exceptions are ignored if the first argument is `"never"`. - ``` + ```js "spaced-comment": ["error", "always", { "exceptions": ["-", "+"] }] ``` @@ -32,7 +32,7 @@ The rule takes two options. such as an additional `/`, used to denote documentation read by doxygen, vsdoc, etc. which must have additional characters. The `"markers"` array will apply regardless of the value of the first argument, e.g. `"always"` or `"never"`. - ``` + ```js "spaced-comment": ["error", "always", { "markers": ["/"] }] ``` @@ -281,7 +281,6 @@ subsequent lines are ignored /*global ABC*/ ``` - ## Related Rules * [spaced-line-comment](spaced-line-comment.md) diff --git a/docs/rules/spaced-line-comment.md b/docs/rules/spaced-line-comment.md index b50404b74f3..aaaa27a181f 100644 --- a/docs/rules/spaced-line-comment.md +++ b/docs/rules/spaced-line-comment.md @@ -6,7 +6,6 @@ Some style guides require or disallow a whitespace immediately after the initial Whitespace after the `//` makes it easier to read text in comments. On the other hand, commenting out code is easier without having to put a whitespace right after the `//`. - ## Rule Details This rule will enforce consistency of spacing after the start of a line comment `//`. diff --git a/docs/rules/switch-colon-spacing.md b/docs/rules/switch-colon-spacing.md index bd469ea7791..b9872c2ad5b 100644 --- a/docs/rules/switch-colon-spacing.md +++ b/docs/rules/switch-colon-spacing.md @@ -20,7 +20,6 @@ This rule has 2 options that are boolean value. - `"before": true` requires one or more spaces before colons. - `"before": false` (Default) disallows before colons. - Examples of **incorrect** code for this rule: ```js diff --git a/docs/rules/symbol-description.md b/docs/rules/symbol-description.md index 61be8767ed5..7743867d290 100644 --- a/docs/rules/symbol-description.md +++ b/docs/rules/symbol-description.md @@ -9,7 +9,6 @@ var someString = "some description"; var bar = Symbol(someString); ``` - Using `description` promotes easier debugging: when a symbol is logged the description is used: ```js @@ -21,12 +20,10 @@ var foo = Symbol("some description"); It may facilitate identifying symbols when one is observed during debugging. - ## Rule Details This rules requires a description when creating symbols. - ## Examples Examples of **incorrect** code for this rule: @@ -50,7 +47,6 @@ var someString = "some description"; var bar = Symbol(someString); ``` - ## When Not To Use It This rule should not be used in ES3/5 environments. diff --git a/docs/user-guide/command-line-interface.md b/docs/user-guide/command-line-interface.md index ad84c37b6be..27d4edc3247 100644 --- a/docs/user-guide/command-line-interface.md +++ b/docs/user-guide/command-line-interface.md @@ -1,6 +1,6 @@ # Command Line Interface -To run ESLint on Node.js, you must have npm installed. If npm is not installed, follow the instructions here: https://www.npmjs.com/ +To run ESLint on Node.js, you must have npm installed. If npm is not installed, follow the instructions here: Once npm is installed, run the following @@ -232,7 +232,7 @@ This option has the same effect as `--fix` with one difference: the fixes are no Because the default formatter does not output the fixed code, you'll have to use another one (e.g. `json`) to get the fixes. Here's an example of this pattern: -``` +```sh getSomeText | eslint --stdin --fix-dry-run --format=json ``` @@ -249,7 +249,7 @@ This option allows you to specify the type of fixes to apply when using either ` You can specify one or more fix type on the command line. Here are some examples: -``` +```sh eslint --fix --fix-type suggestion . eslint --fix --fix-type suggestion --fix-type problem . eslint --fix --fix-type suggestion,layout . @@ -473,7 +473,7 @@ This option causes ESLint to exit with exit code 2 if one or more fatal parsing #### `--debug` -This option outputs debugging information to the console. This information is useful when you're seeing a problem and having a hard time pinpointing it. The ESLint team may ask for this debugging information to help solve bugs. +This option outputs debugging information to the console. This information is useful when you're seeing a problem and having a hard time pinpointing it. The ESLint team may ask for this debugging information to help solve bugs. Add this flag to an ESLint command line invocation in order to get extra debug information as the command is run (e.g. `eslint --debug test.js` and `eslint test.js --debug` are equivalent) #### `-h`, `--help` diff --git a/docs/user-guide/configuring/configuration-files.md b/docs/user-guide/configuring/configuration-files.md index 091d043b9e4..b1fded2a36c 100644 --- a/docs/user-guide/configuring/configuration-files.md +++ b/docs/user-guide/configuring/configuration-files.md @@ -392,7 +392,7 @@ Here is how overrides work in a configuration file: ### Relative glob patterns -``` +```pt project-root ├── app │ ├── lib diff --git a/docs/user-guide/configuring/ignoring-code.md b/docs/user-guide/configuring/ignoring-code.md index d7b3cfd27c8..35c2d25dd3f 100644 --- a/docs/user-guide/configuring/ignoring-code.md +++ b/docs/user-guide/configuring/ignoring-code.md @@ -1,6 +1,5 @@ # Ignoring Code - * [`ignorePatterns` in Config Files](#ignorepatterns-in-config-files) * [The `.eslintignore` File](#the-eslintignore-file) * [Using an Alternate File](#using-an-alternate-file) diff --git a/docs/user-guide/configuring/language-options.md b/docs/user-guide/configuring/language-options.md index 1ee3f2d19be..37fbbe6e3d1 100644 --- a/docs/user-guide/configuring/language-options.md +++ b/docs/user-guide/configuring/language-options.md @@ -1,6 +1,5 @@ # Language Options - * [Specifying Environments](#specifying-environments) * [Specifying Globals](#specifying-globals) * [Specifying Parser Options](#specifying-parser-options) @@ -174,7 +173,6 @@ Globals can be disabled with the string `"off"`. For example, in an environment For historical reasons, the boolean value `false` and the string value `"readable"` are equivalent to `"readonly"`. Similarly, the boolean value `true` and the string value `"writeable"` are equivalent to `"writable"`. However, the use of older values is deprecated. - ## Specifying Parser Options ESLint allows you to specify the JavaScript language options you want to support. By default, ESLint expects ECMAScript 5 syntax. You can override that setting to enable support for other ECMAScript versions as well as JSX by using parser options. diff --git a/docs/user-guide/configuring/plugins.md b/docs/user-guide/configuring/plugins.md index 0235586c980..9d2c9294c4c 100644 --- a/docs/user-guide/configuring/plugins.md +++ b/docs/user-guide/configuring/plugins.md @@ -1,6 +1,5 @@ # Plugins - * [Specifying Parser](#specifying-parser) * [Specifying Processor](#specifying-processor) * [Configuring Plugins](#configuring-plugins) diff --git a/docs/user-guide/configuring/rules.md b/docs/user-guide/configuring/rules.md index 0191f634886..4f45b4a876a 100644 --- a/docs/user-guide/configuring/rules.md +++ b/docs/user-guide/configuring/rules.md @@ -1,6 +1,5 @@ # Rules - * [Configuring Rules](#configuring-rules) * [Disabling Rules](#disabling-rules) diff --git a/docs/user-guide/getting-started.md b/docs/user-guide/getting-started.md index 3c9633bb315..cf808ddc022 100644 --- a/docs/user-guide/getting-started.md +++ b/docs/user-guide/getting-started.md @@ -12,7 +12,7 @@ Prerequisites: [Node.js](https://nodejs.org/en/) (`^12.22.0`, `^14.17.0`, or `>= You can install ESLint using npm or yarn: -``` +```sh npm install eslint --save-dev # or @@ -22,7 +22,7 @@ yarn add eslint --dev You should then set up a configuration file, and the easiest way to do that is to use the `--init` flag: -``` +```sh $ npx eslint --init # or @@ -34,7 +34,7 @@ $ yarn run eslint --init After that, you can run ESLint on any file or directory like this: -``` +```sh $ npx eslint yourfile.js # or diff --git a/docs/user-guide/migrating-from-jscs.md b/docs/user-guide/migrating-from-jscs.md index c5ac5f23523..e05ee70d625 100644 --- a/docs/user-guide/migrating-from-jscs.md +++ b/docs/user-guide/migrating-from-jscs.md @@ -15,7 +15,7 @@ Before beginning the process of migrating to ESLint, it's helpful to understand To install Polyjuice: -``` +```sh $ npm install -g polyjuice ``` @@ -23,7 +23,7 @@ Polyjuice works with JSON configuration files, so if you're using a JavaScript o To convert your configuration file, pass in the location of your `.jscs.json` file using the `--jscs` flag: -``` +```sh $ polyjuice --jscs .jscsrc.json > .eslintrc.json ``` @@ -31,7 +31,7 @@ This creates a `.eslintrc.json` with the equivalent rules from `.jscsrc.json`. If you have multiple `.jscsrc.json` files, you can pass them all and Polyjuice will combine them into one `.eslintrc.json` file: -``` +```sh $ polyjuice --jscs .jscsrc.json ./foo/.jscsrc.json > .eslintrc.json ``` @@ -41,7 +41,7 @@ $ polyjuice --jscs .jscsrc.json ./foo/.jscsrc.json > .eslintrc.json If you don't want to convert your JSCS configuration directly into an ESLint configuration, then you can use ESLint's built-in wizard to get you started. Just run: -``` +```sh $ eslint --init ``` @@ -74,7 +74,7 @@ As an example, suppose that you are using the `airbnb` preset, so your `.jscsrc` In order to get the same functionality in ESLint, you would first need to install the `eslint-config-airbnb` shareable config package: -``` +```sh $ npm install eslint-config-airbnb-base --save-dev ``` @@ -110,13 +110,13 @@ Both JSCS and ESLint have command line arguments corresponding to many of their JSCS uses the `--fix` option to apply automatic fixes to code: -``` +```sh $ jscs --fix file.js ``` ESLint has the same option: -``` +```sh $ eslint --fix file.js ``` @@ -124,13 +124,13 @@ $ eslint --fix file.js The JSCS `--auto-configure` option created a configuration based on what it found in a given file: -``` +```sh $ jscs --auto-configure file.js ``` In ESLint, there's a similar option when you use `--init`. Just select "Inspect your JavaScript file(s)": -``` +```sh $ eslint --init ? How would you like to configure ESLint? (Use arrow keys) > Answer questions about your style @@ -142,30 +142,28 @@ $ eslint --init JSCS allows you to specify a configuration file to use on the command line using either `--config` or `-c`, such as: -``` +```sh $ jscs --config myconfig.json file.js $ jscs -c myconfig.json file.js ``` Both flags are also supported by ESLint: -``` +```sh $ eslint --config myconfig.json file.js $ eslint -c myconfig.json file.js ``` - - ## Piping Code Into ESLint In JSCS, you can pipe code in like this: -``` +```sh $ cat file.js | jscs ``` In ESLint, you can also pipe in code, but you need to use the `--stdin` flag: -``` +```sh $ cat file.js | eslint --stdin ``` diff --git a/docs/user-guide/migrating-to-2.0.0.md b/docs/user-guide/migrating-to-2.0.0.md index 95a3a1774e9..c5f50b3a1d0 100644 --- a/docs/user-guide/migrating-to-2.0.0.md +++ b/docs/user-guide/migrating-to-2.0.0.md @@ -285,7 +285,7 @@ if (variable) { } ``` -Further Reading: https://estools.github.io/escope/ +Further Reading: ## Default Changes When Using `eslint:recommended` diff --git a/docs/user-guide/migrating-to-4.0.0.md b/docs/user-guide/migrating-to-4.0.0.md index b62ef053c09..8f78291d5cd 100644 --- a/docs/user-guide/migrating-to-4.0.0.md +++ b/docs/user-guide/migrating-to-4.0.0.md @@ -4,7 +4,7 @@ ESLint v4.0.0 is the fourth major version release. We have made several breaking The lists below are ordered roughly by the number of users each change is expected to affect, where the first items are expected to affect the most users. -### Breaking changes for users +## Breaking changes for users 1. [New rules have been added to `eslint:recommended`](#eslint-recommended-changes) 1. [The `indent` rule is more strict](#indent-rewrite) @@ -15,14 +15,14 @@ The lists below are ordered roughly by the number of users each change is expect 1. [The `no-multi-spaces` rule is more strict by default](#no-multi-spaces-eol-comments) 1. [References to scoped plugins in config files are now required to include the scope](#scoped-plugin-resolution) -### Breaking changes for plugin/custom rule developers +## Breaking changes for plugin/custom rule developers 1. [`RuleTester` now validates properties of test cases](#rule-tester-validation) 1. [AST nodes no longer have comment properties](#comment-attachment) 1. [`LineComment` and `BlockComment` events will no longer be emitted during AST traversal](#event-comments) 1. [Shebangs are now returned from comment APIs](#shebangs) -### Breaking changes for integration developers +## Breaking changes for integration developers 1. [The `global` property in the `linter.verify()` API is no longer supported](#global-property) 1. [More report messages now have full location ranges](#report-locations) @@ -186,7 +186,7 @@ Starting in 4.0, `LineComment` and `BlockComments` events will not be emitted du **To address:** Instead of relying on `LineComment` and `BlockComment`, rules can now use `sourceCode.getAllComments()` to get all comments in a file. To check all comments of a specific type, rules can use the following pattern: -``` +```js sourceCode.getAllComments().filter(comment => comment.type === "Line"); sourceCode.getAllComments().filter(comment => comment.type === "Block"); ``` @@ -199,7 +199,7 @@ In 4.0, shebang comments are treated as comment tokens of type `Shebang` and wil **To address:** If you have a custom rule that performs operations on comments, some additional logic might be required to ensure that shebang comments are correctly handled or filtered out: -``` +```js sourceCode.getAllComments().filter(comment => comment.type !== "Shebang"); ``` diff --git a/docs/user-guide/migrating-to-5.0.0.md b/docs/user-guide/migrating-to-5.0.0.md index da5c435aa8a..372963163cd 100644 --- a/docs/user-guide/migrating-to-5.0.0.md +++ b/docs/user-guide/migrating-to-5.0.0.md @@ -4,7 +4,7 @@ ESLint v5.0.0 is the fifth major version release. We have made a few breaking ch The lists below are ordered roughly by the number of users each change is expected to affect, where the first items are expected to affect the most users. -### Breaking changes for users +## Breaking changes for users 1. [Node.js 4 is no longer supported](#drop-node-4) 1. [New rules have been added to `eslint:recommended`](#eslint-recommended-changes) @@ -16,7 +16,7 @@ The lists below are ordered roughly by the number of users each change is expect 1. [Plugins in scoped packages are now resolvable in configs](#scoped-plugins) 1. [Multi-line `eslint-disable-line` directives are now reported as problems](#multiline-directives) -### Breaking changes for plugin/custom rule developers +## Breaking changes for plugin/custom rule developers 1. [The `parent` property of AST nodes is now set before rules start running](#parent-before-rules) 1. [When using the default parser, spread operators now have type `SpreadElement`](#spread-operators) @@ -27,7 +27,7 @@ The lists below are ordered roughly by the number of users each change is expect 1. [`RuleTester` now uses strict equality checks in its assertions](#rule-tester-equality) 1. [Rules are now required to provide messages along with reports](#required-report-messages) -### Breaking changes for integration developers +## Breaking changes for integration developers 1. [The `source` property is no longer available on individual linting messages](#source-property) 1. [Fatal errors now result in an exit code of 2](#exit-code-two) diff --git a/docs/user-guide/migrating-to-6.0.0.md b/docs/user-guide/migrating-to-6.0.0.md index 3baec19d95c..225cc4c0e3b 100644 --- a/docs/user-guide/migrating-to-6.0.0.md +++ b/docs/user-guide/migrating-to-6.0.0.md @@ -4,7 +4,7 @@ ESLint v6.0.0 is a major release of ESLint. We have made a few breaking changes The lists below are ordered roughly by the number of users each change is expected to affect, where the first items are expected to affect the most users. -### Breaking changes for users +## Breaking changes for users 1. [Node.js 6 is no longer supported](#drop-node-6) 1. [`eslint:recommended` has been updated](#eslint-recommended-changes) @@ -20,14 +20,14 @@ The lists below are ordered roughly by the number of users each change is expect 1. [The deprecated `experimentalObjectRestSpread` option has been removed](#experimental-object-rest-spread) 1. [User-provided regular expressions in rule options are parsed with the unicode flag](#unicode-regexes) -### Breaking changes for plugin/custom rule developers +## Breaking changes for plugin/custom rule developers 1. [Plugin authors may need to update installation instructions](#plugin-documentation) 1. [`RuleTester` now validates against invalid `default` keywords in rule schemas](#rule-tester-defaults) 1. [`RuleTester` now requires an absolute path on `parser` option](#rule-tester-parser) 1. [The `eslintExplicitGlobalComment` scope analysis property has been removed](#eslintExplicitGlobalComment) -### Breaking changes for integration developers +## Breaking changes for integration developers 1. [Plugins and shareable configs are no longer affected by ESLint's location](#package-loading-simplification) 1. [`Linter` no longer tries to load missing parsers from the filesystem](#linter-parsers) diff --git a/docs/user-guide/migrating-to-8.0.0.md b/docs/user-guide/migrating-to-8.0.0.md index 351309cc00f..444ac124c4c 100644 --- a/docs/user-guide/migrating-to-8.0.0.md +++ b/docs/user-guide/migrating-to-8.0.0.md @@ -51,7 +51,6 @@ ESLint v8.0.0 has removed the `codeframe` and `table` formatters from the core. **Related issue(s):** [#14277](https://github.com/eslint/eslint/issues/14277), [#14316](https://github.com/eslint/eslint/pull/14316) - ## `comma-dangle` rule schema is stricter In ESLint v7.0.0, the `comma-dangle` rule could be configured like this without error: @@ -105,7 +104,6 @@ Four new rules have been enabled in the `eslint:recommended` preset. **Related issue(s):** [#14673](https://github.com/eslint/eslint/issues/14673) - ## Rules require `meta.hasSuggestions` to provide suggestions In ESLint v7.0.0, rules that [provided suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions) did not need to let ESLint know. In v8.0.0, rules providing suggestions need to set their `meta.hasSuggestions` to `true`. This informs ESLint that the rule intends to provide suggestions. Without this property, any attempt to provide a suggestion will result in an error. @@ -219,7 +217,6 @@ In ESLint v8.0.0 (via Acorn v8.0.0), the key and value are now separate objects **Related issue(s):** [#14591](https://github.com/eslint/eslint/pull/14591#issuecomment-887733070) - ## The `CLIEngine` class has been removed The `CLIEngine` class has been removed and replaced by the [`ESLint` class](https://eslint.org/docs/developer-guide/nodejs-api#eslint-class). diff --git a/package.json b/package.json index c3dfa1bb370..6fc8d28770e 100644 --- a/package.json +++ b/package.json @@ -116,8 +116,8 @@ "karma-webpack": "^5.0.0", "lint-staged": "^11.0.0", "load-perf": "^0.2.0", - "markdownlint": "^0.23.1", - "markdownlint-cli": "^0.28.1", + "markdownlint": "^0.24.0", + "markdownlint-cli": "^0.30.0", "memfs": "^3.0.1", "mocha": "^8.3.2", "mocha-junit-reporter": "^2.0.0", diff --git a/templates/bug-report.md b/templates/bug-report.md index bd3035b540e..c8c552d306d 100644 --- a/templates/bug-report.md +++ b/templates/bug-report.md @@ -1,4 +1,4 @@ -**Tell us about your environment** +**Tell us about your environment:** * **ESLint Version:** * **Node Version:** @@ -23,4 +23,3 @@ **What did you expect to happen?** **What actually happened? Please include the actual, raw output from ESLint.** - diff --git a/templates/rule-change-proposal.md b/templates/rule-change-proposal.md index ee100011bc4..a4a8e17cbd5 100644 --- a/templates/rule-change-proposal.md +++ b/templates/rule-change-proposal.md @@ -1,12 +1,9 @@ **What rule do you want to change?** - **Does this change cause the rule to produce more or fewer warnings?** - **How will the change be implemented? (New option, new default behavior, etc.)?** - **Please provide some example code that this change will affect:** ```js @@ -15,6 +12,4 @@ **What does the rule currently do for this code?** - **What will the rule do after it's changed?** - diff --git a/templates/rule-proposal.md b/templates/rule-proposal.md index 383b1b4819c..2adf9317613 100644 --- a/templates/rule-proposal.md +++ b/templates/rule-proposal.md @@ -1,7 +1,6 @@ **Please describe what the rule should do:** - -**What category of rule is this? (place an "X" next to just one item)** +**What category of rule is this (place an "X" next to just one item)?** [ ] Enforces code style [ ] Warns about a potential error @@ -15,4 +14,3 @@ ``` **Why should this rule be included in ESLint (instead of a plugin)?** -