diff --git a/Makefile.js b/Makefile.js index 25eb619fdc1..4ef251b1415 100644 --- a/Makefile.js +++ b/Makefile.js @@ -660,9 +660,7 @@ target.gensite = function(prereleaseVersion) { sourcePath = path.join("lib/rules", sourceBaseName), ruleName = path.basename(filename, ".md"), filePath = path.posix.join("docs", path.relative("tmp", filename)); - let text = cat(filename), - ruleType = "", - title; + let text = cat(filename); process.stdout.write(`> Updating files (Steps 4-9): ${i}/${length} - ${filePath + " ".repeat(30)}\r`); @@ -675,40 +673,12 @@ target.gensite = function(prereleaseVersion) { const isFixable = rule && rule.meta.fixable; const hasSuggestions = rule && rule.meta.hasSuggestions; - // Incorporate the special portion into the documentation content - const textSplit = text.split("\n"); - const ruleHeading = textSplit[0]; - const ruleDocsContent = textSplit.slice(1).join("\n"); + text = text.replace("", isFixable ? FIXABLE_TEXT : "") + .replace("", hasSuggestions ? HAS_SUGGESTIONS_TEXT : "") + .replace("", isRecommended ? RECOMMENDED_TEXT : ""); - text = `${ruleHeading}${isRecommended ? RECOMMENDED_TEXT : ""}${isFixable ? FIXABLE_TEXT : ""}${hasSuggestions ? HAS_SUGGESTIONS_TEXT : ""}\n${ruleDocsContent}`; - title = `${ruleName} - Rules`; - - if (rule && rule.meta) { - ruleType = `rule_type: ${rule.meta.type}`; - } - } else { - - // extract the title from the file itself - title = text.match(/#([^#].+)\n/u); - if (title) { - title = title[1].trim(); - } else { - title = "Documentation"; - } } - text = [ - "---", - `title: ${title}`, - "layout: doc", - `edit_link: https://github.com/eslint/eslint/edit/main/${filePath.replace("docs/", "docs/src/")}`, - ruleType, - "---", - "", - "", - text - ].join("\n"); - // 6. Remove .md extension for relative links and change README to empty string text = text.replace(/\((?!https?:\/\/)([^)]*?)\.md(.*?)\)/gu, "($1$2)").replace("README.html", ""); @@ -816,7 +786,7 @@ target.checkRuleFiles = function() { * @todo Will remove this check when the main heading is automatically generated from rule metadata. */ function hasIdInTitle(id) { - return new RegExp(`^# ${id}`, "u").test(docText); + return new RegExp(`title: ${id}`, "u").test(docText); } /** diff --git a/docs/src/about/index.md b/docs/src/about/index.md index a9c5acb4638..5b3b359b45d 100644 --- a/docs/src/about/index.md +++ b/docs/src/about/index.md @@ -1,4 +1,9 @@ -# About +--- +title: About +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/about/index.md + +--- ESLint is an open source JavaScript linting utility originally created by Nicholas C. Zakas in June 2013. Code [linting][] is a type of static analysis that is frequently used to find problematic patterns or code that doesn't adhere to certain style guidelines. There are code linters for most programming languages, and compilers sometimes incorporate linting into the compilation process. diff --git a/docs/src/developer-guide/README.md b/docs/src/developer-guide/README.md index a5e65927869..ea1bc20bd8e 100644 --- a/docs/src/developer-guide/README.md +++ b/docs/src/developer-guide/README.md @@ -1,4 +1,9 @@ -# Developer Guide +--- +title: Developer Guide +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/developer-guide/README.md + +--- This guide is intended for those who wish to: @@ -14,31 +19,31 @@ In order to work with ESLint as a developer, it's recommended that: If that sounds like you, then continue reading to get started. -## Section 1: Get the [Source Code](source-code.md) +## Section 1: Get the [Source Code](source-code) Before you can get started, you'll need to get a copy of the ESLint source code. This section explains how to do that and a little about the source code structure. -## Section 2: Set up a [Development Environment](development-environment.md) +## Section 2: Set up a [Development Environment](development-environment) Developing for ESLint is a bit different than running it on the command line. This section shows you how to set up a development environment and get you ready to write code. -## Section 3: Run the [Unit Tests](unit-tests.md) +## Section 3: Run the [Unit Tests](unit-tests) There are a lot of unit tests included with ESLint to make sure that we're keeping on top of code quality. This section explains how to run the unit tests. -## Section 4: [Working with Rules](working-with-rules.md) +## Section 4: [Working with Rules](working-with-rules) You're finally ready to start working with rules. You may want to fix an existing rule or create a new one. This section explains how to do all of that. -## Section 5: [Working with Plugins](working-with-plugins.md) +## Section 5: [Working with Plugins](working-with-plugins) You've developed library-specific rules for ESLint and you want to share them with the community. You can publish an ESLint plugin on npm. -## Section 6: [Working with Custom Parsers](working-with-custom-parsers.md) +## Section 6: [Working with Custom Parsers](working-with-custom-parsers) If you aren't going to use the default parser of ESLint, this section explains about using custom parsers. -## Section 7: [Node.js API](nodejs-api.md) +## Section 7: [Node.js API](nodejs-api) If you're interested in writing a tool that uses ESLint, then you can use the Node.js API to get programmatic access to functionality. diff --git a/docs/src/developer-guide/architecture.md b/docs/src/developer-guide/architecture/index.md similarity index 96% rename from docs/src/developer-guide/architecture.md rename to docs/src/developer-guide/architecture/index.md index 37261abcc3d..b2ec2bc194b 100644 --- a/docs/src/developer-guide/architecture.md +++ b/docs/src/developer-guide/architecture/index.md @@ -1,6 +1,11 @@ -# Architecture +--- +title: Architecture +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/developer-guide/architecture/index.md -
dependency graph
+--- + +
dependency graph
At a high level, there are a few key parts to ESLint: diff --git a/docs/src/developer-guide/code-conventions.md b/docs/src/developer-guide/code-conventions.md index 0c1cbe6245d..9b639c36cb9 100644 --- a/docs/src/developer-guide/code-conventions.md +++ b/docs/src/developer-guide/code-conventions.md @@ -1,4 +1,9 @@ -# Code Conventions +--- +title: Code Conventions +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/developer-guide/code-conventions.md + +--- Code conventions for ESLint are determined by [eslint-config-eslint](https://www.npmjs.com/package/eslint-config-eslint). diff --git a/docs/src/developer-guide/code-path-analysis.md b/docs/src/developer-guide/code-path-analysis.md index 2b01bc77e81..68348f3e7a2 100644 --- a/docs/src/developer-guide/code-path-analysis.md +++ b/docs/src/developer-guide/code-path-analysis.md @@ -1,4 +1,9 @@ -# Code Path Analysis Details +--- +title: Code Path Analysis Details +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/developer-guide/code-path-analysis.md + +--- ESLint's rules can use code paths. The code path is execution routes of programs. diff --git a/docs/src/developer-guide/code-path-analysis/README.md b/docs/src/developer-guide/code-path-analysis/README.md index 2b6fd7486f6..6f48c809722 100644 --- a/docs/src/developer-guide/code-path-analysis/README.md +++ b/docs/src/developer-guide/code-path-analysis/README.md @@ -1 +1,8 @@ -[Code Path Analysis Details](../code-path-analysis.md) +--- +title: Code Path Analysis Details +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/developer-guide/code-path-analysis/README.md + +--- + +[Code Path Analysis Details](../code-path-analysis) diff --git a/docs/src/developer-guide/contributing/README.md b/docs/src/developer-guide/contributing/README.md index 050953957e0..84ef50e9458 100644 --- a/docs/src/developer-guide/contributing/README.md +++ b/docs/src/developer-guide/contributing/README.md @@ -1,4 +1,9 @@ -# Contributing +--- +title: Contributing +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/developer-guide/contributing/README.md + +--- One of the great things about open source projects is that anyone can contribute in any number of meaningful ways. ESLint couldn't exist without the help of the many contributors it's had since the project began, and we want you to feel like you can contribute and make a difference as well. @@ -12,15 +17,15 @@ ESLint welcomes contributions from everyone and adheres to the [OpenJS Foundatio Think you found a problem? We'd love to hear about it. This section explains how to submit a bug, the type of information we need to properly verify it, and the overall process. -## Proposing a [New Rule](new-rules.md) +## Proposing a [New Rule](new-rules) We get a lot of proposals for new rules in ESLint. This section explains how we determine which rules are accepted and what information you should provide to help us evaluate your proposal. -## Proposing a [Rule Change](rule-changes.md) +## Proposing a [Rule Change](rule-changes) Want to make a change to an existing rule? This section explains the process and how we evaluate such proposals. -## Requesting a [Change](changes.md) +## Requesting a [Change](changes) If you'd like to request a change other than a bug fix or new rule, this section explains that process. @@ -28,11 +33,11 @@ If you'd like to request a change other than a bug fix or new rule, this section To report a security vulnerability in ESLint, please use our [HackerOne program](https://hackerone.com/eslint). -## [Working on Issues](working-on-issues.md) +## [Working on Issues](working-on-issues) Have some extra time and want to contribute? This section talks about the process of working on issues. -## Submitting a [Pull Request](pull-requests.md) +## Submitting a [Pull Request](pull-requests) We're always looking for contributions from the community. This section explains the requirements for pull requests and the process of contributing code. diff --git a/docs/src/developer-guide/contributing/changes.md b/docs/src/developer-guide/contributing/changes.md index 4c722ad660c..b6059676e1d 100644 --- a/docs/src/developer-guide/contributing/changes.md +++ b/docs/src/developer-guide/contributing/changes.md @@ -1,4 +1,9 @@ -# Change Requests +--- +title: Change Requests +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/developer-guide/contributing/changes.md + +--- If you'd like to request a change to ESLint, please [create a new issue](https://github.com/eslint/eslint/issues/new/choose) on GitHub. Be sure to include the following information: diff --git a/docs/src/developer-guide/contributing/new-rules.md b/docs/src/developer-guide/contributing/new-rules.md index c3f6fbb0e6f..9288618c985 100644 --- a/docs/src/developer-guide/contributing/new-rules.md +++ b/docs/src/developer-guide/contributing/new-rules.md @@ -1,4 +1,9 @@ -# New Rules +--- +title: New Rules +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/developer-guide/contributing/new-rules.md + +--- ESLint is all about rules. For most of the project's lifetime, we've had over 200 rules, and that list continues to grow. However, we can't just accept any proposed rule because all rules need to work cohesively together. As such, we have some guidelines around which rules can be part of the ESLint core and which are better off as custom rules and plugins. @@ -39,4 +44,4 @@ The ESLint team doesn't implement new rules that are suggested by users because ## Alternative: Creating Your Own Rules -Remember that ESLint is completely pluggable, which means you can create your own rules and distribute them using plugins. We did this on purpose because we don't want to be the gatekeepers for all possible rules. Even if we don't accept a rule into the core, that doesn't mean you can't have the exact rule that you want. See the [working with rules](../working-with-rules.md) and [working with plugins](../working-with-plugins.md) documentation for more information. +Remember that ESLint is completely pluggable, which means you can create your own rules and distribute them using plugins. We did this on purpose because we don't want to be the gatekeepers for all possible rules. Even if we don't accept a rule into the core, that doesn't mean you can't have the exact rule that you want. See the [working with rules](../working-with-rules) and [working with plugins](../working-with-plugins) documentation for more information. diff --git a/docs/src/developer-guide/contributing/pull-requests.md b/docs/src/developer-guide/contributing/pull-requests.md index b58d105006c..8c9ede4d003 100644 --- a/docs/src/developer-guide/contributing/pull-requests.md +++ b/docs/src/developer-guide/contributing/pull-requests.md @@ -1,4 +1,9 @@ -# Pull Requests +--- +title: Pull Requests +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/developer-guide/contributing/pull-requests.md + +--- If you want to contribute to an ESLint repo, please use a GitHub pull request. This is the fastest way for us to evaluate your code and to merge it into the code base. Please don't file an issue with snippets of code. Doing so means that we need to manually merge the changes in and update any appropriate tests. That decreases the likelihood that your code is going to get included in a timely manner. Please use pull requests. @@ -6,8 +11,8 @@ If you want to contribute to an ESLint repo, please use a GitHub pull request. T If you'd like to work on a pull request and you've never submitted code before, follow these steps: -1. Set up a [development environment](../development-environment.md). -1. If you want to implement a breaking change or a change to the core, ensure there's an issue that describes what you're doing and the issue has been accepted. You can create a new issue or just indicate you're [working on an existing issue](working-on-issues.md). Bug fixes, documentation changes, and other pull requests do not require an issue. +1. Set up a [development environment](../development-environment). +1. If you want to implement a breaking change or a change to the core, ensure there's an issue that describes what you're doing and the issue has been accepted. You can create a new issue or just indicate you're [working on an existing issue](working-on-issues). Bug fixes, documentation changes, and other pull requests do not require an issue. After that, you're ready to start working on code. @@ -39,7 +44,7 @@ You should do all of your development for the issue in this branch. ### Step 2: Make your changes -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: +Make the changes to the code and tests, following the [code conventions](../code-conventions) as you go. Once you have finished, commit the changes to your branch: ```shell git add -A @@ -72,7 +77,7 @@ The `tag` is one of the following: * `ci` - changes to our CI configuration files and scripts. * `perf` - a code change that improves performance. -Use the [labels of the issue you are working on](working-on-issues.md#issue-labels) to determine the best tag. +Use the [labels of the issue you are working on](working-on-issues#issue-labels) to determine the best tag. The message summary should be a one-sentence description of the change, and it must be 72 characters in length or shorter. If the pull request addresses an issue, then the issue number should be mentioned in the body of the commit message in the format `Fixes #1234`. If the commit doesn't completely fix the issue, then use `Refs #1234` instead of `Fixes #1234`. @@ -116,7 +121,7 @@ With your code ready to go, this is a good time to double-check your submission * Make separate pull requests for unrelated changes. Large pull requests with multiple unrelated changes may be closed without merging. * All changes must be accompanied by tests, even if the feature you're working on previously had no tests. * All user-facing changes must be accompanied by appropriate documentation. -* Follow the [Code Conventions](../code-conventions.md). +* Follow the [Code Conventions](../code-conventions). ### Step 6: Push your changes @@ -176,7 +181,7 @@ The commit messages in subsequent commits do not need to be in any specific form ### Rebasing -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: +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) and then you can rebase using these commands: ```shell git fetch upstream diff --git a/docs/src/developer-guide/contributing/reporting-bugs.md b/docs/src/developer-guide/contributing/reporting-bugs.md index 0c59b345d2b..8d713c46004 100644 --- a/docs/src/developer-guide/contributing/reporting-bugs.md +++ b/docs/src/developer-guide/contributing/reporting-bugs.md @@ -1,6 +1,11 @@ -# Reporting Bugs +--- +title: Reporting Bugs +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/developer-guide/contributing/reporting-bugs.md -If you think you've found a bug in ESLint, please [create a new issue](https://github.com/eslint/eslint/issues/new/choose) or a [pull request](/docs/developer-guide/contributing/pull-requests.md) on GitHub. +--- + +If you think you've found a bug in ESLint, please [create a new issue](https://github.com/eslint/eslint/issues/new/choose) or a [pull request](/docs/developer-guide/contributing/pull-requests) on GitHub. Please include as much detail as possible to help us properly address your issue. If we need to triage issues and constantly ask people for more detail, that's time taken away from actually fixing issues. Help us be as efficient as possible by including a lot of detail in your issues. diff --git a/docs/src/developer-guide/contributing/rule-changes.md b/docs/src/developer-guide/contributing/rule-changes.md index 358862f1af7..d6c07562e81 100644 --- a/docs/src/developer-guide/contributing/rule-changes.md +++ b/docs/src/developer-guide/contributing/rule-changes.md @@ -1,10 +1,15 @@ -# Rule Changes +--- +title: Rule Changes +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/developer-guide/contributing/rule-changes.md + +--- Occasionally, a core ESLint rule needs to be changed. This is not necessarily a bug, but rather, an enhancement that makes a rule more configurable. In those situations, we will consider making changes to rules. ## Proposing a Rule Change -To propose a change to an existing rule, [create a pull request](/docs/developer-guide/contributing/pull-requests.md) or [new issue](https://github.com/eslint/eslint/issues/new/choose) and fill out the template. +To propose a change to an existing rule, [create a pull request](/docs/developer-guide/contributing/pull-requests) or [new issue](https://github.com/eslint/eslint/issues/new/choose) and fill out the template. We need all of this information in order to determine whether or not the change is a good candidate for inclusion. @@ -12,7 +17,7 @@ We need all of this information in order to determine whether or not the change In order for a rule change to be accepted into ESLint, it must: -1. Adhere to the [Core Rule Guidelines](new-rules.md#core-rule-guidelines) +1. Adhere to the [Core Rule Guidelines](new-rules#core-rule-guidelines) 1. Have an ESLint team member champion the change 1. Be important enough that rule is deemed incomplete without this change diff --git a/docs/src/developer-guide/contributing/working-on-issues.md b/docs/src/developer-guide/contributing/working-on-issues.md index 9e666d649b3..0065db77c0c 100644 --- a/docs/src/developer-guide/contributing/working-on-issues.md +++ b/docs/src/developer-guide/contributing/working-on-issues.md @@ -1,4 +1,9 @@ -# Working on Issues +--- +title: Working on Issues +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/developer-guide/contributing/working-on-issues.md + +--- Our public [issues tracker](https://github.com/eslint/eslint/issues) lists all of the things we plan on doing as well as suggestions from the community. Before starting to work on an issue, be sure you read through the rest of this page. diff --git a/docs/src/developer-guide/development-environment.md b/docs/src/developer-guide/development-environment.md index f61c3eb6d2d..cd5f40febda 100644 --- a/docs/src/developer-guide/development-environment.md +++ b/docs/src/developer-guide/development-environment.md @@ -1,4 +1,9 @@ -# Development Environment +--- +title: Development Environment +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/developer-guide/development-environment.md + +--- ESLint has a very lightweight development environment that makes updating code fast and easy. This is a step-by-step guide to setting up a local development environment that will let you contribute back to the project. @@ -59,7 +64,7 @@ The testing takes a few minutes to complete. If any tests fail, that likely mean ### Workflow -Once you have your development environment installed, you can make and submit changes to the ESLint source files. Doing this successfully requires careful adherence to our [pull-request submission workflow](contributing/pull-requests.md). +Once you have your development environment installed, you can make and submit changes to the ESLint source files. Doing this successfully requires careful adherence to our [pull-request submission workflow](contributing/pull-requests). ### Build Scripts diff --git a/docs/src/developer-guide/nodejs-api.md b/docs/src/developer-guide/nodejs-api.md index fc63072ad62..8622326aa56 100644 --- a/docs/src/developer-guide/nodejs-api.md +++ b/docs/src/developer-guide/nodejs-api.md @@ -1,4 +1,9 @@ -# Node.js API +--- +title: Node.js API +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/developer-guide/nodejs-api.md + +--- While ESLint is designed to be run on the command line, it's possible to use ESLint programmatically through the Node.js API. The purpose of the Node.js API is to allow plugin and tool authors to use the ESLint functionality directly, without going through the command line interface. @@ -492,7 +497,7 @@ The `Linter` object does the actual evaluation of the JavaScript code. It doesn' The `Linter` is a constructor, and you can create a new instance by passing in the options you want to use. The available options are: -* `cwd` - Path to a directory that should be considered as the current working directory. It is accessible to rules by calling `context.getCwd()` (see [The Context Object](./working-with-rules.md#the-context-object)). If `cwd` is `undefined`, it will be normalized to `process.cwd()` if the global `process` object is defined (for example, in the Node.js runtime) , or `undefined` otherwise. +* `cwd` - Path to a directory that should be considered as the current working directory. It is accessible to rules by calling `context.getCwd()` (see [The Context Object](./working-with-rules#the-context-object)). If `cwd` is `undefined`, it will be normalized to `process.cwd()` if the global `process` object is defined (for example, in the Node.js runtime) , or `undefined` otherwise. For example: @@ -514,8 +519,8 @@ The most important method on `Linter` is `verify()`, which initiates linting of * **Note**: If you want to lint text and have your configuration be read and processed, use [`ESLint#lintFiles()`][eslint-lintfiles] or [`ESLint#lintText()`][eslint-linttext] instead. * `options` - (optional) Additional options for this run. * `filename` - (optional) the filename to associate with the source code. - * `preprocess` - (optional) A function that [Processors in Plugins](/docs/developer-guide/working-with-plugins.md#processors-in-plugins) documentation describes as the `preprocess` method. - * `postprocess` - (optional) A function that [Processors in Plugins](/docs/developer-guide/working-with-plugins.md#processors-in-plugins) documentation describes as the `postprocess` method. + * `preprocess` - (optional) A function that [Processors in Plugins](/docs/developer-guide/working-with-plugins#processors-in-plugins) documentation describes as the `preprocess` method. + * `postprocess` - (optional) A function that [Processors in Plugins](/docs/developer-guide/working-with-plugins#processors-in-plugins) documentation describes as the `postprocess` method. * `filterCodeBlock` - (optional) A function that decides which code blocks the linter should adopt. The function receives two arguments. The first argument is the virtual filename of a code block. The second argument is the text of the code block. If the function returned `true` then the linter adopts the code block. If the function was omitted, the linter adopts only `*.js` code blocks. If you provided a `filterCodeBlock` function, it overrides this default behavior, so the linter doesn't adopt `*.js` code blocks automatically. * `disableFixes` - (optional) when set to `true`, the linter doesn't make either the `fix` or `suggestions` property of the lint result. * `allowInlineConfig` - (optional) set to `false` to disable inline comments from changing ESLint rules. @@ -579,7 +584,7 @@ The information available for each linting message is: * `endColumn` - the end column of the range on which the error occurred (this property is omitted if it's not range). * `endLine` - the end line of the range on which the error occurred (this property is omitted if it's not range). * `fix` - an object describing the fix for the problem (this property is omitted if no fix is available). -* `suggestions` - an array of objects describing possible lint fixes for editors to programmatically enable (see details in the [Working with Rules docs](./working-with-rules.md#providing-suggestions)). +* `suggestions` - an array of objects describing possible lint fixes for editors to programmatically enable (see details in the [Working with Rules docs](./working-with-rules#providing-suggestions)). You can get the suppressed messages from the previous run by `getSuppressedMessages()` method. If there is not a previous run, `getSuppressedMessage()` will return an empty list. @@ -711,7 +716,7 @@ Map { ### Linter#defineParser Each instance of `Linter` holds a map of custom parsers. If you want to define a parser programmatically, you can add this function -with the name of the parser as first argument and the [parser object](/docs/developer-guide/working-with-custom-parsers.md) as second argument. The default `"espree"` parser will already be loaded for every `Linter` instance. +with the name of the parser as first argument and the [parser object](/docs/developer-guide/working-with-custom-parsers) as second argument. The default `"espree"` parser will already be loaded for every `Linter` instance. ```js const Linter = require("eslint").Linter; @@ -791,7 +796,7 @@ const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: 2015 } }); The `RuleTester#run()` method is used to run the tests. It should be passed the following arguments: * The name of the rule (string) -* The rule object itself (see ["working with rules"](./working-with-rules.md)) +* The rule object itself (see ["working with rules"](./working-with-rules)) * An object containing `valid` and `invalid` properties, each of which is an array containing test cases. A test case is an object with the following properties: diff --git a/docs/src/developer-guide/scope-manager-interface.md b/docs/src/developer-guide/scope-manager-interface.md index e1a84dccad3..4a6dc3302bb 100644 --- a/docs/src/developer-guide/scope-manager-interface.md +++ b/docs/src/developer-guide/scope-manager-interface.md @@ -1,4 +1,9 @@ -# ScopeManager +--- +title: ScopeManager +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/developer-guide/scope-manager-interface.md + +--- This document was written based on the implementation of [eslint-scope](https://github.com/eslint/eslint-scope), a fork of [escope](https://github.com/estools/escope), and deprecates some members ESLint is not using. diff --git a/docs/src/developer-guide/selectors.md b/docs/src/developer-guide/selectors.md index 78bb2608426..1ee40c7d6c4 100644 --- a/docs/src/developer-guide/selectors.md +++ b/docs/src/developer-guide/selectors.md @@ -1,4 +1,9 @@ -# Selectors +--- +title: Selectors +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/developer-guide/selectors.md + +--- Some rules and APIs allow the use of selectors to query an AST. This page is intended to: @@ -90,7 +95,7 @@ If multiple selectors have equal specificity, their listeners will be called in ### Restricting syntax with selectors -With the [no-restricted-syntax](/docs/rules/no-restricted-syntax.md) rule, you can restrict the usage of particular syntax in your code. For example, you can use the following configuration to disallow using `if` statements that do not have block statements as their body: +With the [no-restricted-syntax](/docs/rules/no-restricted-syntax) rule, you can restrict the usage of particular syntax in your code. For example, you can use the following configuration to disallow using `if` statements that do not have block statements as their body: ```json { diff --git a/docs/src/developer-guide/shareable-configs.md b/docs/src/developer-guide/shareable-configs.md index 15032d9e7a0..bdee9e10ca4 100644 --- a/docs/src/developer-guide/shareable-configs.md +++ b/docs/src/developer-guide/shareable-configs.md @@ -1,4 +1,9 @@ -# Shareable Configs +--- +title: Shareable Configs +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/developer-guide/shareable-configs.md + +--- The configuration that you have in your `.eslintrc` file is an important part of your project, and as such, you may want to share it with other projects or people. Shareable configs allow you to publish your configuration settings on [npm](https://www.npmjs.com/) and have others download and use it in their ESLint projects. diff --git a/docs/src/developer-guide/source-code.md b/docs/src/developer-guide/source-code.md index a6b7fa5b1d7..5ee58ffeb25 100644 --- a/docs/src/developer-guide/source-code.md +++ b/docs/src/developer-guide/source-code.md @@ -1,4 +1,9 @@ -# Source Code +--- +title: Source Code +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/developer-guide/source-code.md + +--- ESLint is hosted at [GitHub](https://github.com/eslint/eslint) and uses [Git](https://git-scm.com/) for source control. In order to obtain the source code, you must first install Git on your system. Instructions for installing and setting up Git can be found at [https://help.github.com/articles/set-up-git/](https://help.github.com/articles/set-up-git/). diff --git a/docs/src/developer-guide/unit-tests.md b/docs/src/developer-guide/unit-tests.md index 2968a23805a..0d318495fb4 100644 --- a/docs/src/developer-guide/unit-tests.md +++ b/docs/src/developer-guide/unit-tests.md @@ -1,4 +1,9 @@ -# Unit Tests +--- +title: Unit Tests +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/developer-guide/unit-tests.md + +--- Most parts of ESLint have unit tests associated with them. Unit tests are written using [Mocha](https://mochajs.org/) and are required when making contributions to ESLint. You'll find all of the unit tests in the `tests` directory. diff --git a/docs/src/developer-guide/working-with-custom-formatters.md b/docs/src/developer-guide/working-with-custom-formatters.md index bdcbdb12f6a..d9fd89356c2 100644 --- a/docs/src/developer-guide/working-with-custom-formatters.md +++ b/docs/src/developer-guide/working-with-custom-formatters.md @@ -1,4 +1,9 @@ -# Working with Custom Formatters +--- +title: Working with Custom Formatters +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/developer-guide/working-with-custom-formatters.md + +--- While ESLint has some built-in formatters available to format the linting results, it's also possible to create and distribute your own custom formatters. You can include custom formatters in your project directly or create an npm package to distribute them separately. @@ -122,8 +127,8 @@ Each `message` object contains information about the ESLint rule that was trigge The formatter function receives an object as the second argument. The object has two properties: -* `cwd` ... The current working directory. This value comes from the `cwd` constructor option of the [ESLint](nodejs-api.md#-new-eslintoptions) class. -* `rulesMeta` ... The `meta` property values of rules. See the [Working with Rules](working-with-rules.md) page for more information about rules. +* `cwd` ... The current working directory. This value comes from the `cwd` constructor option of the [ESLint](nodejs-api#-new-eslintoptions) class. +* `rulesMeta` ... The `meta` property values of rules. See the [Working with Rules](working-with-rules) page for more information about rules. For example, here's what the object would look like if one rule, `no-extra-semi`, had been run: diff --git a/docs/src/developer-guide/working-with-custom-parsers.md b/docs/src/developer-guide/working-with-custom-parsers.md index 6387b848584..71a67eb0ede 100644 --- a/docs/src/developer-guide/working-with-custom-parsers.md +++ b/docs/src/developer-guide/working-with-custom-parsers.md @@ -1,10 +1,15 @@ -# Working with Custom Parsers +--- +title: Working with Custom Parsers +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/developer-guide/working-with-custom-parsers.md + +--- If you want to use your own parser and provide additional capabilities for your rules, you can specify your own custom parser. If a `parseForESLint` method is exposed on the parser, this method will be used to parse the code. Otherwise, the `parse` method will be used. Both methods should take in the source code as the first argument, and an optional configuration object as the second argument (provided as `parserOptions` in a config file). The `parse` method should simply return the AST. The `parseForESLint` method should return an object that contains the required property `ast` and optional properties `services`, `scopeManager`, and `visitorKeys`. * `ast` should contain the AST. * `services` can contain any parser-dependent services (such as type checkers for nodes). The value of the `services` property is available to rules as `context.parserServices`. Default is an empty object. -* `scopeManager` can be a [ScopeManager](./scope-manager-interface.md) object. Custom parsers can use customized scope analysis for experimental/enhancement syntaxes. Default is the `ScopeManager` object which is created by [eslint-scope](https://github.com/eslint/eslint-scope). +* `scopeManager` can be a [ScopeManager](./scope-manager-interface) object. Custom parsers can use customized scope analysis for experimental/enhancement syntaxes. Default is the `ScopeManager` object which is created by [eslint-scope](https://github.com/eslint/eslint-scope). * Support for `scopeManager` was added in ESLint v4.14.0. ESLint versions which support `scopeManager` will provide an `eslintScopeManager: true` property in `parserOptions`, which can be used for feature detection. * `visitorKeys` can be an object to customize AST traversal. The keys of the object are the type of AST nodes. Each value is an array of the property names which should be traversed. Default is [KEYS of `eslint-visitor-keys`](https://github.com/eslint/eslint-visitor-keys#evkkeys). * Support for `visitorKeys` was added in ESLint v4.14.0. ESLint versions which support `visitorKeys` will provide an `eslintVisitorKeys: true` property in `parserOptions`, which can be used for feature detection. diff --git a/docs/src/developer-guide/working-with-plugins.md b/docs/src/developer-guide/working-with-plugins.md index bea47021932..68519d28b46 100644 --- a/docs/src/developer-guide/working-with-plugins.md +++ b/docs/src/developer-guide/working-with-plugins.md @@ -1,4 +1,9 @@ -# Working with Plugins +--- +title: Working with Plugins +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/developer-guide/working-with-plugins.md + +--- Each plugin is an npm module with a name in the format of `eslint-plugin-`, such as `eslint-plugin-jquery`. You can also use scoped packages in the format of `@/eslint-plugin-` such as `@jquery/eslint-plugin-jquery` or even `@/eslint-plugin` such as `@jquery/eslint-plugin`. @@ -84,7 +89,7 @@ module.exports = { **The `preprocess` method** takes the file contents and filename as arguments, and returns an array of code blocks to lint. The code blocks will be linted separately but still be registered to the filename. -A code block has two properties `text` and `filename`; the `text` property is the content of the block and the `filename` property is the name of the block. Name of the block can be anything, but should include the file extension, that would tell the linter how to process the current block. The linter will check [`--ext` CLI option](../user-guide/command-line-interface.md#--ext) to see if the current block should be linted, and resolve `overrides` configs to check how to process the current block. +A code block has two properties `text` and `filename`; the `text` property is the content of the block and the `filename` property is the name of the block. Name of the block can be anything, but should include the file extension, that would tell the linter how to process the current block. The linter will check [`--ext` CLI option](../user-guide/command-line-interface#--ext) to see if the current block should be linted, and resolve `overrides` configs to check how to process the current block. It's up to the plugin to decide if it needs to return just one part, or multiple pieces. For example in the case of processing `.html` files, you might want to return just one item in the array by combining all scripts, but for `.md` file where each JavaScript block might be independent, you can return multiple items. @@ -136,7 +141,7 @@ overrides: processor: a-plugin/markdown ``` -See [Specifying Processor](../user-guide/configuring/plugins.md#specifying-processor) for details. +See [Specifying Processor](../user-guide/configuring/plugins#specifying-processor) for details. #### File Extension-named Processor @@ -197,7 +202,7 @@ If the example plugin above were called `eslint-plugin-myPlugin`, the `myConfig` ``` -**Note:** Please note that configuration will not enable any of the plugin's rules by default, and instead should be treated as a standalone config. This means that you must specify your plugin name in the `plugins` array as well as any rules you want to enable that are part of the plugin. Any plugin rules must be prefixed with the short or long plugin name. See [Configuring Plugins](../user-guide/configuring/plugins.md#configuring-plugins) for more information. +**Note:** Please note that configuration will not enable any of the plugin's rules by default, and instead should be treated as a standalone config. This means that you must specify your plugin name in the `plugins` array as well as any rules you want to enable that are part of the plugin. Any plugin rules must be prefixed with the short or long plugin name. See [Configuring Plugins](../user-guide/configuring/plugins#configuring-plugins) for more information. ### Peer Dependency @@ -214,7 +219,7 @@ The plugin support was introduced in ESLint version `0.8.0`. Ensure the `peerDep ### Testing -ESLint provides the [`RuleTester`](/docs/developer-guide/nodejs-api.md#ruletester) utility to make it easy to test the rules of your plugin. +ESLint provides the [`RuleTester`](/docs/developer-guide/nodejs-api#ruletester) utility to make it easy to test the rules of your plugin. ### Linting diff --git a/docs/src/developer-guide/working-with-rules-deprecated.md b/docs/src/developer-guide/working-with-rules-deprecated.md index 63d7bb2fc69..a700780a85f 100644 --- a/docs/src/developer-guide/working-with-rules-deprecated.md +++ b/docs/src/developer-guide/working-with-rules-deprecated.md @@ -1,6 +1,11 @@ -# Working with Rules (Deprecated) +--- +title: Working with Rules (Deprecated) +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/developer-guide/working-with-rules-deprecated.md -**Note:** This page covers the deprecated rule format for ESLint <= 2.13.1. [This is the most recent rule format](./working-with-rules.md). +--- + +**Note:** This page covers the deprecated rule format for ESLint <= 2.13.1. [This is the most recent rule format](./working-with-rules). Each rule in ESLint has two files named with its identifier (for example, `no-extra-semi`). @@ -34,17 +39,17 @@ module.exports.schema = []; // no options ## Rule Basics -`schema` (array) specifies the [options](#options-schemas) so ESLint can prevent invalid [rule configurations](../user-guide/configuring/rules.md#configuring-rules) +`schema` (array) specifies the [options](#options-schemas) so ESLint can prevent invalid [rule configurations](../user-guide/configuring/rules#configuring-rules) `create` (function) returns an object with methods that ESLint calls to "visit" nodes while traversing the abstract syntax tree (AST as defined by [ESTree](https://github.com/estree/estree)) of JavaScript code: * if a key is a node type, ESLint calls that **visitor** function while going **down** the tree * if a key is a node type plus `:exit`, ESLint calls that **visitor** function while going **up** the tree -* if a key is an event name, ESLint calls that **handler** function for [code path analysis](./code-path-analysis.md) +* if a key is an event name, ESLint calls that **handler** function for [code path analysis](./code-path-analysis) A rule can use the current node and its surrounding tree to report or fix problems. -Here are methods for the [array-callback-return](../rules/array-callback-return.md) rule: +Here are methods for the [array-callback-return](../rules/array-callback-return) rule: ```js function checkLastSegment (node) { @@ -74,7 +79,7 @@ module.exports = function(context) { The `context` object contains additional functionality that is helpful for rules to do their jobs. As the name implies, the `context` object contains information that is relevant to the context of the rule. The `context` object has the following properties: -* `parserOptions` - the parser options configured for this run (more details [here](../user-guide/configuring/language-options.md#specifying-parser-options)). +* `parserOptions` - the parser options configured for this run (more details [here](../user-guide/configuring/language-options#specifying-parser-options)). * `id` - the rule ID. * `options` - an array of rule options. * `settings` - the `settings` from configuration. @@ -87,7 +92,7 @@ Additionally, the `context` object has the following methods: * `getFilename()` - returns the filename associated with the source. * `getScope()` - returns the current scope. * `getSourceCode()` - returns a `SourceCode` object that you can use to work with the source that was passed to ESLint -* `markVariableAsUsed(name)` - marks the named variable in scope as used. This affects the [no-unused-vars](../rules/no-unused-vars.md) rule. +* `markVariableAsUsed(name)` - marks the named variable in scope as used. This affects the [no-unused-vars](../rules/no-unused-vars) rule. * `report(descriptor)` - reports a problem in the code. **Deprecated:** The following methods on the `context` object are deprecated. Please use the corresponding methods on `SourceCode` instead: @@ -324,7 +329,7 @@ Keep in mind that comments are technically not a part of the AST and are only at ESLint analyzes code paths while traversing AST. You can access that code path objects with five events related to code paths. -[details here](./code-path-analysis.md) +[details here](./code-path-analysis) ## Rule Unit Tests @@ -478,7 +483,7 @@ valid: [ ] ``` -The options available and the expected syntax for `parserOptions` is the same as those used in [configuration](../user-guide/configuring/language-options.md#specifying-parser-options). +The options available and the expected syntax for `parserOptions` is the same as those used in [configuration](../user-guide/configuring/language-options#specifying-parser-options). ### Write Several Tests @@ -574,4 +579,4 @@ Runtime rules are written in the same format as all other rules. Create your rul 1. Place all of your runtime rules in the same directory (i.e., `eslint_rules`). 2. Create a [configuration file](../user-guide/configuring/) and specify your rule ID error level under the `rules` key. Your rule will not run unless it has a value of `1` or `2` in the configuration file. -3. Run the [command line interface](../user-guide/command-line-interface.md) using the `--rulesdir` option to specify the location of your runtime rules. +3. Run the [command line interface](../user-guide/command-line-interface) using the `--rulesdir` option to specify the location of your runtime rules. diff --git a/docs/src/developer-guide/working-with-rules.md b/docs/src/developer-guide/working-with-rules.md index 697b7ed8bff..f1330ac1296 100644 --- a/docs/src/developer-guide/working-with-rules.md +++ b/docs/src/developer-guide/working-with-rules.md @@ -1,12 +1,17 @@ -# Working with Rules +--- +title: Working with Rules +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/developer-guide/working-with-rules.md -**Note:** This page covers the most recent rule format for ESLint >= 3.0.0. There is also a [deprecated rule format](./working-with-rules-deprecated.md). +--- + +**Note:** This page covers the most recent rule format for ESLint >= 3.0.0. There is also a [deprecated rule format](./working-with-rules-deprecated). Each rule in ESLint has three files named with its identifier (for example, `no-extra-semi`). * in the `lib/rules` directory: a source file (for example, `no-extra-semi.js`) * in the `tests/lib/rules` directory: a test file (for example, `no-extra-semi.js`) -* in the `docs/rules` directory: a Markdown documentation file (for example, `no-extra-semi.md`) +* in the `docs/rules` directory: a Markdown documentation file (for example, `no-extra-semi`) **Important:** If you submit a **core** rule to the ESLint repository, you **must** follow some conventions explained below. @@ -61,12 +66,12 @@ The source file for a rule exports an object with the following properties. * `description` (string) provides the short description of the rule in the [rules index](../rules/) * `category` (string) specifies the heading under which the rule is listed in the [rules index](../rules/) - * `recommended` (boolean) is whether the `"extends": "eslint:recommended"` property in a [configuration file](../user-guide/configuring/configuration-files.md#extending-configuration-files) enables the rule + * `recommended` (boolean) is whether the `"extends": "eslint:recommended"` property in a [configuration file](../user-guide/configuring/configuration-files#extending-configuration-files) enables the rule * `url` (string) specifies the URL at which the full documentation can be accessed (enabling code editors to provide a helpful link on highlighted rule violations) In a custom rule or plugin, you can omit `docs` or include any properties that you need in it. -* `fixable` (string) is either `"code"` or `"whitespace"` if the `--fix` option on the [command line](../user-guide/command-line-interface.md#--fix) automatically fixes problems reported by the rule +* `fixable` (string) is either `"code"` or `"whitespace"` if the `--fix` option on the [command line](../user-guide/command-line-interface#--fix) automatically fixes problems reported by the rule **Important:** the `fixable` property is mandatory for fixable rules. If this property isn't specified, ESLint will throw an error whenever the rule attempts to produce a fix. Omit the `fixable` property if the rule is not fixable. @@ -74,7 +79,7 @@ The source file for a rule exports an object with the following properties. **Important:** the `hasSuggestions` property is mandatory for rules that provide suggestions. If this property isn't set to `true`, ESLint will throw an error whenever the rule attempts to produce a suggestion. Omit the `hasSuggestions` property if the rule does not provide suggestions. -* `schema` (array) specifies the [options](#options-schemas) so ESLint can prevent invalid [rule configurations](../user-guide/configuring/rules.md#configuring-rules) +* `schema` (array) specifies the [options](#options-schemas) so ESLint can prevent invalid [rule configurations](../user-guide/configuring/rules#configuring-rules) * `deprecated` (boolean) indicates whether the rule has been deprecated. You may omit the `deprecated` property if the rule has not been deprecated. @@ -82,13 +87,13 @@ The source file for a rule exports an object with the following properties. `create` (function) returns an object with methods that ESLint calls to "visit" nodes while traversing the abstract syntax tree (AST as defined by [ESTree](https://github.com/estree/estree)) of JavaScript code: -* if a key is a node type or a [selector](./selectors.md), ESLint calls that **visitor** function while going **down** the tree -* if a key is a node type or a [selector](./selectors.md) plus `:exit`, ESLint calls that **visitor** function while going **up** the tree -* if a key is an event name, ESLint calls that **handler** function for [code path analysis](./code-path-analysis.md) +* if a key is a node type or a [selector](./selectors), ESLint calls that **visitor** function while going **down** the tree +* if a key is a node type or a [selector](./selectors) plus `:exit`, ESLint calls that **visitor** function while going **up** the tree +* if a key is an event name, ESLint calls that **handler** function for [code path analysis](./code-path-analysis) A rule can use the current node and its surrounding tree to report or fix problems. -Here are methods for the [array-callback-return](../rules/array-callback-return.md) rule: +Here are methods for the [array-callback-return](../rules/array-callback-return) rule: ```js function checkLastSegment (node) { @@ -121,18 +126,18 @@ module.exports = { The `context` object contains additional functionality that is helpful for rules to do their jobs. As the name implies, the `context` object contains information that is relevant to the context of the rule. The `context` object has the following properties: -* `parserOptions` - the parser options configured for this run (more details [here](../user-guide/configuring/language-options.md#specifying-parser-options)). +* `parserOptions` - the parser options configured for this run (more details [here](../user-guide/configuring/language-options#specifying-parser-options)). * `id` - the rule ID. -* `options` - an array of the [configured options](/docs/user-guide/configuring/rules.md#configuring-rules) for this rule. This array does not include the rule severity. For more information, see [here](#contextoptions). -* `settings` - the [shared settings](/docs/user-guide/configuring/configuration-files.md#adding-shared-settings) from configuration. +* `options` - an array of the [configured options](/docs/user-guide/configuring/rules#configuring-rules) for this rule. This array does not include the rule severity. For more information, see [here](#contextoptions). +* `settings` - the [shared settings](/docs/user-guide/configuring/configuration-files#adding-shared-settings) from configuration. * `parserPath` - the name of the `parser` from configuration. * `parserServices` - an object containing parser-provided services for rules. The default parser does not provide any services. However, if a rule is intended to be used with a custom parser, it could use `parserServices` to access anything provided by that parser. (For example, a TypeScript parser could provide the ability to get the computed type of a given node.) Additionally, the `context` object has the following methods: * `getAncestors()` - returns an array of the ancestors of the currently-traversed node, starting at the root of the AST and continuing through the direct parent of the current node. This array does not include the currently-traversed node itself. -* `getCwd()` - returns the `cwd` passed to [Linter](./nodejs-api.md#linter). It is a path to a directory that should be considered as the current working directory. -* `getDeclaredVariables(node)` - returns a list of [variables](./scope-manager-interface.md#variable-interface) declared by the given node. This information can be used to track references to variables. +* `getCwd()` - returns the `cwd` passed to [Linter](./nodejs-api#linter). It is a path to a directory that should be considered as the current working directory. +* `getDeclaredVariables(node)` - returns a list of [variables](./scope-manager-interface#variable-interface) declared by the given node. This information can be used to track references to variables. * If the node is a `VariableDeclaration`, all variables declared in the declaration are returned. * If the node is a `VariableDeclarator`, all variables declared in the declarator are returned. * If the node is a `FunctionDeclaration` or `FunctionExpression`, the variable for the function name is returned, in addition to variables for the function parameters. @@ -144,9 +149,9 @@ Additionally, the `context` object has the following methods: * Otherwise, if the node does not declare any variables, an empty array is returned. * `getFilename()` - returns the filename associated with the source. * `getPhysicalFilename()` - when linting a file, it returns the full path of the file on disk without any code block information. When linting text, it returns the value passed to `—stdin-filename` or `` if not specified. -* `getScope()` - returns the [scope](./scope-manager-interface.md#scope-interface) of the currently-traversed node. This information can be used to track references to variables. +* `getScope()` - returns the [scope](./scope-manager-interface#scope-interface) of the currently-traversed node. This information can be used to track references to variables. * `getSourceCode()` - returns a [`SourceCode`](#contextgetsourcecode) object that you can use to work with the source that was passed to ESLint. -* `markVariableAsUsed(name)` - marks a variable with the given name in the current scope as used. This affects the [no-unused-vars](../rules/no-unused-vars.md) rule. Returns `true` if a variable with the given name was found and marked as used, otherwise `false`. +* `markVariableAsUsed(name)` - marks a variable with the given name in the current scope as used. This affects the [no-unused-vars](../rules/no-unused-vars) rule. Returns `true` if a variable with the given name was found and marked as used, otherwise `false`. * `report(descriptor)` - reports a problem in the code (see the [dedicated section](#contextreport)). **Note:** Earlier versions of ESLint supported additional methods on the `context` object. Those methods were removed in the new format and should not be relied upon. @@ -176,7 +181,7 @@ This method returns the scope which has the following types: **※2** Only if the `for` statement defines the iteration variable as a block-scoped variable (E.g., `for (let i = 0;;) {}`).
**※3** The scope of the closest ancestor node which has own scope. If the closest ancestor node has multiple scopes then it chooses the innermost scope (E.g., the `Program` node has a `global` scope and a `module` scope if `Program#sourceType` is `"module"`. The innermost scope is the `module` scope.). -The returned value is a [`Scope` object](scope-manager-interface.md) defined by the `eslint-scope` package. The `Variable` objects of global variables have some additional properties. +The returned value is a [`Scope` object](scope-manager-interface) defined by the `eslint-scope` package. The `Variable` objects of global variables have some additional properties. * `variable.writeable` (`boolean | undefined`) ... If `true`, this global variable can be assigned arbitrary value. If `false`, this global variable is read-only. * `variable.eslintExplicitGlobal` (`boolean | undefined`) ... If `true`, this global variable was defined by a `/* globals */` directive comment in the source code file. @@ -350,7 +355,7 @@ Best practices for fixes: ({ "foo": 1 }) ``` - * This fixer can just select a quote type arbitrarily. If it guesses wrong, the resulting code will be automatically reported and fixed by the [`quotes`](/docs/rules/quotes.md) rule. + * This fixer can just select a quote type arbitrarily. If it guesses wrong, the resulting code will be automatically reported and fixed by the [`quotes`](/docs/rules/quotes) rule. Note: Making fixes as small as possible is a best practice, but in some cases it may be correct to extend the range of the fix in order to intentionally prevent other rules from making fixes in a surrounding range in the same pass. For instance, if replacement text declares a new variable, it can be useful to prevent other changes in the scope of the variable as they might cause name collisions. @@ -579,7 +584,7 @@ There are also some properties you can access: * `hasBOM` - the flag to indicate whether or not the source code has Unicode BOM. * `text` - the full text of the code being linted. Unicode BOM has been stripped from this text. * `ast` - the `Program` node of the AST for the code being linted. -* `scopeManager` - the [ScopeManager](./scope-manager-interface.md#scopemanager-interface) object of the code. +* `scopeManager` - the [ScopeManager](./scope-manager-interface#scopemanager-interface) object of the code. * `visitorKeys` - the visitor keys to traverse this AST. * `lines` - an array of lines, split according to the specification's definition of line breaks. @@ -678,13 +683,13 @@ Shebangs are represented by tokens of type `"Shebang"`. They are treated as comm ESLint analyzes code paths while traversing AST. You can access that code path objects with five events related to code paths. -[details here](./code-path-analysis.md) +[details here](./code-path-analysis) ## Rule Unit Tests Each bundled rule for ESLint core must have a set of unit tests submitted with it to be accepted. The test file is named the same as the source file but lives in `tests/lib/`. For example, if the rule source file is `lib/rules/foo.js` then the test file should be `tests/lib/rules/foo.js`. -ESLint provides the [`RuleTester`](/docs/developer-guide/nodejs-api.md#ruletester) utility to make it easy to write tests for rules. +ESLint provides the [`RuleTester`](/docs/developer-guide/nodejs-api#ruletester) utility to make it easy to write tests for rules. ## Performance Testing @@ -767,4 +772,4 @@ Runtime rules are written in the same format as all other rules. Create your rul 1. Place all of your runtime rules in the same directory (e.g., `eslint_rules`). 2. Create a [configuration file](../user-guide/configuring/) and specify your rule ID error level under the `rules` key. Your rule will not run unless it has a value of `"warn"` or `"error"` in the configuration file. -3. Run the [command line interface](../user-guide/command-line-interface.md) using the `--rulesdir` option to specify the location of your runtime rules. +3. Run the [command line interface](../user-guide/command-line-interface) using the `--rulesdir` option to specify the location of your runtime rules. diff --git a/docs/src/maintainer-guide/README.md b/docs/src/maintainer-guide/README.md index 941ad55994b..52ed8a9e5c4 100644 --- a/docs/src/maintainer-guide/README.md +++ b/docs/src/maintainer-guide/README.md @@ -1,23 +1,28 @@ -# Maintainer Guide +--- +title: Maintainer Guide +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/maintainer-guide/README.md + +--- This guide is intended for those who work as part of the ESLint project team. -## [Managing Issues](issues.md) +## [Managing Issues](issues) Describes how to deal with issues when they're opened, when interacting with users, and how to close them effectively. -## [Reviewing Pull Requests](pullrequests.md) +## [Reviewing Pull Requests](pullrequests) Describes how to review incoming pull requests. -## [Managing Releases](releases.md) +## [Managing Releases](releases) Describes how to do an ESLint project release. -## [Governance](governance.md) +## [Governance](governance) Describes the governance policy for ESLint, including the rights and privileges of individuals inside the project. -## [Working Groups](working-groups.md) +## [Working Groups](working-groups) Describes how working groups are created and how they function within the ESLint project. diff --git a/docs/src/maintainer-guide/governance.md b/docs/src/maintainer-guide/governance.md index 2c754113739..5ce0c3fa57a 100644 --- a/docs/src/maintainer-guide/governance.md +++ b/docs/src/maintainer-guide/governance.md @@ -1,4 +1,9 @@ -# Governance +--- +title: Governance +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/maintainer-guide/governance.md + +--- ESLint is an open source project that depends on contributions from the community. Anyone may contribute to the project at any time by submitting code, participating in discussions, making suggestions, or any other contribution they see fit. This document describes how various types of contributors work within the ESLint project. diff --git a/docs/src/maintainer-guide/issues.md b/docs/src/maintainer-guide/issues.md index 2624a4bda08..17d072cb27b 100644 --- a/docs/src/maintainer-guide/issues.md +++ b/docs/src/maintainer-guide/issues.md @@ -1,4 +1,9 @@ -# Managing Issues +--- +title: Managing Issues +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/maintainer-guide/issues.md + +--- New issues are filed frequently, and how we respond to those issues directly affects the success of the project. Being part of the project team means helping to triage and address issues as they come in so the project can continue to run smoothly. diff --git a/docs/src/maintainer-guide/pullrequests.md b/docs/src/maintainer-guide/pullrequests.md index 2d3b13bf0d9..719c8dc013c 100644 --- a/docs/src/maintainer-guide/pullrequests.md +++ b/docs/src/maintainer-guide/pullrequests.md @@ -1,4 +1,9 @@ -# Reviewing Pull Requests +--- +title: Reviewing Pull Requests +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/maintainer-guide/pullrequests.md + +--- Pull requests are submitted frequently and represent our best opportunity to interact with the community. As such, it's important that pull requests are well-reviewed before being merged and that interactions on pull requests are positive. diff --git a/docs/src/maintainer-guide/releases.md b/docs/src/maintainer-guide/releases.md index d406475bed3..5b8cdfbb4f0 100644 --- a/docs/src/maintainer-guide/releases.md +++ b/docs/src/maintainer-guide/releases.md @@ -1,4 +1,9 @@ -# Managing Releases +--- +title: Managing Releases +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/maintainer-guide/releases.md + +--- Releases are when a project formally publishes a new version so the community can use it. There are two types of releases: diff --git a/docs/src/maintainer-guide/working-groups.md b/docs/src/maintainer-guide/working-groups.md index d6d22fb6c20..1f6d43a675d 100644 --- a/docs/src/maintainer-guide/working-groups.md +++ b/docs/src/maintainer-guide/working-groups.md @@ -1,4 +1,9 @@ -# Working Groups +--- +title: Working Groups +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/maintainer-guide/working-groups.md + +--- The ESLint TSC may form working groups to focus on a specific area of the project. diff --git a/docs/src/pages/index.md b/docs/src/pages/index.md index 8f5223a74d8..fa9f617f177 100644 --- a/docs/src/pages/index.md +++ b/docs/src/pages/index.md @@ -1,4 +1,8 @@ -# Documentation +--- +title: Documentation +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/pages/index.md +--- Welcome to our documentation pages! What would you like to view? diff --git a/docs/src/rules/accessor-pairs.md b/docs/src/rules/accessor-pairs.md index 03adbd58e74..b5d5ece3d13 100644 --- a/docs/src/rules/accessor-pairs.md +++ b/docs/src/rules/accessor-pairs.md @@ -1,4 +1,9 @@ -# accessor-pairs +--- +title: accessor-pairs +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/accessor-pairs.md +rule_type: suggestion +--- Enforces getter/setter pairs in objects and classes. @@ -275,9 +280,9 @@ var o = { The code above creates an object with just a setter for the property `"a"`. -See [no-dupe-keys](no-dupe-keys.md) if you also want to disallow duplicate keys in object literals. +See [no-dupe-keys](no-dupe-keys) if you also want to disallow duplicate keys in object literals. -See [no-dupe-class-members](no-dupe-class-members.md) if you also want to disallow duplicate names in class definitions. +See [no-dupe-class-members](no-dupe-class-members) if you also want to disallow duplicate names in class definitions. ## When Not To Use It @@ -285,8 +290,8 @@ You can turn this rule off if you are not concerned with the simultaneous presen ## Related Rules -* [no-dupe-keys](no-dupe-keys.md) -* [no-dupe-class-members](no-dupe-class-members.md) +* [no-dupe-keys](no-dupe-keys) +* [no-dupe-class-members](no-dupe-class-members) ## Further Reading diff --git a/docs/src/rules/array-bracket-newline.md b/docs/src/rules/array-bracket-newline.md index cdcc07b12a1..54be1569819 100644 --- a/docs/src/rules/array-bracket-newline.md +++ b/docs/src/rules/array-bracket-newline.md @@ -1,4 +1,11 @@ -# array-bracket-newline +--- +title: array-bracket-newline +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/array-bracket-newline.md +rule_type: layout +--- + + Enforces line breaks after opening and before closing array brackets. @@ -275,7 +282,7 @@ If you don't want to enforce line breaks after opening and before closing array ## Related Rules -* [array-bracket-spacing](array-bracket-spacing.md) +* [array-bracket-spacing](array-bracket-spacing) ## Compatibility diff --git a/docs/src/rules/array-bracket-spacing.md b/docs/src/rules/array-bracket-spacing.md index 0c2659d716c..825557f070a 100644 --- a/docs/src/rules/array-bracket-spacing.md +++ b/docs/src/rules/array-bracket-spacing.md @@ -1,4 +1,11 @@ -# array-bracket-spacing +--- +title: array-bracket-spacing +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/array-bracket-spacing.md +rule_type: layout +--- + + Disallows or enforce spaces inside of brackets. @@ -220,6 +227,6 @@ You can turn this rule off if you are not concerned with the consistency of spac ## Related Rules -* [space-in-parens](space-in-parens.md) -* [object-curly-spacing](object-curly-spacing.md) -* [computed-property-spacing](computed-property-spacing.md) +* [space-in-parens](space-in-parens) +* [object-curly-spacing](object-curly-spacing) +* [computed-property-spacing](computed-property-spacing) diff --git a/docs/src/rules/array-callback-return.md b/docs/src/rules/array-callback-return.md index 264d16be1b5..a269a53b5f3 100644 --- a/docs/src/rules/array-callback-return.md +++ b/docs/src/rules/array-callback-return.md @@ -1,4 +1,9 @@ -# array-callback-return +--- +title: array-callback-return +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/array-callback-return.md +rule_type: problem +--- Enforces return statements in callbacks of array's methods. diff --git a/docs/src/rules/array-element-newline.md b/docs/src/rules/array-element-newline.md index 9c99fb7881d..66db0024834 100644 --- a/docs/src/rules/array-element-newline.md +++ b/docs/src/rules/array-element-newline.md @@ -1,4 +1,11 @@ -# array-element-newline +--- +title: array-element-newline +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/array-element-newline.md +rule_type: layout +--- + + Enforces line breaks between array elements. @@ -378,14 +385,14 @@ If you don't want to enforce linebreaks between array elements, don't enable thi ## Related Rules -* [array-bracket-spacing](array-bracket-spacing.md) -* [array-bracket-newline](array-bracket-newline.md) -* [object-property-newline](object-property-newline.md) -* [object-curly-spacing](object-curly-spacing.md) -* [object-curly-newline](object-curly-newline.md) -* [max-statements-per-line](max-statements-per-line.md) -* [block-spacing](block-spacing.md) -* [brace-style](brace-style.md) +* [array-bracket-spacing](array-bracket-spacing) +* [array-bracket-newline](array-bracket-newline) +* [object-property-newline](object-property-newline) +* [object-curly-spacing](object-curly-spacing) +* [object-curly-newline](object-curly-newline) +* [max-statements-per-line](max-statements-per-line) +* [block-spacing](block-spacing) +* [brace-style](brace-style) ## Compatibility diff --git a/docs/src/rules/arrow-body-style.md b/docs/src/rules/arrow-body-style.md index f257ccaec1d..68876696fce 100644 --- a/docs/src/rules/arrow-body-style.md +++ b/docs/src/rules/arrow-body-style.md @@ -1,4 +1,11 @@ -# arrow-body-style +--- +title: arrow-body-style +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/arrow-body-style.md +rule_type: suggestion +--- + + Requires braces in arrow function bodies. diff --git a/docs/src/rules/arrow-parens.md b/docs/src/rules/arrow-parens.md index c8068742939..856bcb8f8ee 100644 --- a/docs/src/rules/arrow-parens.md +++ b/docs/src/rules/arrow-parens.md @@ -1,4 +1,11 @@ -# arrow-parens +--- +title: arrow-parens +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/arrow-parens.md +rule_type: layout +--- + + Requires parens in arrow function arguments. diff --git a/docs/src/rules/arrow-spacing.md b/docs/src/rules/arrow-spacing.md index 27f49397539..c6453d11e6d 100644 --- a/docs/src/rules/arrow-spacing.md +++ b/docs/src/rules/arrow-spacing.md @@ -1,4 +1,11 @@ -# arrow-spacing +--- +title: arrow-spacing +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/arrow-spacing.md +rule_type: layout +--- + + Requires space before/after arrow function's arrow. diff --git a/docs/src/rules/block-scoped-var.md b/docs/src/rules/block-scoped-var.md index 412da19ea6a..e23310547d0 100644 --- a/docs/src/rules/block-scoped-var.md +++ b/docs/src/rules/block-scoped-var.md @@ -1,4 +1,9 @@ -# block-scoped-var +--- +title: block-scoped-var +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/block-scoped-var.md +rule_type: suggestion +--- Enforces treating `var` as block scoped. diff --git a/docs/src/rules/block-spacing.md b/docs/src/rules/block-spacing.md index 663a99d5427..e07b7652dcb 100644 --- a/docs/src/rules/block-spacing.md +++ b/docs/src/rules/block-spacing.md @@ -1,4 +1,11 @@ -# block-spacing +--- +title: block-spacing +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/block-spacing.md +rule_type: layout +--- + + Disallows or enforces spaces inside of blocks after opening blocks and before closing blocks. @@ -78,5 +85,5 @@ If you don't want to be notified about spacing style inside of blocks, you can s ## Related Rules -* [space-before-blocks](space-before-blocks.md) -* [brace-style](brace-style.md) +* [space-before-blocks](space-before-blocks) +* [brace-style](brace-style) diff --git a/docs/src/rules/brace-style.md b/docs/src/rules/brace-style.md index 0c5502abb5c..6b69184fd19 100644 --- a/docs/src/rules/brace-style.md +++ b/docs/src/rules/brace-style.md @@ -1,4 +1,11 @@ -# brace-style +--- +title: brace-style +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/brace-style.md +rule_type: layout +--- + + Enforces consistent brace style for blocks. @@ -388,8 +395,8 @@ If you don't want to enforce a particular brace style, don't enable this rule. ## Related Rules -* [block-spacing](block-spacing.md) -* [space-before-blocks](space-before-blocks.md) +* [block-spacing](block-spacing) +* [space-before-blocks](space-before-blocks) ## Further Reading diff --git a/docs/src/rules/callback-return.md b/docs/src/rules/callback-return.md index d375e37d39e..7acf5dc9c67 100644 --- a/docs/src/rules/callback-return.md +++ b/docs/src/rules/callback-return.md @@ -1,4 +1,9 @@ -# callback-return +--- +title: callback-return +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/callback-return.md +rule_type: suggestion +--- Enforces return after callback. @@ -169,7 +174,7 @@ There are some cases where you might want to call a callback function more than ## Related Rules -* [handle-callback-err](handle-callback-err.md) +* [handle-callback-err](handle-callback-err) ## Further Reading diff --git a/docs/src/rules/camelcase.md b/docs/src/rules/camelcase.md index a79ef401261..83843c34bd2 100644 --- a/docs/src/rules/camelcase.md +++ b/docs/src/rules/camelcase.md @@ -1,4 +1,9 @@ -# camelcase +--- +title: camelcase +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/camelcase.md +rule_type: suggestion +--- Enforces camelcase naming convention. diff --git a/docs/src/rules/capitalized-comments.md b/docs/src/rules/capitalized-comments.md index 4de1556f5fe..601de8864e2 100644 --- a/docs/src/rules/capitalized-comments.md +++ b/docs/src/rules/capitalized-comments.md @@ -1,4 +1,11 @@ -# capitalized-comments +--- +title: capitalized-comments +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/capitalized-comments.md +rule_type: suggestion +--- + + Enforces or disallows capitalization of the first letter of a comment. diff --git a/docs/src/rules/class-methods-use-this.md b/docs/src/rules/class-methods-use-this.md index 663ed65bbea..350e0f7c3d0 100644 --- a/docs/src/rules/class-methods-use-this.md +++ b/docs/src/rules/class-methods-use-this.md @@ -1,4 +1,9 @@ -# class-methods-use-this +--- +title: class-methods-use-this +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/class-methods-use-this.md +rule_type: suggestion +--- Enforces that class methods utilize `this`. diff --git a/docs/src/rules/comma-dangle.md b/docs/src/rules/comma-dangle.md index f215b70dbc0..a40f1cb76ca 100644 --- a/docs/src/rules/comma-dangle.md +++ b/docs/src/rules/comma-dangle.md @@ -1,4 +1,11 @@ -# comma-dangle +--- +title: comma-dangle +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/comma-dangle.md +rule_type: layout +--- + + Requires or disallows trailing commas. diff --git a/docs/src/rules/comma-spacing.md b/docs/src/rules/comma-spacing.md index d7566aee431..2463c9bb9e8 100644 --- a/docs/src/rules/comma-spacing.md +++ b/docs/src/rules/comma-spacing.md @@ -1,4 +1,11 @@ -# comma-spacing +--- +title: comma-spacing +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/comma-spacing.md +rule_type: layout +--- + + Enforces spacing around commas. @@ -16,7 +23,7 @@ This rule enforces consistent spacing before and after commas in variable declar This rule does not apply in an `ArrayExpression` or `ArrayPattern` in either of the following cases: * adjacent null elements -* an initial null element, to avoid conflicts with the [`array-bracket-spacing`](array-bracket-spacing.md) rule +* an initial null element, to avoid conflicts with the [`array-bracket-spacing`](array-bracket-spacing) rule ## Options @@ -114,14 +121,14 @@ If your project will not be following a consistent comma-spacing pattern, turn t ## Related Rules -* [array-bracket-spacing](array-bracket-spacing.md) -* [comma-style](comma-style.md) -* [space-in-brackets](space-in-brackets.md) (deprecated) -* [space-in-parens](space-in-parens.md) -* [space-infix-ops](space-infix-ops.md) -* [space-after-keywords](space-after-keywords.md) -* [space-unary-ops](space-unary-ops.md) -* [space-return-throw-case](space-return-throw-case.md) +* [array-bracket-spacing](array-bracket-spacing) +* [comma-style](comma-style) +* [space-in-brackets](space-in-brackets) (deprecated) +* [space-in-parens](space-in-parens) +* [space-infix-ops](space-infix-ops) +* [space-after-keywords](space-after-keywords) +* [space-unary-ops](space-unary-ops) +* [space-return-throw-case](space-return-throw-case) ## Further Reading diff --git a/docs/src/rules/comma-style.md b/docs/src/rules/comma-style.md index 75419a3ac23..4ce1979c974 100644 --- a/docs/src/rules/comma-style.md +++ b/docs/src/rules/comma-style.md @@ -1,4 +1,11 @@ -# comma-style +--- +title: comma-style +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/comma-style.md +rule_type: layout +--- + + Enforces consistent comma styles. @@ -161,7 +168,7 @@ This rule can safely be turned off if your project does not care about enforcing ## Related Rules -* [operator-linebreak](operator-linebreak.md) +* [operator-linebreak](operator-linebreak) ## Further Reading diff --git a/docs/src/rules/complexity.md b/docs/src/rules/complexity.md index a993aec00e8..16a2e05651b 100644 --- a/docs/src/rules/complexity.md +++ b/docs/src/rules/complexity.md @@ -1,4 +1,9 @@ -# complexity +--- +title: complexity +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/complexity.md +rule_type: suggestion +--- Enforces a maximum cyclomatic complexity. @@ -128,13 +133,13 @@ If you can't determine an appropriate complexity limit for your code, then it's ## Related Rules -* [max-depth](max-depth.md) -* [max-len](max-len.md) -* [max-lines](max-lines.md) -* [max-lines-per-function](max-lines-per-function.md) -* [max-nested-callbacks](max-nested-callbacks.md) -* [max-params](max-params.md) -* [max-statements](max-statements.md) +* [max-depth](max-depth) +* [max-len](max-len) +* [max-lines](max-lines) +* [max-lines-per-function](max-lines-per-function) +* [max-nested-callbacks](max-nested-callbacks) +* [max-params](max-params) +* [max-statements](max-statements) ## Further Reading diff --git a/docs/src/rules/computed-property-spacing.md b/docs/src/rules/computed-property-spacing.md index beae783941a..f9f97f4993e 100644 --- a/docs/src/rules/computed-property-spacing.md +++ b/docs/src/rules/computed-property-spacing.md @@ -1,4 +1,11 @@ -# computed-property-spacing +--- +title: computed-property-spacing +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/computed-property-spacing.md +rule_type: layout +--- + + Disallows or enforces spaces inside of computed properties. @@ -176,6 +183,6 @@ You can turn this rule off if you are not concerned with the consistency of comp ## Related Rules -* [array-bracket-spacing](array-bracket-spacing.md) -* [comma-spacing](comma-spacing.md) -* [space-in-parens](space-in-parens.md) +* [array-bracket-spacing](array-bracket-spacing) +* [comma-spacing](comma-spacing) +* [space-in-parens](space-in-parens) diff --git a/docs/src/rules/consistent-return.md b/docs/src/rules/consistent-return.md index 8028b7af001..76cf86f0ba2 100644 --- a/docs/src/rules/consistent-return.md +++ b/docs/src/rules/consistent-return.md @@ -1,4 +1,9 @@ -# consistent-return +--- +title: consistent-return +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/consistent-return.md +rule_type: suggestion +--- Requires `return` statements to either always or never specify values. diff --git a/docs/src/rules/consistent-this.md b/docs/src/rules/consistent-this.md index 46d5ecf2c7a..18ff87ea1eb 100644 --- a/docs/src/rules/consistent-this.md +++ b/docs/src/rules/consistent-this.md @@ -1,4 +1,9 @@ -# consistent-this +--- +title: consistent-this +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/consistent-this.md +rule_type: suggestion +--- Enforces consistent naming when capturing the current execution context. diff --git a/docs/src/rules/constructor-super.md b/docs/src/rules/constructor-super.md index 80471e3dfc7..c6510372b4f 100644 --- a/docs/src/rules/constructor-super.md +++ b/docs/src/rules/constructor-super.md @@ -1,4 +1,11 @@ -# constructor-super +--- +title: constructor-super +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/constructor-super.md +rule_type: problem +--- + + Verifies calls of `super()` in constructors. diff --git a/docs/src/rules/curly.md b/docs/src/rules/curly.md index 6eb76071f9b..e7f7dd0b1a8 100644 --- a/docs/src/rules/curly.md +++ b/docs/src/rules/curly.md @@ -1,4 +1,11 @@ -# curly +--- +title: curly +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/curly.md +rule_type: suggestion +--- + + Requires following curly brace conventions. diff --git a/docs/src/rules/default-case-last.md b/docs/src/rules/default-case-last.md index e626715854a..a75b1ebbb71 100644 --- a/docs/src/rules/default-case-last.md +++ b/docs/src/rules/default-case-last.md @@ -1,4 +1,9 @@ -# default-case-last +--- +title: default-case-last +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/default-case-last.md +rule_type: suggestion +--- Enforces default clauses in switch statements to be last. @@ -16,7 +21,7 @@ This rule enforces `default` clauses in `switch` statements to be last. It applies only to `switch` statements that already have a `default` clause. -This rule does not enforce the existence of `default` clauses. See [default-case](default-case.md) if you also want to enforce the existence of `default` clauses in `switch` statements. +This rule does not enforce the existence of `default` clauses. See [default-case](default-case) if you also want to enforce the existence of `default` clauses in `switch` statements. Examples of **incorrect** code for this rule: @@ -120,7 +125,7 @@ doSomethingAnyway(); ## Related Rules -* [default-case](default-case.md) +* [default-case](default-case) ## Further Reading diff --git a/docs/src/rules/default-case.md b/docs/src/rules/default-case.md index d6d2110f7f3..9e389ca2ffa 100644 --- a/docs/src/rules/default-case.md +++ b/docs/src/rules/default-case.md @@ -1,4 +1,9 @@ -# default-case +--- +title: default-case +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/default-case.md +rule_type: suggestion +--- Requires a `default` case in switch statements. @@ -71,7 +76,6 @@ switch (a) { break; } - switch (a) { case 1: /* code */ @@ -125,4 +129,4 @@ If you don't want to enforce a `default` case for `switch` statements, you can s ## Related Rules -* [no-fallthrough](no-fallthrough.md) +* [no-fallthrough](no-fallthrough) diff --git a/docs/src/rules/default-param-last.md b/docs/src/rules/default-param-last.md index 3944d27bbb3..a2eea8ea37a 100644 --- a/docs/src/rules/default-param-last.md +++ b/docs/src/rules/default-param-last.md @@ -1,4 +1,9 @@ -# default-param-last +--- +title: default-param-last +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/default-param-last.md +rule_type: suggestion +--- Enforces default parameters to be last. diff --git a/docs/src/rules/dot-location.md b/docs/src/rules/dot-location.md index b8285664b26..2193e6745db 100644 --- a/docs/src/rules/dot-location.md +++ b/docs/src/rules/dot-location.md @@ -1,4 +1,11 @@ -# dot-location +--- +title: dot-location +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/dot-location.md +rule_type: layout +--- + + Enforces newline before and after dots. @@ -83,5 +90,5 @@ You can turn this rule off if you are not concerned with the consistency of newl ## Related Rules -* [newline-after-var](newline-after-var.md) -* [dot-notation](dot-notation.md) +* [newline-after-var](newline-after-var) +* [dot-notation](dot-notation) diff --git a/docs/src/rules/dot-notation.md b/docs/src/rules/dot-notation.md index 3495b0a4dc0..d386b4df4e6 100644 --- a/docs/src/rules/dot-notation.md +++ b/docs/src/rules/dot-notation.md @@ -1,4 +1,11 @@ -# dot-notation +--- +title: dot-notation +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/dot-notation.md +rule_type: suggestion +--- + + Enforces dot notation whenever possible. diff --git a/docs/src/rules/eol-last.md b/docs/src/rules/eol-last.md index 63fbee0a007..58d8955dd86 100644 --- a/docs/src/rules/eol-last.md +++ b/docs/src/rules/eol-last.md @@ -1,4 +1,11 @@ -# eol-last +--- +title: eol-last +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/eol-last.md +rule_type: layout +--- + + Requires or disallows newline at the end of files. @@ -13,8 +20,8 @@ of non-empty files. Prior to v0.16.0 this rule also enforced that there was only a single line at the end of the file. If you still want this behavior, consider enabling -[no-multiple-empty-lines](no-multiple-empty-lines.md) with `maxEOF` and/or -[no-trailing-spaces](no-trailing-spaces.md). +[no-multiple-empty-lines](no-multiple-empty-lines) with `maxEOF` and/or +[no-trailing-spaces](no-trailing-spaces). Examples of **incorrect** code for this rule: diff --git a/docs/src/rules/eqeqeq.md b/docs/src/rules/eqeqeq.md index ec6932957fe..6874896ada0 100644 --- a/docs/src/rules/eqeqeq.md +++ b/docs/src/rules/eqeqeq.md @@ -1,4 +1,11 @@ -# eqeqeq +--- +title: eqeqeq +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/eqeqeq.md +rule_type: suggestion +--- + + Requires the use of `===` and `!==`. diff --git a/docs/src/rules/for-direction.md b/docs/src/rules/for-direction.md index 6b0c68f4500..f349d2662b8 100644 --- a/docs/src/rules/for-direction.md +++ b/docs/src/rules/for-direction.md @@ -1,4 +1,11 @@ -# for-direction +--- +title: for-direction +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/for-direction.md +rule_type: problem +--- + + Enforces `for` loop update clause moving the counter in the right direction. diff --git a/docs/src/rules/func-call-spacing.md b/docs/src/rules/func-call-spacing.md index a5b2db9c619..775655aa957 100644 --- a/docs/src/rules/func-call-spacing.md +++ b/docs/src/rules/func-call-spacing.md @@ -1,4 +1,11 @@ -# func-call-spacing +--- +title: func-call-spacing +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/func-call-spacing.md +rule_type: layout +--- + + Requires or disallows spacing between function identifiers and their invocations. @@ -99,7 +106,7 @@ This rule can safely be turned off if your project does not care about enforcing ## Related Rules -* [no-spaced-func](no-spaced-func.md) (deprecated) +* [no-spaced-func](no-spaced-func) (deprecated) ## Compatibility diff --git a/docs/src/rules/func-name-matching.md b/docs/src/rules/func-name-matching.md index d1b85c926f6..21217c7140c 100644 --- a/docs/src/rules/func-name-matching.md +++ b/docs/src/rules/func-name-matching.md @@ -1,4 +1,9 @@ -# func-name-matching +--- +title: func-name-matching +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/func-name-matching.md +rule_type: suggestion +--- Requires function names to match the name of the variable or property to which they are assigned. diff --git a/docs/src/rules/func-names.md b/docs/src/rules/func-names.md index 48f3ba2e871..4c2e87caeae 100644 --- a/docs/src/rules/func-names.md +++ b/docs/src/rules/func-names.md @@ -1,4 +1,9 @@ -# func-names +--- +title: func-names +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/func-names.md +rule_type: suggestion +--- Requires or disallows named `function` expressions. diff --git a/docs/src/rules/func-style.md b/docs/src/rules/func-style.md index a157f499658..f2babc4c94f 100644 --- a/docs/src/rules/func-style.md +++ b/docs/src/rules/func-style.md @@ -1,4 +1,9 @@ -# func-style +--- +title: func-style +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/func-style.md +rule_type: suggestion +--- Enforces the consistent use of either `function` declarations or expressions. diff --git a/docs/src/rules/function-call-argument-newline.md b/docs/src/rules/function-call-argument-newline.md index 8e5bb17dae9..834eebc12e6 100644 --- a/docs/src/rules/function-call-argument-newline.md +++ b/docs/src/rules/function-call-argument-newline.md @@ -1,4 +1,11 @@ -# function-call-argument-newline +--- +title: function-call-argument-newline +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/function-call-argument-newline.md +rule_type: layout +--- + + Enforces line breaks between arguments of a function call. @@ -195,7 +202,7 @@ If you don't want to enforce line breaks between arguments, don't enable this ru ## Related Rules -* [function-paren-newline](function-paren-newline.md) -* [func-call-spacing](func-call-spacing.md) -* [object-property-newline](object-property-newline.md) -* [array-element-newline](array-element-newline.md) +* [function-paren-newline](function-paren-newline) +* [func-call-spacing](func-call-spacing) +* [object-property-newline](object-property-newline) +* [array-element-newline](array-element-newline) diff --git a/docs/src/rules/function-paren-newline.md b/docs/src/rules/function-paren-newline.md index 9447e957dad..3c3f04d569e 100644 --- a/docs/src/rules/function-paren-newline.md +++ b/docs/src/rules/function-paren-newline.md @@ -1,4 +1,11 @@ -# function-paren-newline +--- +title: function-paren-newline +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/function-paren-newline.md +rule_type: layout +--- + + Enforces consistent line breaks inside function parentheses. diff --git a/docs/src/rules/generator-star-spacing.md b/docs/src/rules/generator-star-spacing.md index e61ff04e824..f30cb587db9 100644 --- a/docs/src/rules/generator-star-spacing.md +++ b/docs/src/rules/generator-star-spacing.md @@ -1,4 +1,11 @@ -# generator-star-spacing +--- +title: generator-star-spacing +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/generator-star-spacing.md +rule_type: layout +--- + + Enforces spacing around the `*` in generator functions. diff --git a/docs/src/rules/generator-star.md b/docs/src/rules/generator-star.md index fd0af59395b..0cddfddd49e 100644 --- a/docs/src/rules/generator-star.md +++ b/docs/src/rules/generator-star.md @@ -1,8 +1,12 @@ -# generator-star +--- +title: generator-star +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/generator-star.md +--- Enforces consistent spacing around the asterisk in generator functions. -(removed) This rule was **removed** in ESLint v1.0 and **replaced** by the [generator-star-spacing](generator-star-spacing.md) rule. +(removed) This rule was **removed** in ESLint v1.0 and **replaced** by the [generator-star-spacing](generator-star-spacing) rule. Generators are a new type of function in ECMAScript 6 that can return multiple values over time. These special functions are indicated by placing an `*` after the `function` keyword. diff --git a/docs/src/rules/getter-return.md b/docs/src/rules/getter-return.md index 3d8d23594d1..55fc49cda3e 100644 --- a/docs/src/rules/getter-return.md +++ b/docs/src/rules/getter-return.md @@ -1,4 +1,11 @@ -# getter-return +--- +title: getter-return +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/getter-return.md +rule_type: problem +--- + + Enforces that a `return` statement is present in property getters. diff --git a/docs/src/rules/global-require.md b/docs/src/rules/global-require.md index 0312a91cb73..0650cb07eaf 100644 --- a/docs/src/rules/global-require.md +++ b/docs/src/rules/global-require.md @@ -1,4 +1,9 @@ -# global-require +--- +title: global-require +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/global-require.md +rule_type: suggestion +--- Enforces `require()` on the top-level module scope. diff --git a/docs/src/rules/global-strict.md b/docs/src/rules/global-strict.md index 4be8d7f960b..856b58d856d 100644 --- a/docs/src/rules/global-strict.md +++ b/docs/src/rules/global-strict.md @@ -1,8 +1,13 @@ -# global-strict +--- +title: global-strict +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/global-strict.md + +--- Requires or disallows strict mode directives in the global scope. -(removed) This rule was **removed** in ESLint v1.0 and **replaced** by the [strict](strict.md) rule. The `"global"` option in the new rule is most similar to the removed rule. +(removed) This rule was **removed** in ESLint v1.0 and **replaced** by the [strict](strict) rule. The `"global"` option in the new rule is most similar to the removed rule. Strict mode is enabled by using the following pragma in your code: diff --git a/docs/src/rules/grouped-accessor-pairs.md b/docs/src/rules/grouped-accessor-pairs.md index c46c18f6ee1..92dc21a2f84 100644 --- a/docs/src/rules/grouped-accessor-pairs.md +++ b/docs/src/rules/grouped-accessor-pairs.md @@ -1,4 +1,9 @@ -# grouped-accessor-pairs +--- +title: grouped-accessor-pairs +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/grouped-accessor-pairs.md +rule_type: suggestion +--- Requires grouped accessor pairs in object literals and classes. @@ -38,7 +43,7 @@ This rule requires grouped definitions of accessor functions for the same proper Optionally, this rule can also enforce consistent order (`getBeforeSet` or `setBeforeGet`). -This rule does not enforce the existence of the pair for a getter or a setter. See [accessor-pairs](accessor-pairs.md) if you also want to enforce getter/setter pairs. +This rule does not enforce the existence of the pair for a getter or a setter. See [accessor-pairs](accessor-pairs) if you also want to enforce getter/setter pairs. Examples of **incorrect** code for this rule: @@ -311,15 +316,15 @@ var bar = { Also, this rule does not report any warnings for properties that have duplicate getters or setters. -See [no-dupe-keys](no-dupe-keys.md) if you also want to disallow duplicate keys in object literals. +See [no-dupe-keys](no-dupe-keys) if you also want to disallow duplicate keys in object literals. -See [no-dupe-class-members](no-dupe-class-members.md) if you also want to disallow duplicate names in class definitions. +See [no-dupe-class-members](no-dupe-class-members) if you also want to disallow duplicate names in class definitions. ## Related Rules -* [accessor-pairs](accessor-pairs.md) -* [no-dupe-keys](no-dupe-keys.md) -* [no-dupe-class-members](no-dupe-class-members.md) +* [accessor-pairs](accessor-pairs) +* [no-dupe-keys](no-dupe-keys) +* [no-dupe-class-members](no-dupe-class-members) ## Further Reading diff --git a/docs/src/rules/guard-for-in.md b/docs/src/rules/guard-for-in.md index 36287a522a3..1a39d52214c 100644 --- a/docs/src/rules/guard-for-in.md +++ b/docs/src/rules/guard-for-in.md @@ -1,4 +1,9 @@ -# guard-for-in +--- +title: guard-for-in +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/guard-for-in.md +rule_type: suggestion +--- Requires `for in` loops to include an `if` statement. @@ -10,7 +15,7 @@ for (key in foo) { } ``` -Note that simply checking `foo.hasOwnProperty(key)` is likely to cause an error in some cases; see [no-prototype-builtins](no-prototype-builtins.md). +Note that simply checking `foo.hasOwnProperty(key)` is likely to cause an error in some cases; see [no-prototype-builtins](no-prototype-builtins). ## Rule Details @@ -46,7 +51,7 @@ for (key in foo) { ## Related Rules -* [no-prototype-builtins](no-prototype-builtins.md) +* [no-prototype-builtins](no-prototype-builtins) ## Further Reading diff --git a/docs/src/rules/handle-callback-err.md b/docs/src/rules/handle-callback-err.md index d1346cb6e0e..64db6d074f2 100644 --- a/docs/src/rules/handle-callback-err.md +++ b/docs/src/rules/handle-callback-err.md @@ -1,4 +1,9 @@ -# handle-callback-err +--- +title: handle-callback-err +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/handle-callback-err.md +rule_type: suggestion +--- Enforces callback error handling. diff --git a/docs/src/rules/id-blacklist.md b/docs/src/rules/id-blacklist.md index 12bac041c8c..bfb44e22a55 100644 --- a/docs/src/rules/id-blacklist.md +++ b/docs/src/rules/id-blacklist.md @@ -1,5 +1,10 @@ -# id-blacklist +--- +title: id-blacklist +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/id-blacklist.md +rule_type: suggestion +--- Disallows specified identifiers. -This rule was **deprecated** in ESLint v7.5.0 and replaced by the [id-denylist](id-denylist.md) rule. +This rule was **deprecated** in ESLint v7.5.0 and replaced by the [id-denylist](id-denylist) rule. diff --git a/docs/src/rules/id-denylist.md b/docs/src/rules/id-denylist.md index 283efb6ffeb..c5678a50fd5 100644 --- a/docs/src/rules/id-denylist.md +++ b/docs/src/rules/id-denylist.md @@ -1,4 +1,9 @@ -# id-denylist +--- +title: id-denylist +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/id-denylist.md +rule_type: suggestion +--- Disallows specified identifiers. diff --git a/docs/src/rules/id-length.md b/docs/src/rules/id-length.md index c3450db1f50..ba2051a584d 100644 --- a/docs/src/rules/id-length.md +++ b/docs/src/rules/id-length.md @@ -1,4 +1,9 @@ -# id-length +--- +title: id-length +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/id-length.md +rule_type: suggestion +--- Enforces minimum and maximum identifier lengths. @@ -251,7 +256,7 @@ const { a: z } = foo; ## Related Rules -* [max-len](max-len.md) -* [new-cap](new-cap.md) -* [func-names](func-names.md) -* [camelcase](camelcase.md) +* [max-len](max-len) +* [new-cap](new-cap) +* [func-names](func-names) +* [camelcase](camelcase) diff --git a/docs/src/rules/id-match.md b/docs/src/rules/id-match.md index 016466e4167..606a605d400 100644 --- a/docs/src/rules/id-match.md +++ b/docs/src/rules/id-match.md @@ -1,4 +1,9 @@ -# id-match +--- +title: id-match +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/id-match.md +rule_type: suggestion +--- Requires identifiers to match a specified regular expression. diff --git a/docs/src/rules/implicit-arrow-linebreak.md b/docs/src/rules/implicit-arrow-linebreak.md index bc3fbf4dd6d..876f9696508 100644 --- a/docs/src/rules/implicit-arrow-linebreak.md +++ b/docs/src/rules/implicit-arrow-linebreak.md @@ -1,4 +1,11 @@ -# implicit-arrow-linebreak +--- +title: implicit-arrow-linebreak +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/implicit-arrow-linebreak.md +rule_type: layout +--- + + Enforces the location of arrow function bodies with implicit returns. @@ -80,7 +87,6 @@ Examples of **correct** code for this rule with the `"below"` option: ```js /* eslint implicit-arrow-linebreak: ["error", "below"] */ - (foo) => bar; @@ -96,8 +102,8 @@ Examples of **correct** code for this rule with the `"below"` option: If you're not concerned about consistent locations of implicitly returned arrow function expressions, you should not turn on this rule. -You can also disable this rule if you are using the `"always"` option for the [`arrow-body-style`](arrow-body-style.md), since this will disable the use of implicit returns in arrow functions. +You can also disable this rule if you are using the `"always"` option for the [`arrow-body-style`](arrow-body-style), since this will disable the use of implicit returns in arrow functions. ## Related Rules -* [`brace-style`](brace-style.md) which enforces this behavior for arrow functions with block bodies. +* [`brace-style`](brace-style) which enforces this behavior for arrow functions with block bodies. diff --git a/docs/src/rules/indent-legacy.md b/docs/src/rules/indent-legacy.md index 053136bd0ad..d63b125a65b 100644 --- a/docs/src/rules/indent-legacy.md +++ b/docs/src/rules/indent-legacy.md @@ -1,4 +1,11 @@ -# indent-legacy +--- +title: indent-legacy +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/indent-legacy.md +rule_type: layout +--- + + Enforces consistent indentation. @@ -249,7 +256,6 @@ Examples of **incorrect** code for this rule with the options `2, { "outerIIFEBo })(); - if(y) { console.log('foo'); } @@ -268,7 +274,6 @@ function foo(x) { })(); - if(y) { console.log('foo'); } diff --git a/docs/src/rules/indent.md b/docs/src/rules/indent.md index f8dc70aa22c..2b83a5d3d11 100644 --- a/docs/src/rules/indent.md +++ b/docs/src/rules/indent.md @@ -1,4 +1,11 @@ -# indent +--- +title: indent +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/indent.md +rule_type: layout +--- + + Enforces consistent indentation. @@ -70,7 +77,7 @@ if (a) { This rule has an object option: -* `"ignoredNodes"` can be used to disable indentation checking for any AST node. This accepts an array of [selectors](/docs/developer-guide/selectors.md). If an AST node is matched by any of the selectors, the indentation of tokens which are direct children of that node will be ignored. This can be used as an escape hatch to relax the rule if you disagree with the indentation that it enforces for a particular syntactic pattern. +* `"ignoredNodes"` can be used to disable indentation checking for any AST node. This accepts an array of [selectors](/docs/developer-guide/selectors). If an AST node is matched by any of the selectors, the indentation of tokens which are direct children of that node will be ignored. This can be used as an escape hatch to relax the rule if you disagree with the indentation that it enforces for a particular syntactic pattern. * `"SwitchCase"` (default: 0) enforces indentation level for `case` clauses in `switch` statements * `"VariableDeclarator"` (default: 1) enforces indentation level for `var` declarators; can also take an object to define separate rules for `var`, `let` and `const` declarations. It can also be `"first"`, indicating all the declarators should be aligned with the first declarator. * `"outerIIFEBody"` (default: 1) enforces indentation level for file-level IIFEs. This can also be set to `"off"` to disable checking for file-level IIFEs. @@ -319,7 +326,6 @@ Examples of **incorrect** code for this rule with the options `2, { "outerIIFEBo })(); - if (y) { console.log('foo'); } @@ -338,7 +344,6 @@ function foo(x) { })(); - if (y) { console.log('foo'); } diff --git a/docs/src/rules/init-declarations.md b/docs/src/rules/init-declarations.md index b9031529c2e..c5d5c88be34 100644 --- a/docs/src/rules/init-declarations.md +++ b/docs/src/rules/init-declarations.md @@ -1,4 +1,9 @@ -# init-declarations +--- +title: init-declarations +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/init-declarations.md +rule_type: suggestion +--- Requires or disallows initialization in variable declarations. diff --git a/docs/src/rules/jsx-quotes.md b/docs/src/rules/jsx-quotes.md index 25e7bafd111..91cc4501eeb 100644 --- a/docs/src/rules/jsx-quotes.md +++ b/docs/src/rules/jsx-quotes.md @@ -1,4 +1,11 @@ -# jsx-quotes +--- +title: jsx-quotes +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/jsx-quotes.md +rule_type: layout +--- + + Enforces the consistent use of either double or single quotes in JSX attributes. @@ -72,4 +79,4 @@ You can turn this rule off if you don’t use JSX or if you aren’t concerned w ## Related Rules -* [quotes](quotes.md) +* [quotes](quotes) diff --git a/docs/src/rules/key-spacing.md b/docs/src/rules/key-spacing.md index f4668142c05..59de8f0a296 100644 --- a/docs/src/rules/key-spacing.md +++ b/docs/src/rules/key-spacing.md @@ -1,4 +1,11 @@ -# key-spacing +--- +title: key-spacing +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/key-spacing.md +rule_type: layout +--- + + Enforces consistent spacing between keys and values in object literal properties. diff --git a/docs/src/rules/keyword-spacing.md b/docs/src/rules/keyword-spacing.md index 71d372b3596..d48990c31e6 100644 --- a/docs/src/rules/keyword-spacing.md +++ b/docs/src/rules/keyword-spacing.md @@ -1,4 +1,11 @@ -# keyword-spacing +--- +title: keyword-spacing +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/keyword-spacing.md +rule_type: layout +--- + + Enforces consistent spacing before and after keywords. @@ -17,7 +24,7 @@ if (foo) { Of course, you could also have a style guide that disallows spaces around keywords. -However, if you want to enforce the style of spacing between the `function` keyword and the following opening parenthesis, please refer to [space-before-function-paren](space-before-function-paren.md). +However, if you want to enforce the style of spacing between the `function` keyword and the following opening parenthesis, please refer to [space-before-function-paren](space-before-function-paren). ## Rule Details diff --git a/docs/src/rules/line-comment-position.md b/docs/src/rules/line-comment-position.md index d18dc927ed9..7c033e398b5 100644 --- a/docs/src/rules/line-comment-position.md +++ b/docs/src/rules/line-comment-position.md @@ -1,4 +1,9 @@ -# line-comment-position +--- +title: line-comment-position +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/line-comment-position.md +rule_type: layout +--- Enforces position of line comments. diff --git a/docs/src/rules/linebreak-style.md b/docs/src/rules/linebreak-style.md index 2c823a5c75f..0549f9510f4 100644 --- a/docs/src/rules/linebreak-style.md +++ b/docs/src/rules/linebreak-style.md @@ -1,4 +1,11 @@ -# linebreak-style +--- +title: linebreak-style +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/linebreak-style.md +rule_type: layout +--- + + Enforces consistent linebreak style. diff --git a/docs/src/rules/lines-around-comment.md b/docs/src/rules/lines-around-comment.md index 759c50c382d..2cb707e185e 100644 --- a/docs/src/rules/lines-around-comment.md +++ b/docs/src/rules/lines-around-comment.md @@ -1,4 +1,11 @@ -# lines-around-comment +--- +title: lines-around-comment +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/lines-around-comment.md +rule_type: layout +--- + + Requires empty lines around comments. @@ -529,7 +536,6 @@ foo(); /* eslint mentioned in this comment */, bar(); - /*eslint lines-around-comment: ["error", { "ignorePattern": "pragma" }] */ foo(); @@ -574,5 +580,5 @@ Many people enjoy a terser code style and don't mind comments bumping up against ## Related Rules -* [space-before-blocks](space-before-blocks.md) -* [spaced-comment](spaced-comment.md) +* [space-before-blocks](space-before-blocks) +* [spaced-comment](spaced-comment) diff --git a/docs/src/rules/lines-around-directive.md b/docs/src/rules/lines-around-directive.md index e88e0707faa..4f8b7fc1df0 100644 --- a/docs/src/rules/lines-around-directive.md +++ b/docs/src/rules/lines-around-directive.md @@ -1,8 +1,15 @@ -# lines-around-directive +--- +title: lines-around-directive +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/lines-around-directive.md +rule_type: layout +--- + + Requires or disallow newlines around directives. -This rule was **deprecated** in ESLint v4.0.0 and replaced by the [padding-line-between-statements](padding-line-between-statements.md) rule. +This rule was **deprecated** in ESLint v4.0.0 and replaced by the [padding-line-between-statements](padding-line-between-statements) rule. Directives are used in JavaScript to indicate to the execution environment that a script would like to opt into a feature such as `"strict mode"`. Directives are grouped together in a [directive prologue](https://www.ecma-international.org/ecma-262/7.0/#directive-prologue) at the top of either a file or function block and are applied to the scope in which they occur. @@ -30,7 +37,7 @@ function bar() { ## Rule Details -This rule requires or disallows blank newlines around directive prologues. This rule does not enforce any conventions about blank newlines between the individual directives. In addition, it does not require blank newlines before directive prologues unless they are preceded by a comment. Please use the [padded-blocks](padded-blocks.md) rule if this is a style you would like to enforce. +This rule requires or disallows blank newlines around directive prologues. This rule does not enforce any conventions about blank newlines between the individual directives. In addition, it does not require blank newlines before directive prologues unless they are preceded by a comment. Please use the [padded-blocks](padded-blocks) rule if this is a style you would like to enforce. ## Options @@ -127,7 +134,6 @@ Examples of **incorrect** code for this rule with the `"never"` option: var foo; - /* Top of file */ // comment @@ -136,7 +142,6 @@ var foo; var foo; - function foo() { "use strict"; "use asm"; @@ -144,7 +149,6 @@ function foo() { var bar; } - function foo() { // comment @@ -315,8 +319,8 @@ You can safely disable this rule if you do not have any strict conventions about ## Related Rules -* [lines-around-comment](lines-around-comment.md) -* [padded-blocks](padded-blocks.md) +* [lines-around-comment](lines-around-comment) +* [padded-blocks](padded-blocks) ## Compatibility diff --git a/docs/src/rules/lines-between-class-members.md b/docs/src/rules/lines-between-class-members.md index 0654a3953b1..05a2c90cedd 100644 --- a/docs/src/rules/lines-between-class-members.md +++ b/docs/src/rules/lines-between-class-members.md @@ -1,4 +1,11 @@ -# lines-between-class-members +--- +title: lines-between-class-members +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/lines-between-class-members.md +rule_type: layout +--- + + Requires or disallows an empty line between class members. @@ -124,8 +131,8 @@ If you don't want to enforce empty lines between class members, you can disable ## Related Rules -* [padded-blocks](padded-blocks.md) -* [padding-line-between-statements](padding-line-between-statements.md) +* [padded-blocks](padded-blocks) +* [padding-line-between-statements](padding-line-between-statements) ## Compatibility diff --git a/docs/src/rules/max-classes-per-file.md b/docs/src/rules/max-classes-per-file.md index dab6e77dbaa..5752d540ae9 100644 --- a/docs/src/rules/max-classes-per-file.md +++ b/docs/src/rules/max-classes-per-file.md @@ -1,4 +1,9 @@ -# max-classes-per-file +--- +title: max-classes-per-file +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/max-classes-per-file.md +rule_type: suggestion +--- Enforces a maximum number of classes per file. diff --git a/docs/src/rules/max-depth.md b/docs/src/rules/max-depth.md index 85b7a63e438..fd2539b3f1e 100644 --- a/docs/src/rules/max-depth.md +++ b/docs/src/rules/max-depth.md @@ -1,4 +1,9 @@ -# max-depth +--- +title: max-depth +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/max-depth.md +rule_type: suggestion +--- Enforces a maximum depth that blocks can be nested. @@ -98,10 +103,10 @@ function foo() { ## Related Rules -* [complexity](complexity.md) -* [max-len](max-len.md) -* [max-lines](max-lines.md) -* [max-lines-per-function](max-lines-per-function.md) -* [max-nested-callbacks](max-nested-callbacks.md) -* [max-params](max-params.md) -* [max-statements](max-statements.md) +* [complexity](complexity) +* [max-len](max-len) +* [max-lines](max-lines) +* [max-lines-per-function](max-lines-per-function) +* [max-nested-callbacks](max-nested-callbacks) +* [max-params](max-params) +* [max-statements](max-statements) diff --git a/docs/src/rules/max-len.md b/docs/src/rules/max-len.md index 61804d57057..5b2ab80b102 100644 --- a/docs/src/rules/max-len.md +++ b/docs/src/rules/max-len.md @@ -1,4 +1,9 @@ -# max-len +--- +title: max-len +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/max-len.md +rule_type: layout +--- Enforces a maximum line length. @@ -156,8 +161,8 @@ var dep = require('really/really/really/really/really/really/really/really/long/ ## Related Rules -* [complexity](complexity.md) -* [max-depth](max-depth.md) -* [max-nested-callbacks](max-nested-callbacks.md) -* [max-params](max-params.md) -* [max-statements](max-statements.md) +* [complexity](complexity) +* [max-depth](max-depth) +* [max-nested-callbacks](max-nested-callbacks) +* [max-params](max-params) +* [max-statements](max-statements) diff --git a/docs/src/rules/max-lines-per-function.md b/docs/src/rules/max-lines-per-function.md index 21c49146818..f04ef80261d 100644 --- a/docs/src/rules/max-lines-per-function.md +++ b/docs/src/rules/max-lines-per-function.md @@ -1,4 +1,9 @@ -# max-lines-per-function +--- +title: max-lines-per-function +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/max-lines-per-function.md +rule_type: suggestion +--- Enforces a maximum function length. @@ -192,10 +197,10 @@ You can turn this rule off if you are not concerned with the number of lines in ## Related Rules -* [complexity](complexity.md) -* [max-depth](max-depth.md) -* [max-lines](max-lines.md) -* [max-nested-callbacks](max-nested-callbacks.md) -* [max-params](max-params.md) -* [max-statements](max-statements.md) -* [max-statements-per-line](max-statements-per-line.md) +* [complexity](complexity) +* [max-depth](max-depth) +* [max-lines](max-lines) +* [max-nested-callbacks](max-nested-callbacks) +* [max-params](max-params) +* [max-statements](max-statements) +* [max-statements-per-line](max-statements-per-line) diff --git a/docs/src/rules/max-lines.md b/docs/src/rules/max-lines.md index 8ced25fceab..31d232a6ddb 100644 --- a/docs/src/rules/max-lines.md +++ b/docs/src/rules/max-lines.md @@ -1,4 +1,9 @@ -# max-lines +--- +title: max-lines +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/max-lines.md +rule_type: suggestion +--- Enforces a maximum file length. @@ -113,12 +118,12 @@ You can turn this rule off if you are not concerned with the number of lines in ## Related Rules -* [complexity](complexity.md) -* [max-depth](max-depth.md) -* [max-lines-per-function](max-lines-per-function.md) -* [max-nested-callbacks](max-nested-callbacks.md) -* [max-params](max-params.md) -* [max-statements](max-statements.md) +* [complexity](complexity) +* [max-depth](max-depth) +* [max-lines-per-function](max-lines-per-function) +* [max-nested-callbacks](max-nested-callbacks) +* [max-params](max-params) +* [max-statements](max-statements) ## Compatibility diff --git a/docs/src/rules/max-nested-callbacks.md b/docs/src/rules/max-nested-callbacks.md index c7b85c783d8..61a2ca750ab 100644 --- a/docs/src/rules/max-nested-callbacks.md +++ b/docs/src/rules/max-nested-callbacks.md @@ -1,4 +1,9 @@ -# max-nested-callbacks +--- +title: max-nested-callbacks +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/max-nested-callbacks.md +rule_type: suggestion +--- Enforces a maximum depth that callbacks can be nested. @@ -72,13 +77,13 @@ function handleFoo4() { ## Related Rules -* [complexity](complexity.md) -* [max-depth](max-depth.md) -* [max-len](max-len.md) -* [max-lines](max-lines.md) -* [max-lines-per-function](max-lines-per-function.md) -* [max-params](max-params.md) -* [max-statements](max-statements.md) +* [complexity](complexity) +* [max-depth](max-depth) +* [max-len](max-len) +* [max-lines](max-lines) +* [max-lines-per-function](max-lines-per-function) +* [max-params](max-params) +* [max-statements](max-statements) ## Further Reading diff --git a/docs/src/rules/max-params.md b/docs/src/rules/max-params.md index 0f8c2d1b4e6..ece9598811f 100644 --- a/docs/src/rules/max-params.md +++ b/docs/src/rules/max-params.md @@ -1,4 +1,9 @@ -# max-params +--- +title: max-params +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/max-params.md +rule_type: suggestion +--- Enforces a maximum number of parameters in function definitions. @@ -56,10 +61,10 @@ let foo = (bar, baz, qux) => { ## Related Rules -* [complexity](complexity.md) -* [max-depth](max-depth.md) -* [max-len](max-len.md) -* [max-lines](max-lines.md) -* [max-lines-per-function](max-lines-per-function.md) -* [max-nested-callbacks](max-nested-callbacks.md) -* [max-statements](max-statements.md) +* [complexity](complexity) +* [max-depth](max-depth) +* [max-len](max-len) +* [max-lines](max-lines) +* [max-lines-per-function](max-lines-per-function) +* [max-nested-callbacks](max-nested-callbacks) +* [max-statements](max-statements) diff --git a/docs/src/rules/max-statements-per-line.md b/docs/src/rules/max-statements-per-line.md index ef17951a765..d2a17245060 100644 --- a/docs/src/rules/max-statements-per-line.md +++ b/docs/src/rules/max-statements-per-line.md @@ -1,4 +1,9 @@ -# max-statements-per-line +--- +title: max-statements-per-line +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/max-statements-per-line.md +rule_type: layout +--- Enforces a maximum number of statements allowed per line. @@ -80,10 +85,10 @@ You can turn this rule off if you are not concerned with the number of statement ## Related Rules -* [max-depth](max-depth.md) -* [max-len](max-len.md) -* [max-lines](max-lines.md) -* [max-lines-per-function](max-lines-per-function.md) -* [max-nested-callbacks](max-nested-callbacks.md) -* [max-params](max-params.md) -* [max-statements](max-statements.md) +* [max-depth](max-depth) +* [max-len](max-len) +* [max-lines](max-lines) +* [max-lines-per-function](max-lines-per-function) +* [max-nested-callbacks](max-nested-callbacks) +* [max-params](max-params) +* [max-statements](max-statements) diff --git a/docs/src/rules/max-statements.md b/docs/src/rules/max-statements.md index 11ac27871c5..9c1dfe0ffef 100644 --- a/docs/src/rules/max-statements.md +++ b/docs/src/rules/max-statements.md @@ -1,4 +1,9 @@ -# max-statements +--- +title: max-statements +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/max-statements.md +rule_type: suggestion +--- Enforces a maximum number of statements allowed in function blocks. @@ -162,10 +167,10 @@ function foo() { ## Related Rules -* [complexity](complexity.md) -* [max-depth](max-depth.md) -* [max-len](max-len.md) -* [max-lines](max-lines.md) -* [max-lines-per-function](max-lines-per-function.md) -* [max-nested-callbacks](max-nested-callbacks.md) -* [max-params](max-params.md) +* [complexity](complexity) +* [max-depth](max-depth) +* [max-len](max-len) +* [max-lines](max-lines) +* [max-lines-per-function](max-lines-per-function) +* [max-nested-callbacks](max-nested-callbacks) +* [max-params](max-params) diff --git a/docs/src/rules/multiline-comment-style.md b/docs/src/rules/multiline-comment-style.md index db7a01865d2..fca714605aa 100644 --- a/docs/src/rules/multiline-comment-style.md +++ b/docs/src/rules/multiline-comment-style.md @@ -1,4 +1,11 @@ -# multiline-comment-style +--- +title: multiline-comment-style +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/multiline-comment-style.md +rule_type: suggestion +--- + + Enforces a particular style for multiline comments. @@ -117,7 +124,6 @@ Examples of **correct** code for this rule with the `"separate-lines"` option: // calls foo() foo(); - ``` ## When Not To Use It diff --git a/docs/src/rules/multiline-ternary.md b/docs/src/rules/multiline-ternary.md index a987b6a80fa..d4c5e1e6d9a 100644 --- a/docs/src/rules/multiline-ternary.md +++ b/docs/src/rules/multiline-ternary.md @@ -1,4 +1,11 @@ -# multiline-ternary +--- +title: multiline-ternary +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/multiline-ternary.md +rule_type: layout +--- + + Enforces or disallows newlines between operands of ternary expressions. @@ -21,7 +28,7 @@ var foo = bar > baz ? ## Rule Details This rule enforces or disallows newlines between operands of a ternary expression. -Note: The location of the operators is not enforced by this rule. Please see the [operator-linebreak](operator-linebreak.md) rule if you are interested in enforcing the location of the operators themselves. +Note: The location of the operators is not enforced by this rule. Please see the [operator-linebreak](operator-linebreak) rule if you are interested in enforcing the location of the operators themselves. ## Options @@ -148,7 +155,7 @@ You can safely disable this rule if you do not have any strict conventions about ## Related Rules -* [operator-linebreak](operator-linebreak.md) +* [operator-linebreak](operator-linebreak) ## Compatibility diff --git a/docs/src/rules/new-cap.md b/docs/src/rules/new-cap.md index eb7afc9405e..8bca67c9e73 100644 --- a/docs/src/rules/new-cap.md +++ b/docs/src/rules/new-cap.md @@ -1,4 +1,9 @@ -# new-cap +--- +title: new-cap +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/new-cap.md +rule_type: suggestion +--- Requires constructor names to begin with a capital letter. diff --git a/docs/src/rules/new-parens.md b/docs/src/rules/new-parens.md index 88fe89ec19a..0d7cefcd62b 100644 --- a/docs/src/rules/new-parens.md +++ b/docs/src/rules/new-parens.md @@ -1,4 +1,11 @@ -# new-parens +--- +title: new-parens +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/new-parens.md +rule_type: layout +--- + + Requires parentheses when invoking a constructor with no arguments. diff --git a/docs/src/rules/newline-after-var.md b/docs/src/rules/newline-after-var.md index 5e3b20444d1..9cb5c7a48b8 100644 --- a/docs/src/rules/newline-after-var.md +++ b/docs/src/rules/newline-after-var.md @@ -1,8 +1,15 @@ -# newline-after-var +--- +title: newline-after-var +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/newline-after-var.md +rule_type: layout +--- + + Requires or disallows an empty line after variable declarations. -This rule was **deprecated** in ESLint v4.0.0 and replaced by the [padding-line-between-statements](padding-line-between-statements.md) rule. +This rule was **deprecated** in ESLint v4.0.0 and replaced by the [padding-line-between-statements](padding-line-between-statements) rule. As of today there is no consistency in separating variable declarations from the rest of the code. Some developers leave an empty line between var statements and the rest of the code like: diff --git a/docs/src/rules/newline-before-return.md b/docs/src/rules/newline-before-return.md index 378948ea3ad..718ceb25365 100644 --- a/docs/src/rules/newline-before-return.md +++ b/docs/src/rules/newline-before-return.md @@ -1,8 +1,15 @@ -# newline-before-return +--- +title: newline-before-return +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/newline-before-return.md +rule_type: layout +--- + + Requires an empty line before `return` statements. -This rule was **deprecated** in ESLint v4.0.0 and replaced by the [padding-line-between-statements](padding-line-between-statements.md) rule. +This rule was **deprecated** in ESLint v4.0.0 and replaced by the [padding-line-between-statements](padding-line-between-statements) rule. There is no hard and fast rule about whether empty lines should precede `return` statements in JavaScript. However, clearly delineating where a function is returning can greatly increase the readability and clarity of the code. For example: @@ -115,4 +122,4 @@ You can safely disable this rule if you do not have any strict conventions about ## Related Rules -* [newline-after-var](newline-after-var.md) +* [newline-after-var](newline-after-var) diff --git a/docs/src/rules/newline-per-chained-call.md b/docs/src/rules/newline-per-chained-call.md index 9e3004f8e1e..6aaab2ca9c5 100644 --- a/docs/src/rules/newline-per-chained-call.md +++ b/docs/src/rules/newline-per-chained-call.md @@ -1,4 +1,11 @@ -# newline-per-chained-call +--- +title: newline-per-chained-call +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/newline-per-chained-call.md +rule_type: layout +--- + + Requires a newline after each call in a method chain. diff --git a/docs/src/rules/no-alert.md b/docs/src/rules/no-alert.md index 956aff81114..48167bd1f8d 100644 --- a/docs/src/rules/no-alert.md +++ b/docs/src/rules/no-alert.md @@ -1,4 +1,9 @@ -# no-alert +--- +title: no-alert +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-alert.md +rule_type: suggestion +--- Disallows the use of `alert`, `confirm`, and `prompt`. @@ -43,5 +48,5 @@ function foo() { ## Related Rules -* [no-console](no-console.md) -* [no-debugger](no-debugger.md) +* [no-console](no-console) +* [no-debugger](no-debugger) diff --git a/docs/src/rules/no-array-constructor.md b/docs/src/rules/no-array-constructor.md index 06a8276ecca..746704b55b8 100644 --- a/docs/src/rules/no-array-constructor.md +++ b/docs/src/rules/no-array-constructor.md @@ -1,4 +1,9 @@ -# no-array-constructor +--- +title: no-array-constructor +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-array-constructor.md +rule_type: suggestion +--- Disallows `Array` constructors. @@ -41,5 +46,5 @@ rule may be disabled if the constructor style is preferred. ## Related Rules -* [no-new-object](no-new-object.md) -* [no-new-wrappers](no-new-wrappers.md) +* [no-new-object](no-new-object) +* [no-new-wrappers](no-new-wrappers) diff --git a/docs/src/rules/no-arrow-condition.md b/docs/src/rules/no-arrow-condition.md index 2052f02e3bd..be451c87797 100644 --- a/docs/src/rules/no-arrow-condition.md +++ b/docs/src/rules/no-arrow-condition.md @@ -1,8 +1,13 @@ -# no-arrow-condition +--- +title: no-arrow-condition +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-arrow-condition.md + +--- Disallows arrow functions where test conditions are expected. -(removed) This rule was **removed** in ESLint v2.0 and **replaced** by a combination of the [no-confusing-arrow](no-confusing-arrow.md) and [no-constant-condition](no-constant-condition.md) rules. +(removed) This rule was **removed** in ESLint v2.0 and **replaced** by a combination of the [no-confusing-arrow](no-confusing-arrow) and [no-constant-condition](no-constant-condition) rules. Arrow functions (`=>`) are similar in syntax to some comparison operators (`>`, `<`, `<=`, and `>=`). This rule warns against using the arrow function syntax in places where a condition is expected. Even if the arguments of the arrow function are wrapped with parens, this rule still warns about it. @@ -45,6 +50,6 @@ var x = (a) => 1 ? 2 : 3 ## Related Rules -* [arrow-parens](arrow-parens.md) -* [no-confusing-arrow](no-confusing-arrow.md) -* [no-constant-condition](no-constant-condition.md) +* [arrow-parens](arrow-parens) +* [no-confusing-arrow](no-confusing-arrow) +* [no-constant-condition](no-constant-condition) diff --git a/docs/src/rules/no-async-promise-executor.md b/docs/src/rules/no-async-promise-executor.md index 3f9cf9627ad..6627f5b8be7 100644 --- a/docs/src/rules/no-async-promise-executor.md +++ b/docs/src/rules/no-async-promise-executor.md @@ -1,4 +1,11 @@ -# no-async-promise-executor +--- +title: no-async-promise-executor +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-async-promise-executor.md +rule_type: problem +--- + + Disallows using an async function as a Promise executor. diff --git a/docs/src/rules/no-await-in-loop.md b/docs/src/rules/no-await-in-loop.md index 2395956c357..5e759e60cc2 100644 --- a/docs/src/rules/no-await-in-loop.md +++ b/docs/src/rules/no-await-in-loop.md @@ -1,4 +1,9 @@ -# no-await-in-loop +--- +title: no-await-in-loop +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-await-in-loop.md +rule_type: problem +--- Disallows `await` inside of loops. diff --git a/docs/src/rules/no-bitwise.md b/docs/src/rules/no-bitwise.md index b79a9dc7d9b..b2721bac59f 100644 --- a/docs/src/rules/no-bitwise.md +++ b/docs/src/rules/no-bitwise.md @@ -1,4 +1,9 @@ -# no-bitwise +--- +title: no-bitwise +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-bitwise.md +rule_type: suggestion +--- Disallows bitwise operators. diff --git a/docs/src/rules/no-buffer-constructor.md b/docs/src/rules/no-buffer-constructor.md index 4e1e7728a8e..64e7c1e1702 100644 --- a/docs/src/rules/no-buffer-constructor.md +++ b/docs/src/rules/no-buffer-constructor.md @@ -1,4 +1,9 @@ -# no-buffer-constructor +--- +title: no-buffer-constructor +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-buffer-constructor.md +rule_type: problem +--- Disallows use of the `Buffer()` constructor. diff --git a/docs/src/rules/no-caller.md b/docs/src/rules/no-caller.md index 280d2f6fdac..f7be8267288 100644 --- a/docs/src/rules/no-caller.md +++ b/docs/src/rules/no-caller.md @@ -1,4 +1,9 @@ -# no-caller +--- +title: no-caller +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-caller.md +rule_type: suggestion +--- Disallows use of `caller`/`callee`. diff --git a/docs/src/rules/no-case-declarations.md b/docs/src/rules/no-case-declarations.md index 8a73e5136bb..4e0717e8d27 100644 --- a/docs/src/rules/no-case-declarations.md +++ b/docs/src/rules/no-case-declarations.md @@ -1,4 +1,11 @@ -# no-case-declarations +--- +title: no-case-declarations +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-case-declarations.md +rule_type: suggestion +--- + + Disallows lexical declarations in case/default clauses. @@ -74,4 +81,4 @@ If you depend on fall through behavior and want access to bindings introduced in ## Related Rules -* [no-fallthrough](no-fallthrough.md) +* [no-fallthrough](no-fallthrough) diff --git a/docs/src/rules/no-catch-shadow.md b/docs/src/rules/no-catch-shadow.md index ebd18479198..3ed3b038161 100644 --- a/docs/src/rules/no-catch-shadow.md +++ b/docs/src/rules/no-catch-shadow.md @@ -1,4 +1,9 @@ -# no-catch-shadow +--- +title: no-catch-shadow +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-catch-shadow.md +rule_type: suggestion +--- Disallows shadowing of variables inside of catch. diff --git a/docs/src/rules/no-class-assign.md b/docs/src/rules/no-class-assign.md index ca57fd95f82..9666f8ce7aa 100644 --- a/docs/src/rules/no-class-assign.md +++ b/docs/src/rules/no-class-assign.md @@ -1,4 +1,11 @@ -# no-class-assign +--- +title: no-class-assign +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-class-assign.md +rule_type: problem +--- + + Disallows modifying variables of class declarations. diff --git a/docs/src/rules/no-comma-dangle.md b/docs/src/rules/no-comma-dangle.md index 64fa4fd62c7..6498c1045b3 100644 --- a/docs/src/rules/no-comma-dangle.md +++ b/docs/src/rules/no-comma-dangle.md @@ -1,8 +1,13 @@ -# no-comma-dangle +--- +title: no-comma-dangle +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-comma-dangle.md + +--- Disallows trailing commas in object and array literals. -(removed) This rule was **removed** in ESLint v1.0 and **replaced** by the [comma-dangle](comma-dangle.md) rule. +(removed) This rule was **removed** in ESLint v1.0 and **replaced** by the [comma-dangle](comma-dangle) rule. Trailing commas in object literals are valid according to the ECMAScript 5 (and ECMAScript 3!) spec, however IE8 (when not in IE8 document mode) and below will throw an error when it encounters trailing commas in JavaScript. diff --git a/docs/src/rules/no-compare-neg-zero.md b/docs/src/rules/no-compare-neg-zero.md index ba34e1f025a..bbfea3d8f60 100644 --- a/docs/src/rules/no-compare-neg-zero.md +++ b/docs/src/rules/no-compare-neg-zero.md @@ -1,4 +1,11 @@ -# no-compare-neg-zero +--- +title: no-compare-neg-zero +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-compare-neg-zero.md +rule_type: problem +--- + + Disallows comparing against `-0`. diff --git a/docs/src/rules/no-cond-assign.md b/docs/src/rules/no-cond-assign.md index 1ac17b85063..318a9e8bf34 100644 --- a/docs/src/rules/no-cond-assign.md +++ b/docs/src/rules/no-cond-assign.md @@ -1,4 +1,11 @@ -# no-cond-assign +--- +title: no-cond-assign +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-cond-assign.md +rule_type: problem +--- + + Disallows assignment operators in conditional statements. @@ -126,4 +133,4 @@ if (x === 0) { ## Related Rules -* [no-extra-parens](no-extra-parens.md) +* [no-extra-parens](no-extra-parens) diff --git a/docs/src/rules/no-confusing-arrow.md b/docs/src/rules/no-confusing-arrow.md index f88af8e5d9a..d5a3a0e40c1 100644 --- a/docs/src/rules/no-confusing-arrow.md +++ b/docs/src/rules/no-confusing-arrow.md @@ -1,4 +1,11 @@ -# no-confusing-arrow +--- +title: no-confusing-arrow +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-confusing-arrow.md +rule_type: suggestion +--- + + Disallows arrow functions where they could be confused with comparisons. @@ -91,5 +98,5 @@ Examples of **correct** code for this rule with the `{"onlyOneSimpleParam": true ## Related Rules -* [no-constant-condition](no-constant-condition.md) -* [arrow-parens](arrow-parens.md) +* [no-constant-condition](no-constant-condition) +* [arrow-parens](arrow-parens) diff --git a/docs/src/rules/no-console.md b/docs/src/rules/no-console.md index 39b52822b9c..6bf0637aa86 100644 --- a/docs/src/rules/no-console.md +++ b/docs/src/rules/no-console.md @@ -1,4 +1,9 @@ -# no-console +--- +title: no-console +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-console.md +rule_type: suggestion +--- Disallows the use of `console`. @@ -95,5 +100,5 @@ However, you might not want to manually add `eslint-disable-next-line` or `eslin ## Related Rules -* [no-alert](no-alert.md) -* [no-debugger](no-debugger.md) +* [no-alert](no-alert) +* [no-debugger](no-debugger) diff --git a/docs/src/rules/no-const-assign.md b/docs/src/rules/no-const-assign.md index 422859fbc19..74921f96919 100644 --- a/docs/src/rules/no-const-assign.md +++ b/docs/src/rules/no-const-assign.md @@ -1,4 +1,11 @@ -# no-const-assign +--- +title: no-const-assign +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-const-assign.md +rule_type: problem +--- + + Disallows modifying variables that are declared using `const`. diff --git a/docs/src/rules/no-constant-condition.md b/docs/src/rules/no-constant-condition.md index 810c17bead1..8237ea856e3 100644 --- a/docs/src/rules/no-constant-condition.md +++ b/docs/src/rules/no-constant-condition.md @@ -1,4 +1,11 @@ -# no-constant-condition +--- +title: no-constant-condition +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-constant-condition.md +rule_type: problem +--- + + Disallows constant expressions in conditions. diff --git a/docs/src/rules/no-constructor-return.md b/docs/src/rules/no-constructor-return.md index c2f15fd20d6..4be5f30bedd 100644 --- a/docs/src/rules/no-constructor-return.md +++ b/docs/src/rules/no-constructor-return.md @@ -1,4 +1,9 @@ -# no-constructor-return +--- +title: no-constructor-return +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-constructor-return.md +rule_type: problem +--- Disallows returning values in constructor. diff --git a/docs/src/rules/no-continue.md b/docs/src/rules/no-continue.md index b2f8409b6d2..fff6611a3e6 100644 --- a/docs/src/rules/no-continue.md +++ b/docs/src/rules/no-continue.md @@ -1,4 +1,9 @@ -# no-continue +--- +title: no-continue +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-continue.md +rule_type: suggestion +--- Disallows `continue` statements. diff --git a/docs/src/rules/no-control-regex.md b/docs/src/rules/no-control-regex.md index dcc7df4ca1c..feebe466189 100644 --- a/docs/src/rules/no-control-regex.md +++ b/docs/src/rules/no-control-regex.md @@ -1,4 +1,11 @@ -# no-control-regex +--- +title: no-control-regex +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-control-regex.md +rule_type: problem +--- + + Disallows control characters in regular expressions. @@ -32,5 +39,5 @@ If you need to use control character pattern matching, then you should turn this ## Related Rules -* [no-div-regex](no-div-regex.md) -* [no-regex-spaces](no-regex-spaces.md) +* [no-div-regex](no-div-regex) +* [no-regex-spaces](no-regex-spaces) diff --git a/docs/src/rules/no-debugger.md b/docs/src/rules/no-debugger.md index b7d27b1a0da..99188c8018a 100644 --- a/docs/src/rules/no-debugger.md +++ b/docs/src/rules/no-debugger.md @@ -1,4 +1,11 @@ -# no-debugger +--- +title: no-debugger +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-debugger.md +rule_type: problem +--- + + Disallows the use of `debugger`. @@ -35,8 +42,8 @@ If your code is still very much in development and don't want to worry about str ## Related Rules -* [no-alert](no-alert.md) -* [no-console](no-console.md) +* [no-alert](no-alert) +* [no-console](no-console) ## Further Reading diff --git a/docs/src/rules/no-delete-var.md b/docs/src/rules/no-delete-var.md index e1224a22506..b14dd57f536 100644 --- a/docs/src/rules/no-delete-var.md +++ b/docs/src/rules/no-delete-var.md @@ -1,4 +1,11 @@ -# no-delete-var +--- +title: no-delete-var +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-delete-var.md +rule_type: suggestion +--- + + Disallows deleting variables. diff --git a/docs/src/rules/no-div-regex.md b/docs/src/rules/no-div-regex.md index dda12a725bf..26022d05840 100644 --- a/docs/src/rules/no-div-regex.md +++ b/docs/src/rules/no-div-regex.md @@ -1,4 +1,11 @@ -# no-div-regex +--- +title: no-div-regex +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-div-regex.md +rule_type: suggestion +--- + + Disallows regular expressions that look like division. @@ -30,5 +37,5 @@ function bar() { return /[=]foo/; } ## Related Rules -* [no-control-regex](no-control-regex.md) -* [no-regex-spaces](no-regex-spaces.md) +* [no-control-regex](no-control-regex) +* [no-regex-spaces](no-regex-spaces) diff --git a/docs/src/rules/no-dupe-args.md b/docs/src/rules/no-dupe-args.md index 5c2dead0639..c28f5cd5fd4 100644 --- a/docs/src/rules/no-dupe-args.md +++ b/docs/src/rules/no-dupe-args.md @@ -1,4 +1,11 @@ -# no-dupe-args +--- +title: no-dupe-args +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-dupe-args.md +rule_type: problem +--- + + Disallows duplicate arguments in `function` definitions. diff --git a/docs/src/rules/no-dupe-class-members.md b/docs/src/rules/no-dupe-class-members.md index c825634f07d..f50088b0da8 100644 --- a/docs/src/rules/no-dupe-class-members.md +++ b/docs/src/rules/no-dupe-class-members.md @@ -1,4 +1,11 @@ -# no-dupe-class-members +--- +title: no-dupe-class-members +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-dupe-class-members.md +rule_type: problem +--- + + Disallows duplicate name in class members. diff --git a/docs/src/rules/no-dupe-else-if.md b/docs/src/rules/no-dupe-else-if.md index 9c4138695b2..73c98f9d246 100644 --- a/docs/src/rules/no-dupe-else-if.md +++ b/docs/src/rules/no-dupe-else-if.md @@ -1,4 +1,11 @@ -# no-dupe-else-if +--- +title: no-dupe-else-if +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-dupe-else-if.md +rule_type: problem +--- + + Disallows duplicate conditions in `if-else-if` chains. @@ -176,5 +183,5 @@ In rare cases where you really need identical test conditions in the same chain, ## Related Rules -* [no-duplicate-case](no-duplicate-case.md) -* [no-lonely-if](no-lonely-if.md) +* [no-duplicate-case](no-duplicate-case) +* [no-lonely-if](no-lonely-if) diff --git a/docs/src/rules/no-dupe-keys.md b/docs/src/rules/no-dupe-keys.md index 0698a7e286e..a5bfda0ec1b 100644 --- a/docs/src/rules/no-dupe-keys.md +++ b/docs/src/rules/no-dupe-keys.md @@ -1,4 +1,11 @@ -# no-dupe-keys +--- +title: no-dupe-keys +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-dupe-keys.md +rule_type: problem +--- + + Disallows duplicate keys in object literals. diff --git a/docs/src/rules/no-duplicate-case.md b/docs/src/rules/no-duplicate-case.md index 5ad1dfe0661..455689f33d9 100644 --- a/docs/src/rules/no-duplicate-case.md +++ b/docs/src/rules/no-duplicate-case.md @@ -1,4 +1,11 @@ -# no-duplicate-case +--- +title: no-duplicate-case +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-duplicate-case.md +rule_type: problem +--- + + Disallows duplicate `case` labels. diff --git a/docs/src/rules/no-duplicate-imports.md b/docs/src/rules/no-duplicate-imports.md index 7b6e6d53c1f..88d7a2d8706 100644 --- a/docs/src/rules/no-duplicate-imports.md +++ b/docs/src/rules/no-duplicate-imports.md @@ -1,4 +1,9 @@ -# no-duplicate-imports +--- +title: no-duplicate-imports +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-duplicate-imports.md +rule_type: problem +--- Disallows duplicate imports. diff --git a/docs/src/rules/no-else-return.md b/docs/src/rules/no-else-return.md index 37f5db789ac..8903c4a6082 100644 --- a/docs/src/rules/no-else-return.md +++ b/docs/src/rules/no-else-return.md @@ -1,4 +1,11 @@ -# no-else-return +--- +title: no-else-return +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-else-return.md +rule_type: suggestion +--- + + Disallows `return` before `else`. diff --git a/docs/src/rules/no-empty-character-class.md b/docs/src/rules/no-empty-character-class.md index 7bbdc72b45e..146e0cdf876 100644 --- a/docs/src/rules/no-empty-character-class.md +++ b/docs/src/rules/no-empty-character-class.md @@ -1,4 +1,11 @@ -# no-empty-character-class +--- +title: no-empty-character-class +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-empty-character-class.md +rule_type: problem +--- + + Disallows empty character classes in regular expressions. diff --git a/docs/src/rules/no-empty-class.md b/docs/src/rules/no-empty-class.md index f39f1598329..0673cd3f7ed 100644 --- a/docs/src/rules/no-empty-class.md +++ b/docs/src/rules/no-empty-class.md @@ -1,8 +1,13 @@ -# no-empty-class +--- +title: no-empty-class +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-empty-class.md + +--- Disallows empty character classes in regular expressions. -(removed) This rule was **removed** in ESLint v1.0 and **replaced** by the [no-empty-character-class](no-empty-character-class.md) rule. +(removed) This rule was **removed** in ESLint v1.0 and **replaced** by the [no-empty-character-class](no-empty-character-class) rule. Empty character classes in regular expressions do not match anything and can result in code that may not work as intended. diff --git a/docs/src/rules/no-empty-function.md b/docs/src/rules/no-empty-function.md index 9d053950d55..bb97633610e 100644 --- a/docs/src/rules/no-empty-function.md +++ b/docs/src/rules/no-empty-function.md @@ -1,4 +1,9 @@ -# no-empty-function +--- +title: no-empty-function +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-empty-function.md +rule_type: suggestion +--- Disallows empty functions. @@ -346,4 +351,4 @@ If you don't want to be notified about empty functions, then it's safe to disabl ## Related Rules -* [no-empty](./no-empty.md) +* [no-empty](./no-empty) diff --git a/docs/src/rules/no-empty-label.md b/docs/src/rules/no-empty-label.md index ed9d64193db..f7a3fadebc3 100644 --- a/docs/src/rules/no-empty-label.md +++ b/docs/src/rules/no-empty-label.md @@ -1,8 +1,13 @@ -# no-empty-label +--- +title: no-empty-label +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-empty-label.md + +--- Disallows labels for anything other than loops and switches. -(removed) This rule was **removed** in ESLint v2.0 and **replaced** by the [no-labels](no-labels.md) rule. +(removed) This rule was **removed** in ESLint v2.0 and **replaced** by the [no-labels](no-labels) rule. Labeled statements are only used in conjunction with labeled break and continue statements. ECMAScript has no goto statement. @@ -36,6 +41,6 @@ If you don't want to be notified about usage of labels, then it's safe to disabl ## Related Rules -* [no-labels](./no-labels.md) -* [no-label-var](./no-label-var.md) -* [no-unused-labels](./no-unused-labels.md) +* [no-labels](./no-labels) +* [no-label-var](./no-label-var) +* [no-unused-labels](./no-unused-labels) diff --git a/docs/src/rules/no-empty-pattern.md b/docs/src/rules/no-empty-pattern.md index 407b26d1698..93b0865b677 100644 --- a/docs/src/rules/no-empty-pattern.md +++ b/docs/src/rules/no-empty-pattern.md @@ -1,4 +1,11 @@ -# no-empty-pattern +--- +title: no-empty-pattern +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-empty-pattern.md +rule_type: problem +--- + + Disallows empty destructuring patterns. diff --git a/docs/src/rules/no-empty.md b/docs/src/rules/no-empty.md index 50fd84d1672..cf3ab39d1b9 100644 --- a/docs/src/rules/no-empty.md +++ b/docs/src/rules/no-empty.md @@ -1,4 +1,11 @@ -# no-empty +--- +title: no-empty +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-empty.md +rule_type: suggestion +--- + + Disallows empty block statements. @@ -88,4 +95,4 @@ If you intentionally use empty block statements then you can disable this rule. ## Related Rules -* [no-empty-function](./no-empty-function.md) +* [no-empty-function](./no-empty-function) diff --git a/docs/src/rules/no-eq-null.md b/docs/src/rules/no-eq-null.md index ef810798b32..fdacac401ad 100644 --- a/docs/src/rules/no-eq-null.md +++ b/docs/src/rules/no-eq-null.md @@ -1,4 +1,9 @@ -# no-eq-null +--- +title: no-eq-null +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-eq-null.md +rule_type: suggestion +--- Disallows `null` comparisons without type-checking operators, diff --git a/docs/src/rules/no-eval.md b/docs/src/rules/no-eval.md index 9c00698f98d..35cbc7ee193 100644 --- a/docs/src/rules/no-eval.md +++ b/docs/src/rules/no-eval.md @@ -1,4 +1,9 @@ -# no-eval +--- +title: no-eval +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-eval.md +rule_type: suggestion +--- Disallows eval(). @@ -149,7 +154,7 @@ global.eval("var a = 0"); ## Related Rules -* [no-implied-eval](no-implied-eval.md) +* [no-implied-eval](no-implied-eval) ## Further Reading diff --git a/docs/src/rules/no-ex-assign.md b/docs/src/rules/no-ex-assign.md index 1c697162baf..233ec239010 100644 --- a/docs/src/rules/no-ex-assign.md +++ b/docs/src/rules/no-ex-assign.md @@ -1,4 +1,11 @@ -# no-ex-assign +--- +title: no-ex-assign +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-ex-assign.md +rule_type: problem +--- + + Disallows reassigning exceptions in `catch` clauses. diff --git a/docs/src/rules/no-extend-native.md b/docs/src/rules/no-extend-native.md index b562fdc3e0a..d0be66af56d 100644 --- a/docs/src/rules/no-extend-native.md +++ b/docs/src/rules/no-extend-native.md @@ -1,4 +1,9 @@ -# no-extend-native +--- +title: no-extend-native +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-extend-native.md +rule_type: suggestion +--- Disallows extending of native objects. @@ -74,4 +79,4 @@ You may want to disable this rule when working with polyfills that try to patch ## Related Rules -* [no-global-assign](no-global-assign.md) +* [no-global-assign](no-global-assign) diff --git a/docs/src/rules/no-extra-bind.md b/docs/src/rules/no-extra-bind.md index 90d95ab6831..5a7d28f321f 100644 --- a/docs/src/rules/no-extra-bind.md +++ b/docs/src/rules/no-extra-bind.md @@ -1,4 +1,11 @@ -# no-extra-bind +--- +title: no-extra-bind +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-extra-bind.md +rule_type: suggestion +--- + + Disallows unnecessary function binding. diff --git a/docs/src/rules/no-extra-boolean-cast.md b/docs/src/rules/no-extra-boolean-cast.md index 67814ac2926..550f6985afd 100644 --- a/docs/src/rules/no-extra-boolean-cast.md +++ b/docs/src/rules/no-extra-boolean-cast.md @@ -1,4 +1,13 @@ -# no-extra-boolean-cast +--- +title: no-extra-boolean-cast +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-extra-boolean-cast.md +rule_type: suggestion +--- + + + + Disallows unnecessary boolean casts. diff --git a/docs/src/rules/no-extra-label.md b/docs/src/rules/no-extra-label.md index 3a7068e5c65..82b98c1dce0 100644 --- a/docs/src/rules/no-extra-label.md +++ b/docs/src/rules/no-extra-label.md @@ -1,4 +1,11 @@ -# no-extra-label +--- +title: no-extra-label +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-extra-label.md +rule_type: suggestion +--- + + Disallows unnecessary labels. @@ -79,6 +86,6 @@ If you don't want to be notified about usage of labels, then it's safe to disabl ## Related Rules -* [no-labels](./no-labels.md) -* [no-label-var](./no-label-var.md) -* [no-unused-labels](./no-unused-labels.md) +* [no-labels](./no-labels) +* [no-label-var](./no-label-var) +* [no-unused-labels](./no-unused-labels) diff --git a/docs/src/rules/no-extra-parens.md b/docs/src/rules/no-extra-parens.md index ccebf2dbc98..858734e4374 100644 --- a/docs/src/rules/no-extra-parens.md +++ b/docs/src/rules/no-extra-parens.md @@ -1,4 +1,11 @@ -# no-extra-parens +--- +title: no-extra-parens +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-extra-parens.md +rule_type: layout +--- + + Disallows unnecessary parentheses. @@ -8,9 +15,9 @@ This rule restricts the use of parentheses to only where they are necessary. This rule always ignores extra parentheses around the following: -* RegExp literals such as `(/abc/).test(var)` to avoid conflicts with the [wrap-regex](wrap-regex.md) rule -* immediately-invoked function expressions (also known as IIFEs) such as `var x = (function () {})();` and `var x = (function () {}());` to avoid conflicts with the [wrap-iife](wrap-iife.md) rule -* arrow function arguments to avoid conflicts with the [arrow-parens](arrow-parens.md) rule +* RegExp literals such as `(/abc/).test(var)` to avoid conflicts with the [wrap-regex](wrap-regex) rule +* immediately-invoked function expressions (also known as IIFEs) such as `var x = (function () {})();` and `var x = (function () {}());` to avoid conflicts with the [wrap-iife](wrap-iife) rule +* arrow function arguments to avoid conflicts with the [arrow-parens](arrow-parens) rule ## Options @@ -293,9 +300,9 @@ typeof (a); ## Related Rules -* [arrow-parens](arrow-parens.md) -* [no-cond-assign](no-cond-assign.md) -* [no-return-assign](no-return-assign.md) +* [arrow-parens](arrow-parens) +* [no-cond-assign](no-cond-assign) +* [no-return-assign](no-return-assign) ## Further Reading diff --git a/docs/src/rules/no-extra-semi.md b/docs/src/rules/no-extra-semi.md index c37ca03a054..6aea002ebc9 100644 --- a/docs/src/rules/no-extra-semi.md +++ b/docs/src/rules/no-extra-semi.md @@ -1,4 +1,13 @@ -# no-extra-semi +--- +title: no-extra-semi +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-extra-semi.md +rule_type: suggestion +--- + + + + Disallows unnecessary semicolons. @@ -66,5 +75,5 @@ If you intentionally use extra semicolons then you can disable this rule. ## Related Rules -* [semi](semi.md) -* [semi-spacing](semi-spacing.md) +* [semi](semi) +* [semi-spacing](semi-spacing) diff --git a/docs/src/rules/no-extra-strict.md b/docs/src/rules/no-extra-strict.md index f39848be3bd..f2627ebafda 100644 --- a/docs/src/rules/no-extra-strict.md +++ b/docs/src/rules/no-extra-strict.md @@ -1,8 +1,13 @@ -# no-extra-strict +--- +title: no-extra-strict +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-extra-strict.md + +--- Disallows strict mode directives when already in strict mode. -(removed) This rule was **removed** in ESLint v1.0 and **replaced** by the [strict](strict.md) rule. The `"global"` or `"function"` options in the new rule are similar to the removed rule. +(removed) This rule was **removed** in ESLint v1.0 and **replaced** by the [strict](strict) rule. The `"global"` or `"function"` options in the new rule are similar to the removed rule. The `"use strict";` directive applies to the scope in which it appears and all inner scopes contained within that scope. Therefore, using the `"use strict";` directive in one of these inner scopes is unnecessary. diff --git a/docs/src/rules/no-fallthrough.md b/docs/src/rules/no-fallthrough.md index 8adb37629c1..bb7c618721b 100644 --- a/docs/src/rules/no-fallthrough.md +++ b/docs/src/rules/no-fallthrough.md @@ -1,4 +1,11 @@ -# no-fallthrough +--- +title: no-fallthrough +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-fallthrough.md +rule_type: problem +--- + + Disallows case statement fallthroughs. @@ -190,4 +197,4 @@ If you don't want to enforce that each `case` statement should end with a `throw ## Related Rules -* [default-case](default-case.md) +* [default-case](default-case) diff --git a/docs/src/rules/no-floating-decimal.md b/docs/src/rules/no-floating-decimal.md index 991cf65e772..da348a152ac 100644 --- a/docs/src/rules/no-floating-decimal.md +++ b/docs/src/rules/no-floating-decimal.md @@ -1,4 +1,11 @@ -# no-floating-decimal +--- +title: no-floating-decimal +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-floating-decimal.md +rule_type: suggestion +--- + + Disallows leading or trailing decimal points in numeric literals. diff --git a/docs/src/rules/no-func-assign.md b/docs/src/rules/no-func-assign.md index 24ba713d12f..cbd56279286 100644 --- a/docs/src/rules/no-func-assign.md +++ b/docs/src/rules/no-func-assign.md @@ -1,4 +1,11 @@ -# no-func-assign +--- +title: no-func-assign +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-func-assign.md +rule_type: problem +--- + + Disallows reassigning `function` declarations. diff --git a/docs/src/rules/no-global-assign.md b/docs/src/rules/no-global-assign.md index cd18f8a6d40..b5be6d41e93 100644 --- a/docs/src/rules/no-global-assign.md +++ b/docs/src/rules/no-global-assign.md @@ -1,4 +1,11 @@ -# no-global-assign +--- +title: no-global-assign +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-global-assign.md +rule_type: suggestion +--- + + Disallows assignment to native objects or read-only global variables. @@ -86,6 +93,6 @@ If you are trying to override one of the native objects. ## Related Rules -* [no-extend-native](no-extend-native.md) -* [no-redeclare](no-redeclare.md) -* [no-shadow](no-shadow.md) +* [no-extend-native](no-extend-native) +* [no-redeclare](no-redeclare) +* [no-shadow](no-shadow) diff --git a/docs/src/rules/no-implicit-coercion.md b/docs/src/rules/no-implicit-coercion.md index 6c77b25fb23..cc1338c72fe 100644 --- a/docs/src/rules/no-implicit-coercion.md +++ b/docs/src/rules/no-implicit-coercion.md @@ -1,4 +1,11 @@ -# no-implicit-coercion +--- +title: no-implicit-coercion +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-implicit-coercion.md +rule_type: suggestion +--- + + Disallows shorthand type conversions. diff --git a/docs/src/rules/no-implicit-globals.md b/docs/src/rules/no-implicit-globals.md index efc3a6f28ff..c8a0a542f68 100644 --- a/docs/src/rules/no-implicit-globals.md +++ b/docs/src/rules/no-implicit-globals.md @@ -1,4 +1,9 @@ -# no-implicit-globals +--- +title: no-implicit-globals +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-implicit-globals.md +rule_type: suggestion +--- Disallows declarations in the global scope. @@ -218,8 +223,8 @@ In the case of an ES module, if you don't want this rule to warn you about the r ## Related Rules -* [no-undef](no-undef.md) -* [no-global-assign](no-global-assign.md) +* [no-undef](no-undef) +* [no-global-assign](no-global-assign) ## Further Reading diff --git a/docs/src/rules/no-implied-eval.md b/docs/src/rules/no-implied-eval.md index 59d1ac976b5..48af9609054 100644 --- a/docs/src/rules/no-implied-eval.md +++ b/docs/src/rules/no-implied-eval.md @@ -1,4 +1,9 @@ -# no-implied-eval +--- +title: no-implied-eval +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-implied-eval.md +rule_type: suggestion +--- Disallows the use of `eval()`-like methods. @@ -61,4 +66,4 @@ If you want to allow `setTimeout()` and `setInterval()` with string arguments, t ## Related Rules -* [no-eval](no-eval.md) +* [no-eval](no-eval) diff --git a/docs/src/rules/no-import-assign.md b/docs/src/rules/no-import-assign.md index 9aa66b8efc1..56844f47727 100644 --- a/docs/src/rules/no-import-assign.md +++ b/docs/src/rules/no-import-assign.md @@ -1,4 +1,11 @@ -# no-import-assign +--- +title: no-import-assign +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-import-assign.md +rule_type: problem +--- + + Disallows assigning to imported bindings. diff --git a/docs/src/rules/no-inline-comments.md b/docs/src/rules/no-inline-comments.md index 504f77bc1c3..4ef95d8f154 100644 --- a/docs/src/rules/no-inline-comments.md +++ b/docs/src/rules/no-inline-comments.md @@ -1,4 +1,9 @@ -# no-inline-comments +--- +title: no-inline-comments +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-inline-comments.md +rule_type: suggestion +--- Disallows inline comments after code. diff --git a/docs/src/rules/no-inner-declarations.md b/docs/src/rules/no-inner-declarations.md index a6d1e899db3..5753d4107f5 100644 --- a/docs/src/rules/no-inner-declarations.md +++ b/docs/src/rules/no-inner-declarations.md @@ -1,4 +1,11 @@ -# no-inner-declarations +--- +title: no-inner-declarations +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-inner-declarations.md +rule_type: problem +--- + + Disallows variable or `function` declarations in nested blocks. @@ -178,4 +185,4 @@ class C { ## When Not To Use It -The function declaration portion rule will be rendered obsolete when [block-scoped functions](https://bugzilla.mozilla.org/show_bug.cgi?id=585536) land in ES6, but until then, it should be left on to enforce valid constructions. Disable checking variable declarations when using [block-scoped-var](block-scoped-var.md) or if declaring variables in nested blocks is acceptable despite hoisting. +The function declaration portion rule will be rendered obsolete when [block-scoped functions](https://bugzilla.mozilla.org/show_bug.cgi?id=585536) land in ES6, but until then, it should be left on to enforce valid constructions. Disable checking variable declarations when using [block-scoped-var](block-scoped-var) or if declaring variables in nested blocks is acceptable despite hoisting. diff --git a/docs/src/rules/no-invalid-regexp.md b/docs/src/rules/no-invalid-regexp.md index 1dccd68f593..724cf2118c7 100644 --- a/docs/src/rules/no-invalid-regexp.md +++ b/docs/src/rules/no-invalid-regexp.md @@ -1,4 +1,11 @@ -# no-invalid-regexp +--- +title: no-invalid-regexp +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-invalid-regexp.md +rule_type: problem +--- + + Disallows invalid regular expression strings in `RegExp` constructors. diff --git a/docs/src/rules/no-invalid-this.md b/docs/src/rules/no-invalid-this.md index bbdc79cbcf5..4358deedeee 100644 --- a/docs/src/rules/no-invalid-this.md +++ b/docs/src/rules/no-invalid-this.md @@ -1,4 +1,9 @@ -# no-invalid-this +--- +title: no-invalid-this +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-invalid-this.md +rule_type: suggestion +--- Disallows use of `this` in contexts where the value of `this` is `undefined`. diff --git a/docs/src/rules/no-irregular-whitespace.md b/docs/src/rules/no-irregular-whitespace.md index eb366915ade..b99f1faf034 100644 --- a/docs/src/rules/no-irregular-whitespace.md +++ b/docs/src/rules/no-irregular-whitespace.md @@ -1,4 +1,11 @@ -# no-irregular-whitespace +--- +title: no-irregular-whitespace +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-irregular-whitespace.md +rule_type: problem +--- + + Disallows irregular whitespace characters. diff --git a/docs/src/rules/no-iterator.md b/docs/src/rules/no-iterator.md index 7405dd1295d..39116ee88c9 100644 --- a/docs/src/rules/no-iterator.md +++ b/docs/src/rules/no-iterator.md @@ -1,4 +1,9 @@ -# no-iterator +--- +title: no-iterator +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-iterator.md +rule_type: suggestion +--- Disallows the use of the `__iterator__` property. diff --git a/docs/src/rules/no-label-var.md b/docs/src/rules/no-label-var.md index a4a101f1a38..60f433d9421 100644 --- a/docs/src/rules/no-label-var.md +++ b/docs/src/rules/no-label-var.md @@ -1,4 +1,9 @@ -# no-label-var +--- +title: no-label-var +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-label-var.md +rule_type: suggestion +--- Disallows labels that are variable names. @@ -45,6 +50,6 @@ If you don't want to be notified about usage of labels, then it's safe to disabl ## Related Rules -* [no-extra-label](./no-extra-label.md) -* [no-labels](./no-labels.md) -* [no-unused-labels](./no-unused-labels.md) +* [no-extra-label](./no-extra-label) +* [no-labels](./no-labels) +* [no-unused-labels](./no-unused-labels) diff --git a/docs/src/rules/no-labels.md b/docs/src/rules/no-labels.md index 6758a14329f..fdf9231c597 100644 --- a/docs/src/rules/no-labels.md +++ b/docs/src/rules/no-labels.md @@ -1,4 +1,9 @@ -# no-labels +--- +title: no-labels +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-labels.md +rule_type: suggestion +--- Disallows labeled statements. @@ -120,6 +125,6 @@ If you need to use labeled statements everywhere, then you can safely disable th ## Related Rules -* [no-extra-label](./no-extra-label.md) -* [no-label-var](./no-label-var.md) -* [no-unused-labels](./no-unused-labels.md) +* [no-extra-label](./no-extra-label) +* [no-label-var](./no-label-var) +* [no-unused-labels](./no-unused-labels) diff --git a/docs/src/rules/no-lone-blocks.md b/docs/src/rules/no-lone-blocks.md index 2856c92820f..c3ee3c3d69f 100644 --- a/docs/src/rules/no-lone-blocks.md +++ b/docs/src/rules/no-lone-blocks.md @@ -1,4 +1,9 @@ -# no-lone-blocks +--- +title: no-lone-blocks +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-lone-blocks.md +rule_type: suggestion +--- Disallows unnecessary nested blocks. diff --git a/docs/src/rules/no-lonely-if.md b/docs/src/rules/no-lonely-if.md index 25c8d39f9b1..8f62be51694 100644 --- a/docs/src/rules/no-lonely-if.md +++ b/docs/src/rules/no-lonely-if.md @@ -1,4 +1,11 @@ -# no-lonely-if +--- +title: no-lonely-if +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-lonely-if.md +rule_type: suggestion +--- + + Disallows `if` statements as the only statement in `else` blocks. diff --git a/docs/src/rules/no-loop-func.md b/docs/src/rules/no-loop-func.md index 05b3ad88ba2..9ab8e60e480 100644 --- a/docs/src/rules/no-loop-func.md +++ b/docs/src/rules/no-loop-func.md @@ -1,4 +1,9 @@ -# no-loop-func +--- +title: no-loop-func +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-loop-func.md +rule_type: suggestion +--- Disallows functions in loops. diff --git a/docs/src/rules/no-loss-of-precision.md b/docs/src/rules/no-loss-of-precision.md index f2dcf99d717..b8a4050c529 100644 --- a/docs/src/rules/no-loss-of-precision.md +++ b/docs/src/rules/no-loss-of-precision.md @@ -1,4 +1,11 @@ -# no-loss-of-precision +--- +title: no-loss-of-precision +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-loss-of-precision.md +rule_type: problem +--- + + Disallows number literals that lose precision. diff --git a/docs/src/rules/no-magic-numbers.md b/docs/src/rules/no-magic-numbers.md index 9e59c736e79..f53d2e433b0 100644 --- a/docs/src/rules/no-magic-numbers.md +++ b/docs/src/rules/no-magic-numbers.md @@ -1,4 +1,9 @@ -# no-magic-numbers +--- +title: no-magic-numbers +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-magic-numbers.md +rule_type: suggestion +--- Disallows magic numbers. diff --git a/docs/src/rules/no-misleading-character-class.md b/docs/src/rules/no-misleading-character-class.md index 18744bf8456..005127abf48 100644 --- a/docs/src/rules/no-misleading-character-class.md +++ b/docs/src/rules/no-misleading-character-class.md @@ -1,4 +1,11 @@ -# no-misleading-character-class +--- +title: no-misleading-character-class +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-misleading-character-class.md +rule_type: problem +--- + + Disallows characters which are made with multiple code points in character class syntax. diff --git a/docs/src/rules/no-mixed-operators.md b/docs/src/rules/no-mixed-operators.md index a5df9f0e887..48f8849a70b 100644 --- a/docs/src/rules/no-mixed-operators.md +++ b/docs/src/rules/no-mixed-operators.md @@ -1,4 +1,9 @@ -# no-mixed-operators +--- +title: no-mixed-operators +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-mixed-operators.md +rule_type: suggestion +--- Disallows mixes of different operators. @@ -42,8 +47,8 @@ will generate This rule checks `BinaryExpression`, `LogicalExpression` and `ConditionalExpression`. -This rule may conflict with [no-extra-parens](no-extra-parens.md) rule. -If you use both this and [no-extra-parens](no-extra-parens.md) rule together, you need to use the `nestedBinaryExpressions` option of [no-extra-parens](no-extra-parens.md) rule. +This rule may conflict with [no-extra-parens](no-extra-parens) rule. +If you use both this and [no-extra-parens](no-extra-parens) rule together, you need to use the `nestedBinaryExpressions` option of [no-extra-parens](no-extra-parens) rule. Examples of **incorrect** code for this rule: @@ -192,4 +197,4 @@ If you don't want to be notified about mixed operators, then it's safe to disabl ## Related Rules -* [no-extra-parens](no-extra-parens.md) +* [no-extra-parens](no-extra-parens) diff --git a/docs/src/rules/no-mixed-requires.md b/docs/src/rules/no-mixed-requires.md index 9b22c18588a..4137e9a66fb 100644 --- a/docs/src/rules/no-mixed-requires.md +++ b/docs/src/rules/no-mixed-requires.md @@ -1,4 +1,9 @@ -# no-mixed-requires +--- +title: no-mixed-requires +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-mixed-requires.md +rule_type: suggestion +--- Disallows `require` calls to be mixed with regular variable declarations. diff --git a/docs/src/rules/no-mixed-spaces-and-tabs.md b/docs/src/rules/no-mixed-spaces-and-tabs.md index 4333a835c90..d53fc786f35 100644 --- a/docs/src/rules/no-mixed-spaces-and-tabs.md +++ b/docs/src/rules/no-mixed-spaces-and-tabs.md @@ -1,4 +1,11 @@ -# no-mixed-spaces-and-tabs +--- +title: no-mixed-spaces-and-tabs +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-mixed-spaces-and-tabs.md +rule_type: layout +--- + + Disallows mixed spaces and tabs for indentation. diff --git a/docs/src/rules/no-multi-assign.md b/docs/src/rules/no-multi-assign.md index 8c49635d5d9..8ebc10b38f0 100644 --- a/docs/src/rules/no-multi-assign.md +++ b/docs/src/rules/no-multi-assign.md @@ -1,4 +1,9 @@ -# no-multi-assign +--- +title: no-multi-assign +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-multi-assign.md +rule_type: suggestion +--- Disallows use of chained assignment expressions. @@ -98,4 +103,4 @@ class Foo { ## Related Rules -* [max-statements-per-line](max-statements-per-line.md) +* [max-statements-per-line](max-statements-per-line) diff --git a/docs/src/rules/no-multi-spaces.md b/docs/src/rules/no-multi-spaces.md index 47fa143cc98..2e93c4571ee 100644 --- a/docs/src/rules/no-multi-spaces.md +++ b/docs/src/rules/no-multi-spaces.md @@ -1,4 +1,11 @@ -# no-multi-spaces +--- +title: no-multi-spaces +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-multi-spaces.md +rule_type: layout +--- + + Disallows multiple consecutive spaces. @@ -106,7 +113,7 @@ To avoid contradictions with other rules that require multiple spaces, this rule This option is an object that expects property names to be AST node types as defined by [ESTree](https://github.com/estree/estree). The easiest way to determine the node types for `exceptions` is to use [AST Explorer](https://astexplorer.net/) with the espree parser. -Only the `Property` node type is ignored by default, because for the [key-spacing](key-spacing.md) rule some alignment options require multiple spaces in properties of object literals. +Only the `Property` node type is ignored by default, because for the [key-spacing](key-spacing) rule some alignment options require multiple spaces in properties of object literals. Examples of **correct** code for the default `"exceptions": { "Property": true }` option: @@ -164,10 +171,10 @@ If you don't want to check and disallow multiple spaces, then you should turn th ## Related Rules -* [key-spacing](key-spacing.md) -* [space-infix-ops](space-infix-ops.md) -* [space-in-brackets](space-in-brackets.md) (deprecated) -* [space-in-parens](space-in-parens.md) -* [space-after-keywords](space-after-keywords.md) -* [space-unary-ops](space-unary-ops.md) -* [space-return-throw-case](space-return-throw-case.md) +* [key-spacing](key-spacing) +* [space-infix-ops](space-infix-ops) +* [space-in-brackets](space-in-brackets) (deprecated) +* [space-in-parens](space-in-parens) +* [space-after-keywords](space-after-keywords) +* [space-unary-ops](space-unary-ops) +* [space-return-throw-case](space-return-throw-case) diff --git a/docs/src/rules/no-multi-str.md b/docs/src/rules/no-multi-str.md index e520a824061..caeb62defce 100644 --- a/docs/src/rules/no-multi-str.md +++ b/docs/src/rules/no-multi-str.md @@ -1,4 +1,9 @@ -# no-multi-str +--- +title: no-multi-str +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-multi-str.md +rule_type: suggestion +--- Disallows multiline strings. diff --git a/docs/src/rules/no-multiple-empty-lines.md b/docs/src/rules/no-multiple-empty-lines.md index 3bb7a6dc2a4..8da7a54dbce 100644 --- a/docs/src/rules/no-multiple-empty-lines.md +++ b/docs/src/rules/no-multiple-empty-lines.md @@ -1,4 +1,11 @@ -# no-multiple-empty-lines +--- +title: no-multiple-empty-lines +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-multiple-empty-lines.md +rule_type: layout +--- + + Disallows multiple empty lines. @@ -26,7 +33,6 @@ Examples of **incorrect** code for this rule with the default `{ "max": 2 }` opt var foo = 5; - var bar = 3; ``` @@ -37,7 +43,6 @@ Examples of **correct** code for this rule with the default `{ "max": 2 }` optio var foo = 5; - var bar = 3; ``` @@ -50,10 +55,8 @@ Examples of **incorrect** code for this rule with the `{ max: 2, maxEOF: 0 }` op var foo = 5; - var bar = 3; - ``` Examples of **correct** code for this rule with the `{ max: 2, maxEOF: 0 }` options: @@ -63,7 +66,6 @@ Examples of **correct** code for this rule with the `{ max: 2, maxEOF: 0 }` opti var foo = 5; - var bar = 3; ``` @@ -101,10 +103,8 @@ Examples of **incorrect** code for this rule with the `{ max: 2, maxBOF: 1 }` op ```js /*eslint no-multiple-empty-lines: ["error", { "max": 2, "maxBOF": 1 }]*/ - var foo = 5; - var bar = 3; ``` @@ -115,7 +115,6 @@ Examples of **correct** code for this rule with the `{ max: 2, maxBOF: 1 }` opti var foo = 5; - var bar = 3; ``` diff --git a/docs/src/rules/no-native-reassign.md b/docs/src/rules/no-native-reassign.md index ca668413818..f66a09ca48d 100644 --- a/docs/src/rules/no-native-reassign.md +++ b/docs/src/rules/no-native-reassign.md @@ -1,8 +1,13 @@ -# no-native-reassign +--- +title: no-native-reassign +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-native-reassign.md +rule_type: suggestion +--- Disallows reassignment of native objects. -This rule was **deprecated** in ESLint v3.3.0 and replaced by the [no-global-assign](no-global-assign.md) rule. +This rule was **deprecated** in ESLint v3.3.0 and replaced by the [no-global-assign](no-global-assign) rule. JavaScript environments contain a number of built-in global variables, such as `window` in browsers and `process` in Node.js. In almost all cases, you don't want to assign a value to these global variables as doing so could result in losing access to important functionality. For example, you probably don't want to do this in browser code: @@ -88,6 +93,6 @@ If you are trying to override one of the native objects. ## Related Rules -* [no-extend-native](no-extend-native.md) -* [no-redeclare](no-redeclare.md) -* [no-shadow](no-shadow.md) +* [no-extend-native](no-extend-native) +* [no-redeclare](no-redeclare) +* [no-shadow](no-shadow) diff --git a/docs/src/rules/no-negated-condition.md b/docs/src/rules/no-negated-condition.md index cb2b3f66bcf..c6f62f0f08c 100644 --- a/docs/src/rules/no-negated-condition.md +++ b/docs/src/rules/no-negated-condition.md @@ -1,4 +1,9 @@ -# no-negated-condition +--- +title: no-negated-condition +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-negated-condition.md +rule_type: suggestion +--- Disallows negated conditions. diff --git a/docs/src/rules/no-negated-in-lhs.md b/docs/src/rules/no-negated-in-lhs.md index 16bdfd09288..052b863202d 100644 --- a/docs/src/rules/no-negated-in-lhs.md +++ b/docs/src/rules/no-negated-in-lhs.md @@ -1,8 +1,13 @@ -# no-negated-in-lhs +--- +title: no-negated-in-lhs +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-negated-in-lhs.md +rule_type: problem +--- Disallows negating the left operand in `in` expressions. -This rule was **deprecated** in ESLint v3.3.0 and replaced by the [no-unsafe-negation](no-unsafe-negation.md) rule. +This rule was **deprecated** in ESLint v3.3.0 and replaced by the [no-unsafe-negation](no-unsafe-negation) rule. Just as developers might type `-a + b` when they mean `-(a + b)` for the negative of a sum, they might type `!key in object` by mistake when they almost certainly mean `!(key in object)` to test that a key is not in an object. diff --git a/docs/src/rules/no-nested-ternary.md b/docs/src/rules/no-nested-ternary.md index 9f359360db0..a9194ff3064 100644 --- a/docs/src/rules/no-nested-ternary.md +++ b/docs/src/rules/no-nested-ternary.md @@ -1,4 +1,9 @@ -# no-nested-ternary +--- +title: no-nested-ternary +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-nested-ternary.md +rule_type: suggestion +--- Disallows nested ternary expressions. @@ -42,5 +47,5 @@ if (foo) { ## Related Rules -* [no-ternary](no-ternary.md) -* [no-unneeded-ternary](no-unneeded-ternary.md) +* [no-ternary](no-ternary) +* [no-unneeded-ternary](no-unneeded-ternary) diff --git a/docs/src/rules/no-new-func.md b/docs/src/rules/no-new-func.md index dd2b325aead..28e663b4455 100644 --- a/docs/src/rules/no-new-func.md +++ b/docs/src/rules/no-new-func.md @@ -1,4 +1,9 @@ -# no-new-func +--- +title: no-new-func +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-new-func.md +rule_type: suggestion +--- Disallows `new` operators with the `Function` object. diff --git a/docs/src/rules/no-new-object.md b/docs/src/rules/no-new-object.md index 7dd70053596..96533e5f03d 100644 --- a/docs/src/rules/no-new-object.md +++ b/docs/src/rules/no-new-object.md @@ -1,4 +1,9 @@ -# no-new-object +--- +title: no-new-object +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-new-object.md +rule_type: suggestion +--- Disallows `new` operators with the `Object` object. @@ -51,5 +56,5 @@ If you wish to allow the use of the `Object` constructor, you can safely turn th ## Related Rules -* [no-array-constructor](no-array-constructor.md) -* [no-new-wrappers](no-new-wrappers.md) +* [no-array-constructor](no-array-constructor) +* [no-new-wrappers](no-new-wrappers) diff --git a/docs/src/rules/no-new-require.md b/docs/src/rules/no-new-require.md index 69001bc168b..13500baec20 100644 --- a/docs/src/rules/no-new-require.md +++ b/docs/src/rules/no-new-require.md @@ -1,4 +1,9 @@ -# no-new-require +--- +title: no-new-require +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-new-require.md +rule_type: suggestion +--- Disallows `new` operators with calls to `require`. diff --git a/docs/src/rules/no-new-symbol.md b/docs/src/rules/no-new-symbol.md index e5684e7911e..06e965d5d4e 100644 --- a/docs/src/rules/no-new-symbol.md +++ b/docs/src/rules/no-new-symbol.md @@ -1,4 +1,11 @@ -# no-new-symbol +--- +title: no-new-symbol +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-new-symbol.md +rule_type: problem +--- + + Disallows `new` operators with the `Symbol` object. @@ -33,7 +40,6 @@ Examples of **correct** code for this rule: var foo = Symbol('foo'); - // Ignores shadowed Symbol. function bar(Symbol) { const baz = new Symbol("baz"); diff --git a/docs/src/rules/no-new-wrappers.md b/docs/src/rules/no-new-wrappers.md index 04ef96117ac..91f2d1821dd 100644 --- a/docs/src/rules/no-new-wrappers.md +++ b/docs/src/rules/no-new-wrappers.md @@ -1,4 +1,9 @@ -# no-new-wrappers +--- +title: no-new-wrappers +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-new-wrappers.md +rule_type: suggestion +--- Disallows `new` operators with the `String`, `Number`, and `Boolean` objects. @@ -72,8 +77,8 @@ If you want to allow the use of primitive wrapper objects, then you can safely d ## Related Rules -* [no-array-constructor](no-array-constructor.md) -* [no-new-object](no-new-object.md) +* [no-array-constructor](no-array-constructor) +* [no-new-object](no-new-object) ## Further Reading diff --git a/docs/src/rules/no-new.md b/docs/src/rules/no-new.md index 0e7020c87e6..41d46310df0 100644 --- a/docs/src/rules/no-new.md +++ b/docs/src/rules/no-new.md @@ -1,4 +1,9 @@ -# no-new +--- +title: no-new +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-new.md +rule_type: suggestion +--- Disallows `new` operators outside of assignments or comparisons. diff --git a/docs/src/rules/no-nonoctal-decimal-escape.md b/docs/src/rules/no-nonoctal-decimal-escape.md index db8bf55193f..22b08a254c9 100644 --- a/docs/src/rules/no-nonoctal-decimal-escape.md +++ b/docs/src/rules/no-nonoctal-decimal-escape.md @@ -1,4 +1,13 @@ -# no-nonoctal-decimal-escape +--- +title: no-nonoctal-decimal-escape +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-nonoctal-decimal-escape.md +rule_type: suggestion +--- + + + + Disallows `\8` and `\9` escape sequences in string literals. @@ -57,7 +66,7 @@ var quux = "\0\u0038"; ## Related Rules -* [no-octal-escape](no-octal-escape.md) +* [no-octal-escape](no-octal-escape) ## Further Reading diff --git a/docs/src/rules/no-obj-calls.md b/docs/src/rules/no-obj-calls.md index 0d0c1e8b146..f8a3941037a 100644 --- a/docs/src/rules/no-obj-calls.md +++ b/docs/src/rules/no-obj-calls.md @@ -1,4 +1,11 @@ -# no-obj-calls +--- +title: no-obj-calls +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-obj-calls.md +rule_type: problem +--- + + Disallows calling global object properties as functions. diff --git a/docs/src/rules/no-octal-escape.md b/docs/src/rules/no-octal-escape.md index 3ff43f00c90..b6a06a4d7eb 100644 --- a/docs/src/rules/no-octal-escape.md +++ b/docs/src/rules/no-octal-escape.md @@ -1,4 +1,9 @@ -# no-octal-escape +--- +title: no-octal-escape +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-octal-escape.md +rule_type: suggestion +--- Disallows octal escape sequences in string literals. diff --git a/docs/src/rules/no-octal.md b/docs/src/rules/no-octal.md index 4757385c20d..513ac64781a 100644 --- a/docs/src/rules/no-octal.md +++ b/docs/src/rules/no-octal.md @@ -1,4 +1,11 @@ -# no-octal +--- +title: no-octal +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-octal.md +rule_type: suggestion +--- + + Disallows octal literals. diff --git a/docs/src/rules/no-param-reassign.md b/docs/src/rules/no-param-reassign.md index b5c86797769..08200d83828 100644 --- a/docs/src/rules/no-param-reassign.md +++ b/docs/src/rules/no-param-reassign.md @@ -1,4 +1,9 @@ -# no-param-reassign +--- +title: no-param-reassign +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-param-reassign.md +rule_type: suggestion +--- Disallows reassignment of function parameters. diff --git a/docs/src/rules/no-path-concat.md b/docs/src/rules/no-path-concat.md index 23ed0cd6e40..e419526769c 100644 --- a/docs/src/rules/no-path-concat.md +++ b/docs/src/rules/no-path-concat.md @@ -1,4 +1,9 @@ -# no-path-concat +--- +title: no-path-concat +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-path-concat.md +rule_type: suggestion +--- Disallows string concatenation when using `__dirname` and `__filename`. diff --git a/docs/src/rules/no-plusplus.md b/docs/src/rules/no-plusplus.md index f0c3b768440..5f93853717f 100644 --- a/docs/src/rules/no-plusplus.md +++ b/docs/src/rules/no-plusplus.md @@ -1,4 +1,9 @@ -# no-plusplus +--- +title: no-plusplus +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-plusplus.md +rule_type: suggestion +--- Disallows the unary operators `++` and `--`. diff --git a/docs/src/rules/no-process-env.md b/docs/src/rules/no-process-env.md index d7ce5a78165..9bd325cf218 100644 --- a/docs/src/rules/no-process-env.md +++ b/docs/src/rules/no-process-env.md @@ -1,4 +1,9 @@ -# no-process-env +--- +title: no-process-env +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-process-env.md +rule_type: suggestion +--- Disallows the use of `process.env`. diff --git a/docs/src/rules/no-process-exit.md b/docs/src/rules/no-process-exit.md index 53ddf1c4576..59913153395 100644 --- a/docs/src/rules/no-process-exit.md +++ b/docs/src/rules/no-process-exit.md @@ -1,4 +1,9 @@ -# no-process-exit +--- +title: no-process-exit +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-process-exit.md +rule_type: suggestion +--- Disallows the use of `process.exit()`. diff --git a/docs/src/rules/no-promise-executor-return.md b/docs/src/rules/no-promise-executor-return.md index 59076b55f4b..d57988512ae 100644 --- a/docs/src/rules/no-promise-executor-return.md +++ b/docs/src/rules/no-promise-executor-return.md @@ -1,4 +1,9 @@ -# no-promise-executor-return +--- +title: no-promise-executor-return +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-promise-executor-return.md +rule_type: problem +--- Disallows returning values from Promise executor functions. @@ -91,7 +96,7 @@ Promise.resolve(1); ## Related Rules -* [no-async-promise-executor](no-async-promise-executor.md) +* [no-async-promise-executor](no-async-promise-executor) ## Further Reading diff --git a/docs/src/rules/no-proto.md b/docs/src/rules/no-proto.md index fbc6b46114a..77063d3112f 100644 --- a/docs/src/rules/no-proto.md +++ b/docs/src/rules/no-proto.md @@ -1,4 +1,9 @@ -# no-proto +--- +title: no-proto +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-proto.md +rule_type: suggestion +--- Disallows the use of the `__proto__` property. diff --git a/docs/src/rules/no-prototype-builtins.md b/docs/src/rules/no-prototype-builtins.md index 93423d90845..c2e9f1d8ecf 100644 --- a/docs/src/rules/no-prototype-builtins.md +++ b/docs/src/rules/no-prototype-builtins.md @@ -1,4 +1,11 @@ -# no-prototype-builtins +--- +title: no-prototype-builtins +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-prototype-builtins.md +rule_type: problem +--- + + Disallows calling some `Object.prototype` methods directly on objects. diff --git a/docs/src/rules/no-redeclare.md b/docs/src/rules/no-redeclare.md index ed107f28c58..e0e2e75634e 100644 --- a/docs/src/rules/no-redeclare.md +++ b/docs/src/rules/no-redeclare.md @@ -1,4 +1,11 @@ -# no-redeclare +--- +title: no-redeclare +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-redeclare.md +rule_type: suggestion +--- + + Disallows variable redeclarations. @@ -79,8 +86,8 @@ var top = 0; The `browser` environment has many built-in global variables (for example, `top`). Some of built-in global variables cannot be redeclared. -Note that when using the `node` or `commonjs` environments (or `ecmaFeatures.globalReturn`, if using the default parser), the top scope of a program is not actually the global scope, but rather a "module" scope. When this is the case, declaring a variable named after a builtin global is not a redeclaration, but rather a shadowing of the global variable. In that case, the [`no-shadow`](no-shadow.md) rule with the `"builtinGlobals"` option should be used. +Note that when using the `node` or `commonjs` environments (or `ecmaFeatures.globalReturn`, if using the default parser), the top scope of a program is not actually the global scope, but rather a "module" scope. When this is the case, declaring a variable named after a builtin global is not a redeclaration, but rather a shadowing of the global variable. In that case, the [`no-shadow`](no-shadow) rule with the `"builtinGlobals"` option should be used. ## Related Rules -* [no-shadow](no-shadow.md) +* [no-shadow](no-shadow) diff --git a/docs/src/rules/no-regex-spaces.md b/docs/src/rules/no-regex-spaces.md index 158ee9ce878..2edf2e586f4 100644 --- a/docs/src/rules/no-regex-spaces.md +++ b/docs/src/rules/no-regex-spaces.md @@ -1,4 +1,13 @@ -# no-regex-spaces +--- +title: no-regex-spaces +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-regex-spaces.md +rule_type: suggestion +--- + + + + Disallows multiple spaces in regular expression literals. @@ -44,5 +53,5 @@ If you want to allow multiple spaces in a regular expression, then you can safel ## Related Rules -* [no-div-regex](no-div-regex.md) -* [no-control-regex](no-control-regex.md) +* [no-div-regex](no-div-regex) +* [no-control-regex](no-control-regex) diff --git a/docs/src/rules/no-reserved-keys.md b/docs/src/rules/no-reserved-keys.md index 8eb2b56ed3d..5644d0042cd 100644 --- a/docs/src/rules/no-reserved-keys.md +++ b/docs/src/rules/no-reserved-keys.md @@ -1,8 +1,13 @@ -# no-reserved-keys +--- +title: no-reserved-keys +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-reserved-keys.md + +--- Disallows unquoted reserved words as property names in object literals. -(removed) This rule was **removed** in ESLint v1.0 and **replaced** by the [quote-props](quote-props.md) rule. +(removed) This rule was **removed** in ESLint v1.0 and **replaced** by the [quote-props](quote-props) rule. ECMAScript 3 described as series of keywords and reserved words, such as `if` and `public`, that are used or intended to be used for a core language feature. The specification also indicated that these keywords and reserved words could not be used as object property names without being enclosed in strings. An error occurs in an ECMAScript 3 environment when you use a keyword or reserved word in an object literal. For example: diff --git a/docs/src/rules/no-restricted-exports.md b/docs/src/rules/no-restricted-exports.md index 9474e6eae29..e168c1cdca4 100644 --- a/docs/src/rules/no-restricted-exports.md +++ b/docs/src/rules/no-restricted-exports.md @@ -1,4 +1,9 @@ -# no-restricted-exports +--- +title: no-restricted-exports +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-restricted-exports.md +rule_type: suggestion +--- Disallows specified names in exports. diff --git a/docs/src/rules/no-restricted-globals.md b/docs/src/rules/no-restricted-globals.md index 4b7b9dfbb9b..5164b9f15c7 100644 --- a/docs/src/rules/no-restricted-globals.md +++ b/docs/src/rules/no-restricted-globals.md @@ -1,4 +1,9 @@ -# no-restricted-globals +--- +title: no-restricted-globals +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-restricted-globals.md +rule_type: suggestion +--- Disallows specific global variables. @@ -88,5 +93,5 @@ function onClick() { ## Related Rules -* [no-restricted-properties](no-restricted-properties.md) -* [no-restricted-syntax](no-restricted-syntax.md) +* [no-restricted-properties](no-restricted-properties) +* [no-restricted-syntax](no-restricted-syntax) diff --git a/docs/src/rules/no-restricted-imports.md b/docs/src/rules/no-restricted-imports.md index 3337ab83217..d4543c20e30 100644 --- a/docs/src/rules/no-restricted-imports.md +++ b/docs/src/rules/no-restricted-imports.md @@ -1,4 +1,9 @@ -# no-restricted-imports +--- +title: no-restricted-imports +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-restricted-imports.md +rule_type: suggestion +--- Disallows specific imports. diff --git a/docs/src/rules/no-restricted-modules.md b/docs/src/rules/no-restricted-modules.md index b82ebe40df7..a4ef2216cde 100644 --- a/docs/src/rules/no-restricted-modules.md +++ b/docs/src/rules/no-restricted-modules.md @@ -1,4 +1,9 @@ -# no-restricted-modules +--- +title: no-restricted-modules +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-restricted-modules.md +rule_type: suggestion +--- Disallows Node.js modules. diff --git a/docs/src/rules/no-restricted-properties.md b/docs/src/rules/no-restricted-properties.md index b2b2f128a9b..a2781c9d773 100644 --- a/docs/src/rules/no-restricted-properties.md +++ b/docs/src/rules/no-restricted-properties.md @@ -1,4 +1,9 @@ -# no-restricted-properties +--- +title: no-restricted-properties +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-restricted-properties.md +rule_type: suggestion +--- Disallows certain object properties. @@ -122,5 +127,5 @@ If you don't have any object/property combinations to restrict, you should not u ## Related Rules -* [no-restricted-globals](no-restricted-globals.md) -* [no-restricted-syntax](no-restricted-syntax.md) +* [no-restricted-globals](no-restricted-globals) +* [no-restricted-syntax](no-restricted-syntax) diff --git a/docs/src/rules/no-restricted-syntax.md b/docs/src/rules/no-restricted-syntax.md index 9b21aea5ba4..e64d809639e 100644 --- a/docs/src/rules/no-restricted-syntax.md +++ b/docs/src/rules/no-restricted-syntax.md @@ -1,4 +1,9 @@ -# no-restricted-syntax +--- +title: no-restricted-syntax +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-restricted-syntax.md +rule_type: suggestion +--- Disallows specified syntax. @@ -80,7 +85,7 @@ If you don't want to restrict your code from using any JavaScript features or sy ## Related Rules -* [no-alert](no-alert.md) -* [no-console](no-console.md) -* [no-debugger](no-debugger.md) -* [no-restricted-properties](no-restricted-properties.md) +* [no-alert](no-alert) +* [no-console](no-console) +* [no-debugger](no-debugger) +* [no-restricted-properties](no-restricted-properties) diff --git a/docs/src/rules/no-return-assign.md b/docs/src/rules/no-return-assign.md index 60d18a0805f..92f4cf715fc 100644 --- a/docs/src/rules/no-return-assign.md +++ b/docs/src/rules/no-return-assign.md @@ -1,4 +1,9 @@ -# no-return-assign +--- +title: no-return-assign +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-return-assign.md +rule_type: suggestion +--- Disallows assignment operators in `return` statements. diff --git a/docs/src/rules/no-return-await.md b/docs/src/rules/no-return-await.md index 1108ff1f146..2ec7bbe02f6 100644 --- a/docs/src/rules/no-return-await.md +++ b/docs/src/rules/no-return-await.md @@ -1,4 +1,9 @@ -# no-return-await +--- +title: no-return-await +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-return-await.md +rule_type: suggestion +--- Disallows unnecessary `return await`. diff --git a/docs/src/rules/no-script-url.md b/docs/src/rules/no-script-url.md index 82280bd9b38..582233cc0f8 100644 --- a/docs/src/rules/no-script-url.md +++ b/docs/src/rules/no-script-url.md @@ -1,4 +1,9 @@ -# no-script-url +--- +title: no-script-url +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-script-url.md +rule_type: suggestion +--- Disallows `javascript:` URLs. diff --git a/docs/src/rules/no-self-assign.md b/docs/src/rules/no-self-assign.md index e648f8fb895..1bc3e6c7d9e 100644 --- a/docs/src/rules/no-self-assign.md +++ b/docs/src/rules/no-self-assign.md @@ -1,4 +1,11 @@ -# no-self-assign +--- +title: no-self-assign +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-self-assign.md +rule_type: problem +--- + + Disallows assignments where both sides are exactly the same. diff --git a/docs/src/rules/no-self-compare.md b/docs/src/rules/no-self-compare.md index 00e09f8e3ae..744fbd8818c 100644 --- a/docs/src/rules/no-self-compare.md +++ b/docs/src/rules/no-self-compare.md @@ -1,4 +1,9 @@ -# no-self-compare +--- +title: no-self-compare +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-self-compare.md +rule_type: problem +--- Disallows comparisons where both sides are exactly the same. diff --git a/docs/src/rules/no-sequences.md b/docs/src/rules/no-sequences.md index b6dfaf7a006..cb17caa7ccf 100644 --- a/docs/src/rules/no-sequences.md +++ b/docs/src/rules/no-sequences.md @@ -1,4 +1,9 @@ -# no-sequences +--- +title: no-sequences +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-sequences.md +rule_type: suggestion +--- Disallows use of the comma operator. diff --git a/docs/src/rules/no-setter-return.md b/docs/src/rules/no-setter-return.md index 9c39199020f..527411134b6 100644 --- a/docs/src/rules/no-setter-return.md +++ b/docs/src/rules/no-setter-return.md @@ -1,4 +1,11 @@ -# no-setter-return +--- +title: no-setter-return +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-setter-return.md +rule_type: problem +--- + + Disallows returning values from setters. @@ -96,7 +103,7 @@ Object.defineProperty(foo, "bar", { ## Related Rules -* [getter-return](getter-return.md) +* [getter-return](getter-return) ## Further Reading diff --git a/docs/src/rules/no-shadow-restricted-names.md b/docs/src/rules/no-shadow-restricted-names.md index 7b2328f3b90..e1c13853ac4 100644 --- a/docs/src/rules/no-shadow-restricted-names.md +++ b/docs/src/rules/no-shadow-restricted-names.md @@ -1,4 +1,11 @@ -# no-shadow-restricted-names +--- +title: no-shadow-restricted-names +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-shadow-restricted-names.md +rule_type: suggestion +--- + + Disallows identifiers from shadowing restricted names. @@ -41,7 +48,7 @@ var undefined; ## Related Rules -* [no-shadow](no-shadow.md) +* [no-shadow](no-shadow) ## Further Reading diff --git a/docs/src/rules/no-shadow.md b/docs/src/rules/no-shadow.md index 284b7a1b9a2..de033113bfe 100644 --- a/docs/src/rules/no-shadow.md +++ b/docs/src/rules/no-shadow.md @@ -1,4 +1,9 @@ -# no-shadow +--- +title: no-shadow +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-shadow.md +rule_type: suggestion +--- Disallows variable declarations from shadowing variables declared in the outer scope. @@ -196,7 +201,7 @@ The rationale for callback functions is the assumption that they will be called ## Related Rules -* [no-shadow-restricted-names](no-shadow-restricted-names.md) +* [no-shadow-restricted-names](no-shadow-restricted-names) ## Further Reading diff --git a/docs/src/rules/no-space-before-semi.md b/docs/src/rules/no-space-before-semi.md index a309312c372..60c2116fd8e 100644 --- a/docs/src/rules/no-space-before-semi.md +++ b/docs/src/rules/no-space-before-semi.md @@ -1,8 +1,13 @@ -# no-space-before-semi +--- +title: no-space-before-semi +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-space-before-semi.md + +--- Disallows spaces before semicolons. -(removed) This rule was **removed** in ESLint v1.0 and **replaced** by the [semi-spacing](semi-spacing.md) rule. +(removed) This rule was **removed** in ESLint v1.0 and **replaced** by the [semi-spacing](semi-spacing) rule. JavaScript allows for placing unnecessary spaces between an expression and the closing semicolon. @@ -41,5 +46,5 @@ var foo = "bar"; ## Related Rules -* [semi](semi.md) -* [no-extra-semi](no-extra-semi.md) +* [semi](semi) +* [no-extra-semi](no-extra-semi) diff --git a/docs/src/rules/no-spaced-func.md b/docs/src/rules/no-spaced-func.md index e4bf0993989..b06d81ae426 100644 --- a/docs/src/rules/no-spaced-func.md +++ b/docs/src/rules/no-spaced-func.md @@ -1,8 +1,15 @@ -# no-spaced-func +--- +title: no-spaced-func +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-spaced-func.md +rule_type: layout +--- + + Disallows spacing between function identifiers and their applications. -This rule was **deprecated** in ESLint v3.3.0 and replaced by the [func-call-spacing](func-call-spacing.md) rule. +This rule was **deprecated** in ESLint v3.3.0 and replaced by the [func-call-spacing](func-call-spacing) rule. While it's possible to have whitespace between the name of a function and the parentheses that execute it, such patterns tend to look more like errors. diff --git a/docs/src/rules/no-sparse-arrays.md b/docs/src/rules/no-sparse-arrays.md index 6720c4b9c38..4340619cb8d 100644 --- a/docs/src/rules/no-sparse-arrays.md +++ b/docs/src/rules/no-sparse-arrays.md @@ -1,4 +1,11 @@ -# no-sparse-arrays +--- +title: no-sparse-arrays +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-sparse-arrays.md +rule_type: problem +--- + + Disallows sparse arrays. diff --git a/docs/src/rules/no-sync.md b/docs/src/rules/no-sync.md index 57d33d93343..2c839f42e64 100644 --- a/docs/src/rules/no-sync.md +++ b/docs/src/rules/no-sync.md @@ -1,4 +1,9 @@ -# no-sync +--- +title: no-sync +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-sync.md +rule_type: suggestion +--- Disallows synchronous methods. diff --git a/docs/src/rules/no-tabs.md b/docs/src/rules/no-tabs.md index 29d8f34cc6a..fa26235ffce 100644 --- a/docs/src/rules/no-tabs.md +++ b/docs/src/rules/no-tabs.md @@ -1,4 +1,9 @@ -# no-tabs +--- +title: no-tabs +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-tabs.md +rule_type: layout +--- Disallows all tabs. diff --git a/docs/src/rules/no-template-curly-in-string.md b/docs/src/rules/no-template-curly-in-string.md index e8e0d7349e8..64b08187d94 100644 --- a/docs/src/rules/no-template-curly-in-string.md +++ b/docs/src/rules/no-template-curly-in-string.md @@ -1,4 +1,9 @@ -# no-template-curly-in-string +--- +title: no-template-curly-in-string +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-template-curly-in-string.md +rule_type: problem +--- Disallows template literal placeholder syntax in regular strings. diff --git a/docs/src/rules/no-ternary.md b/docs/src/rules/no-ternary.md index 357da016630..280862070c6 100644 --- a/docs/src/rules/no-ternary.md +++ b/docs/src/rules/no-ternary.md @@ -1,4 +1,9 @@ -# no-ternary +--- +title: no-ternary +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-ternary.md +rule_type: suggestion +--- Disallows ternary operators. @@ -48,5 +53,5 @@ function quux() { ## Related Rules -* [no-nested-ternary](no-nested-ternary.md) -* [no-unneeded-ternary](no-unneeded-ternary.md) +* [no-nested-ternary](no-nested-ternary) +* [no-unneeded-ternary](no-unneeded-ternary) diff --git a/docs/src/rules/no-this-before-super.md b/docs/src/rules/no-this-before-super.md index e783a876c33..7b679d85059 100644 --- a/docs/src/rules/no-this-before-super.md +++ b/docs/src/rules/no-this-before-super.md @@ -1,4 +1,11 @@ -# no-this-before-super +--- +title: no-this-before-super +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-this-before-super.md +rule_type: problem +--- + + Disallows use of `this`/`super` before calling `super()` in constructors. diff --git a/docs/src/rules/no-throw-literal.md b/docs/src/rules/no-throw-literal.md index 452a8afb755..52d5ad44236 100644 --- a/docs/src/rules/no-throw-literal.md +++ b/docs/src/rules/no-throw-literal.md @@ -1,4 +1,9 @@ -# no-throw-literal +--- +title: no-throw-literal +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-throw-literal.md +rule_type: suggestion +--- Restricts what can be thrown as an exception. diff --git a/docs/src/rules/no-trailing-spaces.md b/docs/src/rules/no-trailing-spaces.md index 0a94173ed84..515e8ad6f8c 100644 --- a/docs/src/rules/no-trailing-spaces.md +++ b/docs/src/rules/no-trailing-spaces.md @@ -1,4 +1,11 @@ -# no-trailing-spaces +--- +title: no-trailing-spaces +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-trailing-spaces.md +rule_type: layout +--- + + Disallows trailing whitespace at the end of lines. diff --git a/docs/src/rules/no-undef-init.md b/docs/src/rules/no-undef-init.md index f0dda6fab7a..830d219e8b1 100644 --- a/docs/src/rules/no-undef-init.md +++ b/docs/src/rules/no-undef-init.md @@ -1,4 +1,11 @@ -# no-undef-init +--- +title: no-undef-init +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-undef-init.md +rule_type: suggestion +--- + + Disallows initializing variables to `undefined`. @@ -125,5 +132,5 @@ for (i = 0; i < 10; i++) { ## Related Rules -* [no-undefined](no-undefined.md) -* [no-void](no-void.md) +* [no-undefined](no-undefined) +* [no-void](no-void) diff --git a/docs/src/rules/no-undef.md b/docs/src/rules/no-undef.md index 71f6b03294d..f3f99677911 100644 --- a/docs/src/rules/no-undef.md +++ b/docs/src/rules/no-undef.md @@ -1,4 +1,11 @@ -# no-undef +--- +title: no-undef +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-undef.md +rule_type: problem +--- + + Disallows the use of undeclared variables unless mentioned in `/*global */` comments. @@ -28,10 +35,10 @@ var bar = a + 1; ``` Note that this rule does not disallow assignments to read-only global variables. -See [no-global-assign](no-global-assign.md) if you also want to disallow those assignments. +See [no-global-assign](no-global-assign) if you also want to disallow those assignments. This rule also does not disallow redeclarations of global variables. -See [no-redeclare](no-redeclare.md) if you also want to disallow those redeclarations. +See [no-redeclare](no-redeclare) if you also want to disallow those redeclarations. ## Options @@ -70,7 +77,7 @@ if(typeof a === "string"){} ## Environments -For convenience, ESLint provides shortcuts that pre-define global variables exposed by popular libraries and runtime environments. This rule supports these environments, as listed in [Specifying Environments](../user-guide/configuring/language-options.md#specifying-environments). A few examples are given below. +For convenience, ESLint provides shortcuts that pre-define global variables exposed by popular libraries and runtime environments. This rule supports these environments, as listed in [Specifying Environments](../user-guide/configuring/language-options#specifying-environments). A few examples are given below. ### browser @@ -105,8 +112,8 @@ If explicit declaration of global variables is not to your taste. ## Related Rules -* [no-global-assign](no-global-assign.md) -* [no-redeclare](no-redeclare.md) +* [no-global-assign](no-global-assign) +* [no-redeclare](no-redeclare) ## Compatibility diff --git a/docs/src/rules/no-undefined.md b/docs/src/rules/no-undefined.md index 9313dfb23ba..54da12de5ce 100644 --- a/docs/src/rules/no-undefined.md +++ b/docs/src/rules/no-undefined.md @@ -1,4 +1,9 @@ -# no-undefined +--- +title: no-undefined +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-undefined.md +rule_type: suggestion +--- Disallows the use of `undefined` as an identifier. @@ -22,7 +27,7 @@ Because `undefined` can be overwritten or shadowed, reading `undefined` can give * Checking if a value is `undefined` should be done with `typeof`. * Using the `void` operator to generate the value of `undefined` if necessary. -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. +As an alternative, you can use the [no-global-assign](no-global-assign) and [no-shadow-restricted-names](no-shadow-restricted-names) 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 @@ -68,10 +73,10 @@ If you want to allow the use of `undefined` in your code, then you can safely tu ## Related Rules -* [no-undef-init](no-undef-init.md) -* [no-void](no-void.md) -* [no-shadow-restricted-names](no-shadow-restricted-names.md) -* [no-global-assign](no-global-assign.md) +* [no-undef-init](no-undef-init) +* [no-void](no-void) +* [no-shadow-restricted-names](no-shadow-restricted-names) +* [no-global-assign](no-global-assign) ## Further Reading diff --git a/docs/src/rules/no-underscore-dangle.md b/docs/src/rules/no-underscore-dangle.md index a4535d3f481..73b13244602 100644 --- a/docs/src/rules/no-underscore-dangle.md +++ b/docs/src/rules/no-underscore-dangle.md @@ -1,4 +1,9 @@ -# no-underscore-dangle +--- +title: no-underscore-dangle +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-underscore-dangle.md +rule_type: suggestion +--- Disallows dangling underscores in identifiers. diff --git a/docs/src/rules/no-unexpected-multiline.md b/docs/src/rules/no-unexpected-multiline.md index 65b18bf8389..18a0b828a38 100644 --- a/docs/src/rules/no-unexpected-multiline.md +++ b/docs/src/rules/no-unexpected-multiline.md @@ -1,8 +1,15 @@ -# no-unexpected-multiline +--- +title: no-unexpected-multiline +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-unexpected-multiline.md +rule_type: problem +--- + + Disallows confusing multiline expressions. -Semicolons are usually optional in JavaScript, because of automatic semicolon insertion (ASI). You can require or disallow semicolons with the [semi](./semi.md) rule. +Semicolons are usually optional in JavaScript, because of automatic semicolon insertion (ASI). You can require or disallow semicolons with the [semi](./semi) rule. The rules for ASI are relatively straightforward: As once described by Isaac Schlueter, a newline character always ends a statement, just like a semicolon, **except** where one of the following is true: @@ -67,10 +74,10 @@ tag `hello` You can turn this rule off if you are confident that you will not accidentally introduce code like this. -Note that the patterns considered problems are **not** flagged by the [semi](semi.md) rule. +Note that the patterns considered problems are **not** flagged by the [semi](semi) rule. ## Related Rules -* [func-call-spacing](func-call-spacing.md) -* [semi](semi.md) -* [space-unary-ops](space-unary-ops.md) +* [func-call-spacing](func-call-spacing) +* [semi](semi) +* [space-unary-ops](space-unary-ops) diff --git a/docs/src/rules/no-unmodified-loop-condition.md b/docs/src/rules/no-unmodified-loop-condition.md index 8a4c8cc9f5b..154d7c05d0f 100644 --- a/docs/src/rules/no-unmodified-loop-condition.md +++ b/docs/src/rules/no-unmodified-loop-condition.md @@ -1,4 +1,9 @@ -# no-unmodified-loop-condition +--- +title: no-unmodified-loop-condition +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-unmodified-loop-condition.md +rule_type: problem +--- Disallows unmodified conditions of loops. diff --git a/docs/src/rules/no-unneeded-ternary.md b/docs/src/rules/no-unneeded-ternary.md index 5d8575f5888..e1550e9f252 100644 --- a/docs/src/rules/no-unneeded-ternary.md +++ b/docs/src/rules/no-unneeded-ternary.md @@ -1,4 +1,11 @@ -# no-unneeded-ternary +--- +title: no-unneeded-ternary +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-unneeded-ternary.md +rule_type: suggestion +--- + + Disallows ternary operators when simpler alternatives exist. @@ -12,7 +19,6 @@ var isYes = answer === 1 ? true : false; // Good var isYes = answer === 1; - // Bad var isNo = answer === 1 ? false : true; @@ -90,5 +96,5 @@ You can turn this rule off if you are not concerned with unnecessary complexity ## Related Rules -* [no-ternary](no-ternary.md) -* [no-nested-ternary](no-nested-ternary.md) +* [no-ternary](no-ternary) +* [no-nested-ternary](no-nested-ternary) diff --git a/docs/src/rules/no-unreachable-loop.md b/docs/src/rules/no-unreachable-loop.md index 24668e9760c..c777d4807dd 100644 --- a/docs/src/rules/no-unreachable-loop.md +++ b/docs/src/rules/no-unreachable-loop.md @@ -1,4 +1,9 @@ -# no-unreachable-loop +--- +title: no-unreachable-loop +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-unreachable-loop.md +rule_type: problem +--- Disallows loops with a body that allows only one iteration. @@ -186,7 +191,7 @@ for (let i = 0; i < 10; i++) { ## Related Rules -* [no-unreachable](no-unreachable.md) -* [no-constant-condition](no-constant-condition.md) -* [no-unmodified-loop-condition](no-unmodified-loop-condition.md) -* [for-direction](for-direction.md) +* [no-unreachable](no-unreachable) +* [no-constant-condition](no-constant-condition) +* [no-unmodified-loop-condition](no-unmodified-loop-condition) +* [for-direction](for-direction) diff --git a/docs/src/rules/no-unreachable.md b/docs/src/rules/no-unreachable.md index d4689c0b1ee..2af7ae0407c 100644 --- a/docs/src/rules/no-unreachable.md +++ b/docs/src/rules/no-unreachable.md @@ -1,4 +1,11 @@ -# no-unreachable +--- +title: no-unreachable +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-unreachable.md +rule_type: problem +--- + + Disallows unreachable code after `return`, `throw`, `continue`, and `break` statements. diff --git a/docs/src/rules/no-unsafe-finally.md b/docs/src/rules/no-unsafe-finally.md index 56325e2a9c7..51b4afe2786 100644 --- a/docs/src/rules/no-unsafe-finally.md +++ b/docs/src/rules/no-unsafe-finally.md @@ -1,4 +1,11 @@ -# no-unsafe-finally +--- +title: no-unsafe-finally +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-unsafe-finally.md +rule_type: problem +--- + + Disallows control flow statements in `finally` blocks. diff --git a/docs/src/rules/no-unsafe-negation.md b/docs/src/rules/no-unsafe-negation.md index 066bb5df6ee..a9379d58bfd 100644 --- a/docs/src/rules/no-unsafe-negation.md +++ b/docs/src/rules/no-unsafe-negation.md @@ -1,4 +1,13 @@ -# no-unsafe-negation +--- +title: no-unsafe-negation +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-unsafe-negation.md +rule_type: problem +--- + + + + Disallows negating the left operand of relational operators. diff --git a/docs/src/rules/no-unsafe-optional-chaining.md b/docs/src/rules/no-unsafe-optional-chaining.md index e57d6cd28d7..879662df4ea 100644 --- a/docs/src/rules/no-unsafe-optional-chaining.md +++ b/docs/src/rules/no-unsafe-optional-chaining.md @@ -1,4 +1,11 @@ -# no-unsafe-optional-chaining +--- +title: no-unsafe-optional-chaining +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-unsafe-optional-chaining.md +rule_type: problem +--- + + Disallows use of optional chaining in contexts where the `undefined` value is not allowed. diff --git a/docs/src/rules/no-unused-expressions.md b/docs/src/rules/no-unused-expressions.md index c6a3fab9af2..fb69dbd4909 100644 --- a/docs/src/rules/no-unused-expressions.md +++ b/docs/src/rules/no-unused-expressions.md @@ -1,4 +1,9 @@ -# no-unused-expressions +--- +title: no-unused-expressions +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-unused-expressions.md +rule_type: suggestion +--- Disallows unused expressions. diff --git a/docs/src/rules/no-unused-labels.md b/docs/src/rules/no-unused-labels.md index f400697cf3b..ecfeb3c36ac 100644 --- a/docs/src/rules/no-unused-labels.md +++ b/docs/src/rules/no-unused-labels.md @@ -1,4 +1,13 @@ -# no-unused-labels +--- +title: no-unused-labels +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-unused-labels.md +rule_type: suggestion +--- + + + + Disallows unused labels. @@ -65,6 +74,6 @@ If you don't want to be notified about unused labels, then it's safe to disable ## Related Rules -* [no-extra-label](./no-extra-label.md) -* [no-labels](./no-labels.md) -* [no-label-var](./no-label-var.md) +* [no-extra-label](./no-extra-label) +* [no-labels](./no-labels) +* [no-label-var](./no-label-var) diff --git a/docs/src/rules/no-unused-private-class-members.md b/docs/src/rules/no-unused-private-class-members.md index 092f1fe61ad..c3852c5aab3 100644 --- a/docs/src/rules/no-unused-private-class-members.md +++ b/docs/src/rules/no-unused-private-class-members.md @@ -1,4 +1,9 @@ -# no-unused-private-class-members +--- +title: no-unused-private-class-members +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-unused-private-class-members.md +rule_type: problem +--- Disallows unused private class members. diff --git a/docs/src/rules/no-unused-vars.md b/docs/src/rules/no-unused-vars.md index ddf74823e7a..cea0d7f1ccd 100644 --- a/docs/src/rules/no-unused-vars.md +++ b/docs/src/rules/no-unused-vars.md @@ -1,4 +1,11 @@ -# no-unused-vars +--- +title: no-unused-vars +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-unused-vars.md +rule_type: problem +--- + + Disallows unused variables. diff --git a/docs/src/rules/no-use-before-define.md b/docs/src/rules/no-use-before-define.md index 1fb9dfaf80b..f388a469540 100644 --- a/docs/src/rules/no-use-before-define.md +++ b/docs/src/rules/no-use-before-define.md @@ -1,4 +1,9 @@ -# no-use-before-define +--- +title: no-use-before-define +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-use-before-define.md +rule_type: problem +--- Disallows the use of variables before they are defined. diff --git a/docs/src/rules/no-useless-backreference.md b/docs/src/rules/no-useless-backreference.md index c488f922fa3..4d31b3b31e3 100644 --- a/docs/src/rules/no-useless-backreference.md +++ b/docs/src/rules/no-useless-backreference.md @@ -1,4 +1,11 @@ -# no-useless-backreference +--- +title: no-useless-backreference +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-useless-backreference.md +rule_type: problem +--- + + Disallows useless backreferences in regular expressions. @@ -123,9 +130,9 @@ Examples of additional **correct** code for this rule: ## Related Rules -* [no-control-regex](no-control-regex.md) -* [no-empty-character-class](no-empty-character-class.md) -* [no-invalid-regexp](no-invalid-regexp.md) +* [no-control-regex](no-control-regex) +* [no-empty-character-class](no-empty-character-class) +* [no-invalid-regexp](no-invalid-regexp) ## Further Reading diff --git a/docs/src/rules/no-useless-call.md b/docs/src/rules/no-useless-call.md index 5f252cf1654..36765cecba4 100644 --- a/docs/src/rules/no-useless-call.md +++ b/docs/src/rules/no-useless-call.md @@ -1,4 +1,9 @@ -# no-useless-call +--- +title: no-useless-call +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-useless-call.md +rule_type: suggestion +--- Disallows unnecessary `.call()` and `.apply()`. @@ -72,4 +77,4 @@ If you don't want to be notified about unnecessary `.call()` and `.apply()`, you ## Related Rules -* [prefer-spread](prefer-spread.md) +* [prefer-spread](prefer-spread) diff --git a/docs/src/rules/no-useless-catch.md b/docs/src/rules/no-useless-catch.md index 12c5bc30664..0359f807c08 100644 --- a/docs/src/rules/no-useless-catch.md +++ b/docs/src/rules/no-useless-catch.md @@ -1,4 +1,11 @@ -# no-useless-catch +--- +title: no-useless-catch +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-useless-catch.md +rule_type: suggestion +--- + + Disallows unnecessary catch clauses. diff --git a/docs/src/rules/no-useless-computed-key.md b/docs/src/rules/no-useless-computed-key.md index ce31c51aa87..0049d773570 100644 --- a/docs/src/rules/no-useless-computed-key.md +++ b/docs/src/rules/no-useless-computed-key.md @@ -1,4 +1,11 @@ -# no-useless-computed-key +--- +title: no-useless-computed-key +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-useless-computed-key.md +rule_type: suggestion +--- + + Disallows unnecessary computed property keys in objects and classes. diff --git a/docs/src/rules/no-useless-concat.md b/docs/src/rules/no-useless-concat.md index fcfca8329ac..5e21f9de32f 100644 --- a/docs/src/rules/no-useless-concat.md +++ b/docs/src/rules/no-useless-concat.md @@ -1,4 +1,9 @@ -# no-useless-concat +--- +title: no-useless-concat +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-useless-concat.md +rule_type: suggestion +--- Disallows unnecessary concatenation of strings. diff --git a/docs/src/rules/no-useless-constructor.md b/docs/src/rules/no-useless-constructor.md index 6a628759ca9..58557862bac 100644 --- a/docs/src/rules/no-useless-constructor.md +++ b/docs/src/rules/no-useless-constructor.md @@ -1,4 +1,9 @@ -# no-useless-constructor +--- +title: no-useless-constructor +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-useless-constructor.md +rule_type: suggestion +--- Disallows unnecessary constructors. diff --git a/docs/src/rules/no-useless-escape.md b/docs/src/rules/no-useless-escape.md index ef093c39a0e..4d1af9988bc 100644 --- a/docs/src/rules/no-useless-escape.md +++ b/docs/src/rules/no-useless-escape.md @@ -1,4 +1,13 @@ -# no-useless-escape +--- +title: no-useless-escape +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-useless-escape.md +rule_type: suggestion +--- + + + + Disallows unnecessary escape characters. diff --git a/docs/src/rules/no-useless-rename.md b/docs/src/rules/no-useless-rename.md index dfdc914488c..58f127c9625 100644 --- a/docs/src/rules/no-useless-rename.md +++ b/docs/src/rules/no-useless-rename.md @@ -1,4 +1,11 @@ -# no-useless-rename +--- +title: no-useless-rename +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-useless-rename.md +rule_type: suggestion +--- + + Disallows renaming import, export, and destructured assignments to the same name. @@ -125,7 +132,7 @@ You can safely disable this rule if you do not care about redundantly renaming i ## Related Rules -* [`object-shorthand`](object-shorthand.md) which can enforce this behavior for properties in object literals. +* [`object-shorthand`](object-shorthand) which can enforce this behavior for properties in object literals. ## Compatibility diff --git a/docs/src/rules/no-useless-return.md b/docs/src/rules/no-useless-return.md index 67ad47541f0..b207177d35b 100644 --- a/docs/src/rules/no-useless-return.md +++ b/docs/src/rules/no-useless-return.md @@ -1,4 +1,11 @@ -# no-useless-return +--- +title: no-useless-return +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-useless-return.md +rule_type: suggestion +--- + + Disallows redundant return statements. diff --git a/docs/src/rules/no-var.md b/docs/src/rules/no-var.md index 19a4cc2d737..8d8b754797c 100644 --- a/docs/src/rules/no-var.md +++ b/docs/src/rules/no-var.md @@ -1,4 +1,11 @@ -# no-var +--- +title: no-var +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-var.md +rule_type: suggestion +--- + + Requires `let` or `const` instead of `var`. diff --git a/docs/src/rules/no-void.md b/docs/src/rules/no-void.md index a4897f45ede..1ff4709267d 100644 --- a/docs/src/rules/no-void.md +++ b/docs/src/rules/no-void.md @@ -1,4 +1,9 @@ -# no-void +--- +title: no-void +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-void.md +rule_type: suggestion +--- Disallows use of the void operator. @@ -100,8 +105,8 @@ If you intentionally use the `void` operator then you can disable this rule. ## Related Rules -* [no-undef-init](no-undef-init.md) -* [no-undefined](no-undefined.md) +* [no-undef-init](no-undef-init) +* [no-undefined](no-undefined) ## Further Reading diff --git a/docs/src/rules/no-warning-comments.md b/docs/src/rules/no-warning-comments.md index befb259fcb8..6775c41e408 100644 --- a/docs/src/rules/no-warning-comments.md +++ b/docs/src/rules/no-warning-comments.md @@ -1,4 +1,9 @@ -# no-warning-comments +--- +title: no-warning-comments +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-warning-comments.md +rule_type: suggestion +--- Disallows specified warning terms in comments. diff --git a/docs/src/rules/no-whitespace-before-property.md b/docs/src/rules/no-whitespace-before-property.md index d6aa32c8e3f..c90bbe8a575 100644 --- a/docs/src/rules/no-whitespace-before-property.md +++ b/docs/src/rules/no-whitespace-before-property.md @@ -1,4 +1,11 @@ -# no-whitespace-before-property +--- +title: no-whitespace-before-property +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-whitespace-before-property.md +rule_type: layout +--- + + Disallows whitespace before properties. diff --git a/docs/src/rules/no-with.md b/docs/src/rules/no-with.md index b485838ba27..b7fa4d7cb6f 100644 --- a/docs/src/rules/no-with.md +++ b/docs/src/rules/no-with.md @@ -1,4 +1,11 @@ -# no-with +--- +title: no-with +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-with.md +rule_type: suggestion +--- + + Disallows `with` statements. diff --git a/docs/src/rules/no-wrap-func.md b/docs/src/rules/no-wrap-func.md index 6580ea4e26c..0285338ed4b 100644 --- a/docs/src/rules/no-wrap-func.md +++ b/docs/src/rules/no-wrap-func.md @@ -1,8 +1,13 @@ -# no-wrap-func +--- +title: no-wrap-func +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/no-wrap-func.md + +--- Disallows unnecessary parentheses around function expressions. -(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. +(removed) This rule was **removed** in ESLint v1.0 and **replaced** by the [no-extra-parens](no-extra-parens) 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: diff --git a/docs/src/rules/nonblock-statement-body-position.md b/docs/src/rules/nonblock-statement-body-position.md index 6c0c545e195..7ae31b5c43f 100644 --- a/docs/src/rules/nonblock-statement-body-position.md +++ b/docs/src/rules/nonblock-statement-body-position.md @@ -1,4 +1,11 @@ -# nonblock-statement-body-position +--- +title: nonblock-statement-body-position +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/nonblock-statement-body-position.md +rule_type: layout +--- + + Enforces the location of single-line statements. @@ -29,7 +36,7 @@ if (foo) bar(); This rule aims to enforce a consistent location for single-line statements. -Note that this rule does not enforce the usage of single-line statements in general. If you would like to disallow single-line statements, use the [`curly`](/docs/rules/curly.md) rule instead. +Note that this rule does not enforce the usage of single-line statements in general. If you would like to disallow single-line statements, use the [`curly`](/docs/rules/curly) rule instead. ### Options @@ -153,7 +160,7 @@ while (foo) ## When Not To Use It -If you're not concerned about consistent locations of single-line statements, you should not turn on this rule. You can also disable this rule if you're using the `"all"` option for the [`curly`](/docs/rules/curly.md) rule, because this will disallow single-line statements entirely. +If you're not concerned about consistent locations of single-line statements, you should not turn on this rule. You can also disable this rule if you're using the `"all"` option for the [`curly`](/docs/rules/curly) rule, because this will disallow single-line statements entirely. ## Further Reading diff --git a/docs/src/rules/object-curly-newline.md b/docs/src/rules/object-curly-newline.md index 31f7810840f..156a39a5405 100644 --- a/docs/src/rules/object-curly-newline.md +++ b/docs/src/rules/object-curly-newline.md @@ -1,4 +1,11 @@ -# object-curly-newline +--- +title: object-curly-newline +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/object-curly-newline.md +rule_type: layout +--- + + Enforces consistent line breaks after opening and before closing braces. @@ -371,7 +378,6 @@ Examples of **correct** code for this rule with the default `{ "consistent": tru /*eslint object-curly-newline: ["error", { "consistent": true }]*/ /*eslint-env es6*/ - let empty1 = {}; let empty2 = { }; @@ -539,10 +545,10 @@ If you don't want to enforce consistent line breaks after opening and before clo ## Related Rules -* [comma-spacing](comma-spacing.md) -* [key-spacing](key-spacing.md) -* [object-curly-spacing](object-curly-spacing.md) -* [object-property-newline](object-property-newline.md) +* [comma-spacing](comma-spacing) +* [key-spacing](key-spacing) +* [object-curly-spacing](object-curly-spacing) +* [object-property-newline](object-property-newline) ## Compatibility diff --git a/docs/src/rules/object-curly-spacing.md b/docs/src/rules/object-curly-spacing.md index 7b48bd19d31..bf2dceeb57f 100644 --- a/docs/src/rules/object-curly-spacing.md +++ b/docs/src/rules/object-curly-spacing.md @@ -1,4 +1,11 @@ -# object-curly-spacing +--- +title: object-curly-spacing +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/object-curly-spacing.md +rule_type: layout +--- + + Enforces consistent spacing inside braces. @@ -152,7 +159,7 @@ You can turn this rule off if you are not concerned with the consistency of spac ## Related Rules -* [array-bracket-spacing](array-bracket-spacing.md) -* [comma-spacing](comma-spacing.md) -* [computed-property-spacing](computed-property-spacing.md) -* [space-in-parens](space-in-parens.md) +* [array-bracket-spacing](array-bracket-spacing) +* [comma-spacing](comma-spacing) +* [computed-property-spacing](computed-property-spacing) +* [space-in-parens](space-in-parens) diff --git a/docs/src/rules/object-property-newline.md b/docs/src/rules/object-property-newline.md index c1a1af6607e..43bc8bd8ec7 100644 --- a/docs/src/rules/object-property-newline.md +++ b/docs/src/rules/object-property-newline.md @@ -1,4 +1,11 @@ -# object-property-newline +--- +title: object-property-newline +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/object-property-newline.md +rule_type: layout +--- + + Enforces placing object properties on separate lines. @@ -262,10 +269,10 @@ You can turn this rule off if you want to decide, case-by-case, whether to place ## Related Rules -* [brace-style](brace-style.md) -* [comma-dangle](comma-dangle.md) -* [key-spacing](key-spacing.md) -* [object-curly-spacing](object-curly-spacing.md) +* [brace-style](brace-style) +* [comma-dangle](comma-dangle) +* [key-spacing](key-spacing) +* [object-curly-spacing](object-curly-spacing) ## Compatibility diff --git a/docs/src/rules/object-shorthand.md b/docs/src/rules/object-shorthand.md index 4f196bf1d96..24e3dbda9fb 100644 --- a/docs/src/rules/object-shorthand.md +++ b/docs/src/rules/object-shorthand.md @@ -1,4 +1,11 @@ -# object-shorthand +--- +title: object-shorthand +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/object-shorthand.md +rule_type: suggestion +--- + + Requires or disallows method and property shorthand syntax for object literals. @@ -246,7 +253,7 @@ syntax harder to read and may not want to encourage it with this rule. ## Related Rules -* [`no-useless-rename`](no-useless-rename.md) which disallows renaming import, export, and destructured assignments to the same name. +* [`no-useless-rename`](no-useless-rename) which disallows renaming import, export, and destructured assignments to the same name. ## Further Reading diff --git a/docs/src/rules/one-var-declaration-per-line.md b/docs/src/rules/one-var-declaration-per-line.md index 33069c5891c..bb6e0d991a0 100644 --- a/docs/src/rules/one-var-declaration-per-line.md +++ b/docs/src/rules/one-var-declaration-per-line.md @@ -1,4 +1,11 @@ -# one-var-declaration-per-line +--- +title: one-var-declaration-per-line +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/one-var-declaration-per-line.md +rule_type: suggestion +--- + + Requires or disallows newlines around variable declarations. @@ -88,4 +95,4 @@ let a, ## Related Rules -* [one-var](one-var.md) +* [one-var](one-var) diff --git a/docs/src/rules/one-var.md b/docs/src/rules/one-var.md index aa971eaf8ba..c7631e2493e 100644 --- a/docs/src/rules/one-var.md +++ b/docs/src/rules/one-var.md @@ -1,4 +1,11 @@ -# one-var +--- +title: one-var +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/one-var.md +rule_type: suggestion +--- + + Enforces variables to be declared either together or separately in functions. diff --git a/docs/src/rules/operator-assignment.md b/docs/src/rules/operator-assignment.md index 84fbf1c6239..3f535fad92a 100644 --- a/docs/src/rules/operator-assignment.md +++ b/docs/src/rules/operator-assignment.md @@ -1,4 +1,11 @@ -# operator-assignment +--- +title: operator-assignment +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/operator-assignment.md +rule_type: suggestion +--- + + Requires or disallows assignment operator shorthand where possible. diff --git a/docs/src/rules/operator-linebreak.md b/docs/src/rules/operator-linebreak.md index ab3b821196b..085bc352147 100644 --- a/docs/src/rules/operator-linebreak.md +++ b/docs/src/rules/operator-linebreak.md @@ -1,4 +1,11 @@ -# operator-linebreak +--- +title: operator-linebreak +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/operator-linebreak.md +rule_type: layout +--- + + Enforces consistent linebreak style for operators. @@ -335,4 +342,4 @@ If your project will not be using a common operator line break style, turn this ## Related Rules -* [comma-style](comma-style.md) +* [comma-style](comma-style) diff --git a/docs/src/rules/padded-blocks.md b/docs/src/rules/padded-blocks.md index 3361f7bf59f..731cf49cf49 100644 --- a/docs/src/rules/padded-blocks.md +++ b/docs/src/rules/padded-blocks.md @@ -1,4 +1,11 @@ -# padded-blocks +--- +title: padded-blocks +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/padded-blocks.md +rule_type: layout +--- + + Requires or disallows padding within blocks. @@ -478,5 +485,5 @@ You can turn this rule off if you are not concerned with the consistency of padd ## Related Rules -* [lines-between-class-members](lines-between-class-members.md) -* [padding-line-between-statements](padding-line-between-statements.md) +* [lines-between-class-members](lines-between-class-members) +* [padding-line-between-statements](padding-line-between-statements) diff --git a/docs/src/rules/padding-line-between-statements.md b/docs/src/rules/padding-line-between-statements.md index 8b10438a3b2..3cd684236cf 100644 --- a/docs/src/rules/padding-line-between-statements.md +++ b/docs/src/rules/padding-line-between-statements.md @@ -1,4 +1,11 @@ -# padding-line-between-statements +--- +title: padding-line-between-statements +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/padding-line-between-statements.md +rule_type: layout +--- + + Requires or disallows padding lines between statements. @@ -87,7 +94,7 @@ You can supply any number of configurations. If a statement pair matches multipl ## Examples -This configuration would require blank lines before all `return` statements, like the [newline-before-return](newline-before-return.md) rule. +This configuration would require blank lines before all `return` statements, like the [newline-before-return](newline-before-return) rule. Examples of **incorrect** code for the `[{ blankLine: "always", prev: "*", next: "return" }]` configuration: @@ -124,7 +131,7 @@ function foo() { ---- -This configuration would require blank lines after every sequence of variable declarations, like the [newline-after-var](newline-after-var.md) rule. +This configuration would require blank lines after every sequence of variable declarations, like the [newline-after-var](newline-after-var) rule. Examples of **incorrect** code for the `[{ blankLine: "always", prev: ["const", "let", "var"], next: "*"}, { blankLine: "any", prev: ["const", "let", "var"], next: ["const", "let", "var"]}]` configuration: @@ -200,7 +207,7 @@ class C { ---- -This configuration would require blank lines after all directive prologues, like the [lines-around-directive](lines-around-directive.md) rule. +This configuration would require blank lines after all directive prologues, like the [lines-around-directive](lines-around-directive) rule. Examples of **incorrect** code for the `[{ blankLine: "always", prev: "directive", next: "*" }, { blankLine: "any", prev: "directive", next: "directive" }]` configuration: diff --git a/docs/src/rules/prefer-arrow-callback.md b/docs/src/rules/prefer-arrow-callback.md index dc395b82746..e4222dc098f 100644 --- a/docs/src/rules/prefer-arrow-callback.md +++ b/docs/src/rules/prefer-arrow-callback.md @@ -1,4 +1,11 @@ -# prefer-arrow-callback +--- +title: prefer-arrow-callback +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/prefer-arrow-callback.md +rule_type: suggestion +--- + + Requires using arrow functions for callbacks. diff --git a/docs/src/rules/prefer-const.md b/docs/src/rules/prefer-const.md index 48cc3338d2f..7d652b35a40 100644 --- a/docs/src/rules/prefer-const.md +++ b/docs/src/rules/prefer-const.md @@ -1,4 +1,11 @@ -# prefer-const +--- +title: prefer-const +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/prefer-const.md +rule_type: suggestion +--- + + Requires `const` declarations for variables that are never reassigned after declared. @@ -218,5 +225,5 @@ If you don't want to be notified about variables that are never reassigned after ## Related Rules -* [no-var](no-var.md) -* [no-use-before-define](no-use-before-define.md) +* [no-var](no-var) +* [no-use-before-define](no-use-before-define) diff --git a/docs/src/rules/prefer-destructuring.md b/docs/src/rules/prefer-destructuring.md index 252199adc93..e32be78b48c 100644 --- a/docs/src/rules/prefer-destructuring.md +++ b/docs/src/rules/prefer-destructuring.md @@ -1,4 +1,11 @@ -# prefer-destructuring +--- +title: prefer-destructuring +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/prefer-destructuring.md +rule_type: suggestion +--- + + Requires destructuring from arrays and/or objects. diff --git a/docs/src/rules/prefer-exponentiation-operator.md b/docs/src/rules/prefer-exponentiation-operator.md index 15f120c900b..72b24a574c5 100644 --- a/docs/src/rules/prefer-exponentiation-operator.md +++ b/docs/src/rules/prefer-exponentiation-operator.md @@ -1,4 +1,11 @@ -# prefer-exponentiation-operator +--- +title: prefer-exponentiation-operator +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/prefer-exponentiation-operator.md +rule_type: suggestion +--- + + Disallows the use of `Math.pow` in favor of the `**` operator. diff --git a/docs/src/rules/prefer-named-capture-group.md b/docs/src/rules/prefer-named-capture-group.md index 5667dd0d7c1..a947a05c2a3 100644 --- a/docs/src/rules/prefer-named-capture-group.md +++ b/docs/src/rules/prefer-named-capture-group.md @@ -1,4 +1,9 @@ -# prefer-named-capture-group +--- +title: prefer-named-capture-group +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/prefer-named-capture-group.md +rule_type: suggestion +--- Suggest using named capture group in regular expression. @@ -48,4 +53,4 @@ If you are targeting ECMAScript 2017 and/or older environments, you should not u ## Related Rules -* [no-invalid-regexp](./no-invalid-regexp.md) +* [no-invalid-regexp](./no-invalid-regexp) diff --git a/docs/src/rules/prefer-numeric-literals.md b/docs/src/rules/prefer-numeric-literals.md index b5dc6448ec7..379bbb7fe48 100644 --- a/docs/src/rules/prefer-numeric-literals.md +++ b/docs/src/rules/prefer-numeric-literals.md @@ -1,4 +1,11 @@ -# prefer-numeric-literals +--- +title: prefer-numeric-literals +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/prefer-numeric-literals.md +rule_type: suggestion +--- + + Disallows `parseInt()` and `Number.parseInt()` in favor of binary, octal, and hexadecimal literals. diff --git a/docs/src/rules/prefer-object-has-own.md b/docs/src/rules/prefer-object-has-own.md index a0bc201b7a9..91fdc8e9541 100644 --- a/docs/src/rules/prefer-object-has-own.md +++ b/docs/src/rules/prefer-object-has-own.md @@ -1,4 +1,11 @@ -# prefer-object-has-own +--- +title: prefer-object-has-own +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/prefer-object-has-own.md +rule_type: suggestion +--- + + Prefer `Object.hasOwn()` over `Object.prototype.hasOwnProperty.call()`. @@ -10,7 +17,7 @@ if (Object.prototype.hasOwnProperty.call(object, "foo")) { } ``` -This is a common practice because methods on `Object.prototype` can sometimes be unavailable or redefined (see the [no-prototype-builtins](no-prototype-builtins.md) rule). +This is a common practice because methods on `Object.prototype` can sometimes be unavailable or redefined (see the [no-prototype-builtins](no-prototype-builtins) rule). Introduced in ES2022, `Object.hasOwn()` is a shorter alternative to `Object.prototype.hasOwnProperty.call()`: diff --git a/docs/src/rules/prefer-object-spread.md b/docs/src/rules/prefer-object-spread.md index 34a815c1bac..fe6bad8aab5 100644 --- a/docs/src/rules/prefer-object-spread.md +++ b/docs/src/rules/prefer-object-spread.md @@ -1,4 +1,11 @@ -# prefer-object-spread +--- +title: prefer-object-spread +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/prefer-object-spread.md +rule_type: suggestion +--- + + Prefer use of an object spread over `Object.assign`. diff --git a/docs/src/rules/prefer-promise-reject-errors.md b/docs/src/rules/prefer-promise-reject-errors.md index d0993d43b4b..5c5c566997c 100644 --- a/docs/src/rules/prefer-promise-reject-errors.md +++ b/docs/src/rules/prefer-promise-reject-errors.md @@ -1,4 +1,9 @@ -# prefer-promise-reject-errors +--- +title: prefer-promise-reject-errors +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/prefer-promise-reject-errors.md +rule_type: suggestion +--- Requires using Error objects as Promise rejection reasons. @@ -66,9 +71,9 @@ new Promise(function(resolve, reject) { ## Known Limitations -Due to the limits of static analysis, this rule cannot guarantee that you will only reject Promises with `Error` objects. While the rule will report cases where it can guarantee that the rejection reason is clearly not an `Error`, it will not report cases where there is uncertainty about whether a given reason is an `Error`. For more information on this caveat, see the [similar limitations](no-throw-literal.md#known-limitations) in the `no-throw-literal` rule. +Due to the limits of static analysis, this rule cannot guarantee that you will only reject Promises with `Error` objects. While the rule will report cases where it can guarantee that the rejection reason is clearly not an `Error`, it will not report cases where there is uncertainty about whether a given reason is an `Error`. For more information on this caveat, see the [similar limitations](no-throw-literal#known-limitations) in the `no-throw-literal` rule. -To avoid conflicts between rules, this rule does not report non-error values used in `throw` statements in async functions, even though these lead to Promise rejections. To lint for these cases, use the [`no-throw-literal`](no-throw-literal.md) rule. +To avoid conflicts between rules, this rule does not report non-error values used in `throw` statements in async functions, even though these lead to Promise rejections. To lint for these cases, use the [`no-throw-literal`](no-throw-literal) rule. ## When Not To Use It @@ -76,7 +81,7 @@ If you're using custom non-error values as Promise rejection reasons, you can tu ## Related Rules -* [`no-throw-literal`](no-throw-literal.md) +* [`no-throw-literal`](no-throw-literal) ## Further Reading diff --git a/docs/src/rules/prefer-reflect.md b/docs/src/rules/prefer-reflect.md index d332f371255..2c25ddd8ef9 100644 --- a/docs/src/rules/prefer-reflect.md +++ b/docs/src/rules/prefer-reflect.md @@ -1,4 +1,9 @@ -# prefer-reflect +--- +title: prefer-reflect +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/prefer-reflect.md +rule_type: suggestion +--- Suggest using Reflect methods where applicable. @@ -316,7 +321,7 @@ delete bar; // deleting variable Reflect.deleteProperty(foo, 'bar'); ``` -Note: For a rule preventing deletion of variables, see [no-delete-var instead](no-delete-var.md) +Note: For a rule preventing deletion of variables, see [no-delete-var instead](no-delete-var) Examples of **correct** code for this rule with the `{ "exceptions": ["delete"] }` option: @@ -336,6 +341,6 @@ In ES2015 (ES6) or later, if you don't want to be notified about places where Re ## Related Rules -* [no-useless-call](no-useless-call.md) -* [prefer-spread](prefer-spread.md) -* [no-delete-var](no-delete-var.md) +* [no-useless-call](no-useless-call) +* [prefer-spread](prefer-spread) +* [no-delete-var](no-delete-var) diff --git a/docs/src/rules/prefer-regex-literals.md b/docs/src/rules/prefer-regex-literals.md index 7c01166b642..7ca6b3275f0 100644 --- a/docs/src/rules/prefer-regex-literals.md +++ b/docs/src/rules/prefer-regex-literals.md @@ -1,4 +1,11 @@ -# prefer-regex-literals +--- +title: prefer-regex-literals +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/prefer-regex-literals.md +rule_type: suggestion +--- + + Disallows use of the `RegExp` constructor in favor of regular expression literals. diff --git a/docs/src/rules/prefer-rest-params.md b/docs/src/rules/prefer-rest-params.md index d36127caae7..5eb69ba9622 100644 --- a/docs/src/rules/prefer-rest-params.md +++ b/docs/src/rules/prefer-rest-params.md @@ -1,4 +1,9 @@ -# prefer-rest-params +--- +title: prefer-rest-params +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/prefer-rest-params.md +rule_type: suggestion +--- Suggests using rest parameters instead of `arguments`. @@ -64,4 +69,4 @@ In ES2015 (ES6) or later, if you don't want to be notified about `arguments` var ## Related Rules -* [prefer-spread](prefer-spread.md) +* [prefer-spread](prefer-spread) diff --git a/docs/src/rules/prefer-spread.md b/docs/src/rules/prefer-spread.md index 00adc3d9018..08c0eae7308 100644 --- a/docs/src/rules/prefer-spread.md +++ b/docs/src/rules/prefer-spread.md @@ -1,4 +1,9 @@ -# prefer-spread +--- +title: prefer-spread +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/prefer-spread.md +rule_type: suggestion +--- Suggests using spread syntax instead of `.apply()`. @@ -77,4 +82,4 @@ In ES2015 (ES6) or later, if you don't want to be notified about `Function.proto ## Related Rules -* [no-useless-call](no-useless-call.md) +* [no-useless-call](no-useless-call) diff --git a/docs/src/rules/prefer-template.md b/docs/src/rules/prefer-template.md index bfea4a26e47..f2045ee2692 100644 --- a/docs/src/rules/prefer-template.md +++ b/docs/src/rules/prefer-template.md @@ -1,4 +1,11 @@ -# prefer-template +--- +title: prefer-template +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/prefer-template.md +rule_type: suggestion +--- + + Suggests using template literals instead of string concatenation. @@ -51,5 +58,5 @@ In ES2015 (ES6) or later, if you don't want to be notified about string concaten ## Related Rules -* [no-useless-concat](no-useless-concat.md) -* [quotes](quotes.md) +* [no-useless-concat](no-useless-concat) +* [quotes](quotes) diff --git a/docs/src/rules/quote-props.md b/docs/src/rules/quote-props.md index 9e2a7fb602e..6761bc0a3f1 100644 --- a/docs/src/rules/quote-props.md +++ b/docs/src/rules/quote-props.md @@ -1,4 +1,11 @@ -# quote-props +--- +title: quote-props +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/quote-props.md +rule_type: suggestion +--- + + Requires quotes around object literal property names. diff --git a/docs/src/rules/quotes.md b/docs/src/rules/quotes.md index 545c5347f86..be42f89b717 100644 --- a/docs/src/rules/quotes.md +++ b/docs/src/rules/quotes.md @@ -1,4 +1,11 @@ -# quotes +--- +title: quotes +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/quotes.md +rule_type: layout +--- + + Enforces the consistent use of either backticks, double, or single quotes. @@ -149,7 +156,7 @@ var single = 'single'; var single = `single`; ``` -`{ "allowTemplateLiterals": false }` will not disallow the usage of all template literals. If you want to forbid any instance of template literals, use [no-restricted-syntax](no-restricted-syntax.md) and target the `TemplateLiteral` selector. +`{ "allowTemplateLiterals": false }` will not disallow the usage of all template literals. If you want to forbid any instance of template literals, use [no-restricted-syntax](no-restricted-syntax) and target the `TemplateLiteral` selector. ## When Not To Use It diff --git a/docs/src/rules/radix.md b/docs/src/rules/radix.md index a1033fe8502..b1adcee93a2 100644 --- a/docs/src/rules/radix.md +++ b/docs/src/rules/radix.md @@ -1,4 +1,11 @@ -# radix +--- +title: radix +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/radix.md +rule_type: suggestion +--- + + Enforces the consistent use of the radix argument when using `parseInt()`. diff --git a/docs/src/rules/require-atomic-updates.md b/docs/src/rules/require-atomic-updates.md index 2b107d53646..ee58f8115b0 100644 --- a/docs/src/rules/require-atomic-updates.md +++ b/docs/src/rules/require-atomic-updates.md @@ -1,4 +1,9 @@ -# require-atomic-updates +--- +title: require-atomic-updates +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/require-atomic-updates.md +rule_type: problem +--- Disallows assignments that can lead to race conditions due to usage of `await` or `yield`. diff --git a/docs/src/rules/require-await.md b/docs/src/rules/require-await.md index 250d0e673f3..0d9362d230d 100644 --- a/docs/src/rules/require-await.md +++ b/docs/src/rules/require-await.md @@ -1,4 +1,9 @@ -# require-await +--- +title: require-await +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/require-await.md +rule_type: suggestion +--- Disallows async functions which have no `await` expression. @@ -85,4 +90,4 @@ If you are throwing an error inside of an asynchronous function for this purpose ## Related Rules -* [require-yield](require-yield.md) +* [require-yield](require-yield) diff --git a/docs/src/rules/require-jsdoc.md b/docs/src/rules/require-jsdoc.md index 14a3dda51c4..52256697891 100644 --- a/docs/src/rules/require-jsdoc.md +++ b/docs/src/rules/require-jsdoc.md @@ -1,4 +1,9 @@ -# require-jsdoc +--- +title: require-jsdoc +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/require-jsdoc.md +rule_type: suggestion +--- Requires JSDoc comments. @@ -188,4 +193,4 @@ If you do not require JSDoc for your functions, then you can leave this rule off ## Related Rules -* [valid-jsdoc](valid-jsdoc.md) +* [valid-jsdoc](valid-jsdoc) diff --git a/docs/src/rules/require-unicode-regexp.md b/docs/src/rules/require-unicode-regexp.md index f920764e605..96d03569eb8 100644 --- a/docs/src/rules/require-unicode-regexp.md +++ b/docs/src/rules/require-unicode-regexp.md @@ -1,4 +1,9 @@ -# require-unicode-regexp +--- +title: require-unicode-regexp +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/require-unicode-regexp.md +rule_type: suggestion +--- Enforces the use of `u` flag on RegExp. diff --git a/docs/src/rules/require-yield.md b/docs/src/rules/require-yield.md index 5c073194ff3..291f438df40 100644 --- a/docs/src/rules/require-yield.md +++ b/docs/src/rules/require-yield.md @@ -1,4 +1,11 @@ -# require-yield +--- +title: require-yield +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/require-yield.md +rule_type: suggestion +--- + + Disallows generator functions that do not have `yield`. @@ -44,4 +51,4 @@ If you don't want to notify generator functions that have no `yield` expression, ## Related Rules -* [require-await](require-await.md) +* [require-await](require-await) diff --git a/docs/src/rules/rest-spread-spacing.md b/docs/src/rules/rest-spread-spacing.md index 33a1f51a8e3..48c1a7a9923 100644 --- a/docs/src/rules/rest-spread-spacing.md +++ b/docs/src/rules/rest-spread-spacing.md @@ -1,4 +1,11 @@ -# rest-spread-spacing +--- +title: rest-spread-spacing +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/rest-spread-spacing.md +rule_type: layout +--- + + Enforces spacing between rest and spread operators and their expressions. diff --git a/docs/src/rules/semi-spacing.md b/docs/src/rules/semi-spacing.md index 9b8d368740b..b2d465d4a23 100644 --- a/docs/src/rules/semi-spacing.md +++ b/docs/src/rules/semi-spacing.md @@ -1,4 +1,11 @@ -# semi-spacing +--- +title: semi-spacing +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/semi-spacing.md +rule_type: layout +--- + + Enforces spacing before and after semicolons. @@ -104,8 +111,8 @@ You can turn this rule off if you are not concerned with the consistency of spac ## Related Rules -* [semi](semi.md) -* [no-extra-semi](no-extra-semi.md) -* [comma-spacing](comma-spacing.md) -* [block-spacing](block-spacing.md) -* [space-in-parens](space-in-parens.md) +* [semi](semi) +* [no-extra-semi](no-extra-semi) +* [comma-spacing](comma-spacing) +* [block-spacing](block-spacing) +* [space-in-parens](space-in-parens) diff --git a/docs/src/rules/semi-style.md b/docs/src/rules/semi-style.md index 6f22daaae5b..1c44bd9ffcb 100644 --- a/docs/src/rules/semi-style.md +++ b/docs/src/rules/semi-style.md @@ -1,4 +1,11 @@ -# semi-style +--- +title: semi-style +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/semi-style.md +rule_type: layout +--- + + Enforces location of semicolons. @@ -121,6 +128,6 @@ If you don't want to notify the location of semicolons, then it's safe to disabl ## Related Rules -* [no-extra-semi](./no-extra-semi.md) -* [semi](./semi.md) -* [semi-spacing](./semi-spacing.md) +* [no-extra-semi](./no-extra-semi) +* [semi](./semi) +* [semi-spacing](./semi-spacing) diff --git a/docs/src/rules/semi.md b/docs/src/rules/semi.md index 3f6857cfd3f..013b9675abe 100644 --- a/docs/src/rules/semi.md +++ b/docs/src/rules/semi.md @@ -1,4 +1,11 @@ -# semi +--- +title: semi +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/semi.md +rule_type: layout +--- + + Requires or disallows semicolons instead of ASI. @@ -31,7 +38,7 @@ return; } ``` -Effectively, a semicolon is inserted after the `return` statement, causing the code below it (a labeled literal inside a block) to be unreachable. This rule and the [no-unreachable](no-unreachable.md) rule will protect your code from such cases. +Effectively, a semicolon is inserted after the `return` statement, causing the code below it (a labeled literal inside a block) to be unreachable. This rule and the [no-unreachable](no-unreachable) rule will protect your code from such cases. On the other side of the argument are those who say that since semicolons are inserted automatically, they are optional and do not need to be inserted manually. However, the ASI mechanism can also be tricky to people who don't use semicolons. For example, consider this code: @@ -46,7 +53,7 @@ var globalCounter = { } })() ``` -In this example, a semicolon will not be inserted after the first line, causing a run-time error (because an empty object is called as if it's a function). The [no-unexpected-multiline](no-unexpected-multiline.md) rule can protect your code from such cases. +In this example, a semicolon will not be inserted after the first line, causing a run-time error (because an empty object is called as if it's a function). The [no-unexpected-multiline](no-unexpected-multiline) rule can protect your code from such cases. Although ASI allows for more freedom over your coding style, it can also make your code behave in an unexpected way, whether you use semicolons or not. Therefore, it is best to know when ASI takes place and when it does not, and have ESLint protect your code from these potentially unexpected cases. In short, as once described by Isaac Schlueter, a `\n` character always ends a statement (just like a semicolon) unless one of the following is true: @@ -214,9 +221,9 @@ If you do not want to enforce semicolon usage (or omission) in any particular wa ## Related Rules -* [no-extra-semi](no-extra-semi.md) -* [no-unexpected-multiline](no-unexpected-multiline.md) -* [semi-spacing](semi-spacing.md) +* [no-extra-semi](no-extra-semi) +* [no-unexpected-multiline](no-unexpected-multiline) +* [semi-spacing](semi-spacing) ## Further Reading diff --git a/docs/src/rules/sort-imports.md b/docs/src/rules/sort-imports.md index 5ba4509a228..40f7686c885 100644 --- a/docs/src/rules/sort-imports.md +++ b/docs/src/rules/sort-imports.md @@ -1,4 +1,11 @@ -# sort-imports +--- +title: sort-imports +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/sort-imports.md +rule_type: suggestion +--- + + Enforces sorted import declarations within modules. @@ -288,5 +295,5 @@ This rule is a formatting preference and not following it won't negatively affec ## Related Rules -* [sort-keys](sort-keys.md) -* [sort-vars](sort-vars.md) +* [sort-keys](sort-keys) +* [sort-vars](sort-vars) diff --git a/docs/src/rules/sort-keys.md b/docs/src/rules/sort-keys.md index 27368412fd9..f01771336cb 100644 --- a/docs/src/rules/sort-keys.md +++ b/docs/src/rules/sort-keys.md @@ -1,4 +1,9 @@ -# sort-keys +--- +title: sort-keys +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/sort-keys.md +rule_type: suggestion +--- Requires object keys to be sorted. @@ -222,8 +227,8 @@ If you don't want to notify about properties' order, then it's safe to disable t ## Related Rules -* [sort-imports](sort-imports.md) -* [sort-vars](sort-vars.md) +* [sort-imports](sort-imports) +* [sort-vars](sort-vars) ## Compatibility diff --git a/docs/src/rules/sort-vars.md b/docs/src/rules/sort-vars.md index 63c3df6e526..2cd8f478d36 100644 --- a/docs/src/rules/sort-vars.md +++ b/docs/src/rules/sort-vars.md @@ -1,4 +1,11 @@ -# sort-vars +--- +title: sort-vars +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/sort-vars.md +rule_type: suggestion +--- + + Requires variables within the same declaration block to be sorted. @@ -76,5 +83,5 @@ This rule is a formatting preference and not following it won't negatively affec ## Related Rules -* [sort-keys](sort-keys.md) -* [sort-imports](sort-imports.md) +* [sort-keys](sort-keys) +* [sort-imports](sort-imports) diff --git a/docs/src/rules/space-after-function-name.md b/docs/src/rules/space-after-function-name.md index fee100a4b29..390198fdd47 100644 --- a/docs/src/rules/space-after-function-name.md +++ b/docs/src/rules/space-after-function-name.md @@ -1,8 +1,13 @@ -# space-after-function-name +--- +title: space-after-function-name +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/space-after-function-name.md + +--- Enforces consistent spacing after name in function definitions. -(removed) This rule was **removed** in ESLint v1.0 and **replaced** by the [space-before-function-paren](space-before-function-paren.md) rule. +(removed) This rule was **removed** in ESLint v1.0 and **replaced** by the [space-before-function-paren](space-before-function-paren) rule. Whitespace between a function name and its parameter list is optional. diff --git a/docs/src/rules/space-after-keywords.md b/docs/src/rules/space-after-keywords.md index 7a061d815e3..36ff74aa194 100644 --- a/docs/src/rules/space-after-keywords.md +++ b/docs/src/rules/space-after-keywords.md @@ -1,8 +1,13 @@ -# space-after-keywords +--- +title: space-after-keywords +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/space-after-keywords.md + +--- Enforces consistent spacing after keywords. -(removed) This rule was **removed** in ESLint v2.0 and replaced by the [keyword-spacing](keyword-spacing.md) rule. +(removed) This rule was **removed** in ESLint v2.0 and replaced by the [keyword-spacing](keyword-spacing) rule. (fixable) The `--fix` option on the [command line](../user-guide/command-line-interface#--fix) automatically fixed problems reported by this rule. diff --git a/docs/src/rules/space-before-blocks.md b/docs/src/rules/space-before-blocks.md index 1271a4e1b3f..755d057623b 100644 --- a/docs/src/rules/space-before-blocks.md +++ b/docs/src/rules/space-before-blocks.md @@ -1,4 +1,11 @@ -# space-before-blocks +--- +title: space-before-blocks +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/space-before-blocks.md +rule_type: layout +--- + + Requires Or disallows space before blocks. @@ -214,8 +221,8 @@ You can turn this rule off if you are not concerned with the consistency of spac ## Related Rules -* [keyword-spacing](keyword-spacing.md) -* [arrow-spacing](arrow-spacing.md) -* [switch-colon-spacing](switch-colon-spacing.md) -* [block-spacing](block-spacing.md) -* [brace-style](brace-style.md) +* [keyword-spacing](keyword-spacing) +* [arrow-spacing](arrow-spacing) +* [switch-colon-spacing](switch-colon-spacing) +* [block-spacing](block-spacing) +* [brace-style](brace-style) diff --git a/docs/src/rules/space-before-function-paren.md b/docs/src/rules/space-before-function-paren.md index 547e26c0c06..b16fc954887 100644 --- a/docs/src/rules/space-before-function-paren.md +++ b/docs/src/rules/space-before-function-paren.md @@ -1,4 +1,11 @@ -# space-before-function-paren +--- +title: space-before-function-paren +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/space-before-function-paren.md +rule_type: layout +--- + + Requires or disallows a space before function parenthesis. @@ -366,5 +373,5 @@ You can turn this rule off if you are not concerned with the consistency of spac ## Related Rules -* [space-after-keywords](space-after-keywords.md) -* [space-return-throw-case](space-return-throw-case.md) +* [space-after-keywords](space-after-keywords) +* [space-return-throw-case](space-return-throw-case) diff --git a/docs/src/rules/space-before-function-parentheses.md b/docs/src/rules/space-before-function-parentheses.md index a5d869866ba..376bd1cfeed 100644 --- a/docs/src/rules/space-before-function-parentheses.md +++ b/docs/src/rules/space-before-function-parentheses.md @@ -1,8 +1,13 @@ -# space-before-function-parentheses +--- +title: space-before-function-parentheses +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/space-before-function-parentheses.md + +--- Enforces consistent spacing before opening parenthesis in function definitions. -(removed) This rule was **removed** in ESLint v1.0 and **replaced** by the [space-before-function-paren](space-before-function-paren.md) rule. The name of the rule changed from "parentheses" to "paren" for consistency with the names of other rules. +(removed) This rule was **removed** in ESLint v1.0 and **replaced** by the [space-before-function-paren](space-before-function-paren) rule. The name of the rule changed from "parentheses" to "paren" for consistency with the names of other rules. When formatting a function, whitespace is allowed between the function name or `function` keyword and the opening paren. Named functions also require a space between the `function` keyword and the function name, but anonymous functions require no whitespace. For example: @@ -258,5 +263,5 @@ You can turn this rule off if you are not concerned with the consistency of spac ## Related Rules -* [space-after-keywords](space-after-keywords.md) -* [space-return-throw-case](space-return-throw-case.md) +* [space-after-keywords](space-after-keywords) +* [space-return-throw-case](space-return-throw-case) diff --git a/docs/src/rules/space-before-keywords.md b/docs/src/rules/space-before-keywords.md index 2c77bc1d8af..1d9384e03f8 100644 --- a/docs/src/rules/space-before-keywords.md +++ b/docs/src/rules/space-before-keywords.md @@ -1,8 +1,13 @@ -# space-before-keywords +--- +title: space-before-keywords +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/space-before-keywords.md + +--- Enforces consistent spacing before keywords. -(removed) This rule was **removed** in ESLint v2.0 and **replaced** by the [keyword-spacing](keyword-spacing.md) rule. +(removed) This rule was **removed** in ESLint v2.0 and **replaced** by the [keyword-spacing](keyword-spacing) rule. (fixable) The `--fix` option on the [command line](../user-guide/command-line-interface#--fix) automatically fixed problems reported by this rule. @@ -30,7 +35,7 @@ must be preceded by at least one space. If `"never"` then no spaces will be allo the keywords `else`, `while` (do...while), `finally` and `catch`. The default value is `"always"`. This rule will allow keywords to be preceded by an opening curly brace (`{`). If you wish to alter -this behavior, consider using the [block-spacing](block-spacing.md) rule. +this behavior, consider using the [block-spacing](block-spacing) rule. Examples of **incorrect** code for this rule with the default `"always"` option: @@ -109,8 +114,8 @@ If you do not wish to enforce consistency on keyword spacing. ## Related Rules -* [space-after-keywords](space-after-keywords.md) -* [block-spacing](block-spacing.md) -* [space-return-throw-case](space-return-throw-case.md) -* [space-unary-ops](space-unary-ops.md) -* [space-infix-ops](space-infix-ops.md) +* [space-after-keywords](space-after-keywords) +* [block-spacing](block-spacing) +* [space-return-throw-case](space-return-throw-case) +* [space-unary-ops](space-unary-ops) +* [space-infix-ops](space-infix-ops) diff --git a/docs/src/rules/space-in-brackets.md b/docs/src/rules/space-in-brackets.md index 363bd3053d2..d7de26eba12 100644 --- a/docs/src/rules/space-in-brackets.md +++ b/docs/src/rules/space-in-brackets.md @@ -1,8 +1,13 @@ -# space-in-brackets +--- +title: space-in-brackets +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/space-in-brackets.md + +--- Enforces consistent spacing inside braces of object literals and brackets of array literals. -(removed) This rule was **removed** in ESLint v1.0 and **replaced** by the [object-curly-spacing](object-curly-spacing.md) and [array-bracket-spacing](array-bracket-spacing.md) rules. +(removed) This rule was **removed** in ESLint v1.0 and **replaced** by the [object-curly-spacing](object-curly-spacing) and [array-bracket-spacing](array-bracket-spacing) rules. While formatting preferences are very personal, a number of style guides require or disallow spaces between brackets: @@ -303,7 +308,7 @@ You can turn this rule off if you are not concerned with the consistency of spac ## Related Rules -* [array-bracket-spacing](array-bracket-spacing.md) -* [object-curly-spacing](object-curly-spacing.md) -* [space-in-parens](space-in-parens.md) -* [computed-property-spacing](computed-property-spacing.md) +* [array-bracket-spacing](array-bracket-spacing) +* [object-curly-spacing](object-curly-spacing) +* [space-in-parens](space-in-parens) +* [computed-property-spacing](computed-property-spacing) diff --git a/docs/src/rules/space-in-parens.md b/docs/src/rules/space-in-parens.md index f9be1bc1d0d..7d6f4bc3ad7 100644 --- a/docs/src/rules/space-in-parens.md +++ b/docs/src/rules/space-in-parens.md @@ -1,4 +1,11 @@ -# space-in-parens +--- +title: space-in-parens +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/space-in-parens.md +rule_type: layout +--- + + Disallows or enforce spaces inside of parentheses. @@ -289,6 +296,6 @@ You can turn this rule off if you are not concerned with the consistency of spac ## Related Rules -* [array-bracket-spacing](array-bracket-spacing.md) -* [object-curly-spacing](object-curly-spacing.md) -* [computed-property-spacing](computed-property-spacing.md) +* [array-bracket-spacing](array-bracket-spacing) +* [object-curly-spacing](object-curly-spacing) +* [computed-property-spacing](computed-property-spacing) diff --git a/docs/src/rules/space-infix-ops.md b/docs/src/rules/space-infix-ops.md index 9453b7990c5..aa079b51114 100644 --- a/docs/src/rules/space-infix-ops.md +++ b/docs/src/rules/space-infix-ops.md @@ -1,4 +1,11 @@ -# space-infix-ops +--- +title: space-infix-ops +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/space-infix-ops.md +rule_type: layout +--- + + Requires spacing around infix operators. diff --git a/docs/src/rules/space-return-throw-case.md b/docs/src/rules/space-return-throw-case.md index 9df4f681ee3..6bf9ba199b2 100644 --- a/docs/src/rules/space-return-throw-case.md +++ b/docs/src/rules/space-return-throw-case.md @@ -1,8 +1,13 @@ -# space-return-throw-case +--- +title: space-return-throw-case +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/space-return-throw-case.md + +--- Requires spaces after `return`, `throw`, and `case` keywords. -(removed) This rule was **removed** in ESLint v2.0 and **replaced** by the [keyword-spacing](keyword-spacing.md) rule. +(removed) This rule was **removed** in ESLint v2.0 and **replaced** by the [keyword-spacing](keyword-spacing) rule. (fixable) The `--fix` option on the [command line](../user-guide/command-line-interface#--fix) automatically fixed problems reported by this rule. diff --git a/docs/src/rules/space-unary-ops.md b/docs/src/rules/space-unary-ops.md index 39eb9cbf050..d413ff68651 100644 --- a/docs/src/rules/space-unary-ops.md +++ b/docs/src/rules/space-unary-ops.md @@ -1,4 +1,11 @@ -# space-unary-ops +--- +title: space-unary-ops +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/space-unary-ops.md +rule_type: layout +--- + + Requires or disallow spaces before/after unary operators. diff --git a/docs/src/rules/space-unary-word-ops.md b/docs/src/rules/space-unary-word-ops.md index 4d4fb85cd5f..eb5d3d95e0c 100644 --- a/docs/src/rules/space-unary-word-ops.md +++ b/docs/src/rules/space-unary-word-ops.md @@ -1,8 +1,13 @@ -# space-unary-word-ops +--- +title: space-unary-word-ops +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/space-unary-word-ops.md + +--- Requires spaces after unary word operators. -(removed) This rule was **removed** in ESLint v0.10.0 and **replaced** by the [space-unary-ops](space-unary-ops.md) rule. +(removed) This rule was **removed** in ESLint v0.10.0 and **replaced** by the [space-unary-ops](space-unary-ops) rule. Require spaces following unary word operators. diff --git a/docs/src/rules/spaced-comment.md b/docs/src/rules/spaced-comment.md index 965a274e276..c990773744b 100644 --- a/docs/src/rules/spaced-comment.md +++ b/docs/src/rules/spaced-comment.md @@ -1,4 +1,11 @@ -# spaced-comment +--- +title: spaced-comment +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/spaced-comment.md +rule_type: suggestion +--- + + Enforces consistent spacing after the `//` or `/*` in a comment. @@ -285,4 +292,4 @@ subsequent lines are ignored ## Related Rules -* [spaced-line-comment](spaced-line-comment.md) +* [spaced-line-comment](spaced-line-comment) diff --git a/docs/src/rules/spaced-line-comment.md b/docs/src/rules/spaced-line-comment.md index b33124bf341..e032d05df96 100644 --- a/docs/src/rules/spaced-line-comment.md +++ b/docs/src/rules/spaced-line-comment.md @@ -1,8 +1,13 @@ -# spaced-line-comment +--- +title: spaced-line-comment +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/spaced-line-comment.md + +--- Enforces consistent spacing after `//` in line comments. -(removed) This rule was **removed** in ESLint v1.0 and **replaced** by the [spaced-comment](spaced-comment.md) rule. +(removed) This rule was **removed** in ESLint v1.0 and **replaced** by the [spaced-comment](spaced-comment) rule. Some style guides require or disallow a whitespace immediately after the initial `//` of a line comment. Whitespace after the `//` makes it easier to read text in comments. @@ -71,4 +76,4 @@ var foo = 5; ## Related Rules -* [spaced-comment](spaced-comment.md) +* [spaced-comment](spaced-comment) diff --git a/docs/src/rules/strict.md b/docs/src/rules/strict.md index 077ca95a87e..df14488edca 100644 --- a/docs/src/rules/strict.md +++ b/docs/src/rules/strict.md @@ -1,4 +1,11 @@ -# strict +--- +title: strict +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/strict.md +rule_type: suggestion +--- + + Requires or disallow strict mode directives. @@ -44,14 +51,14 @@ In **ECMAScript** modules, which always have strict mode semantics, the directiv This rule requires or disallows strict mode directives. -This rule disallows strict mode directives, no matter which option is specified, if ESLint configuration specifies either of the following as [parser options](/docs/user-guide/configuring/language-options.md#specifying-parser-options): +This rule disallows strict mode directives, no matter which option is specified, if ESLint configuration specifies either of the following as [parser options](/docs/user-guide/configuring/language-options#specifying-parser-options): * `"sourceType": "module"` that is, files are **ECMAScript** modules * `"impliedStrict": true` property in the `ecmaFeatures` object This rule disallows strict mode directives, no matter which option is specified, in functions with non-simple parameter lists (for example, parameter lists with default parameter values) because that is a syntax error in **ECMAScript 2016** and later. See the examples of the [function](#function) option. -This rule does not apply to class static blocks, no matter which option is specified, because class static blocks do not have directives. Therefore, a `"use strict"` statement in a class static block is not a directive, and will be reported by the [no-unused-expressions](no-unused-expressions.md) rule. +This rule does not apply to class static blocks, no matter which option is specified, because class static blocks do not have directives. Therefore, a `"use strict"` statement in a class static block is not a directive, and will be reported by the [no-unused-expressions](no-unused-expressions) rule. The `--fix` option on the command line does not insert new `"use strict"` statements, but only removes unneeded statements. @@ -70,8 +77,8 @@ This rule has a string option: The `"safe"` option corresponds to the `"global"` option if ESLint considers a file to be a **Node.js** or **CommonJS** module because the configuration specifies either of the following: -* `node` or `commonjs` [environments](/docs/user-guide/configuring/language-options.md#specifying-environments) -* `"globalReturn": true` property in the `ecmaFeatures` object of [parser options](/docs/user-guide/configuring/language-options.md#specifying-parser-options) +* `node` or `commonjs` [environments](/docs/user-guide/configuring/language-options#specifying-environments) +* `"globalReturn": true` property in the `ecmaFeatures` object of [parser options](/docs/user-guide/configuring/language-options#specifying-parser-options) Otherwise the `"safe"` option corresponds to the `"function"` option. Note that if `"globalReturn": false` is explicitly specified in the configuration, the `"safe"` option will correspond to the `"function"` option regardless of the specified environment. @@ -273,4 +280,4 @@ function foo() { ## When Not To Use It -In a codebase that has both strict and non-strict code, either turn this rule off, or [selectively disable it](/docs/user-guide/configuring/rules.md#disabling-rules) where necessary. For example, functions referencing `arguments.callee` are invalid in strict mode. A [full list of strict mode differences](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode/Transitioning_to_strict_mode#Differences_from_non-strict_to_strict) is available on MDN. +In a codebase that has both strict and non-strict code, either turn this rule off, or [selectively disable it](/docs/user-guide/configuring/rules#disabling-rules) where necessary. For example, functions referencing `arguments.callee` are invalid in strict mode. A [full list of strict mode differences](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode/Transitioning_to_strict_mode#Differences_from_non-strict_to_strict) is available on MDN. diff --git a/docs/src/rules/switch-colon-spacing.md b/docs/src/rules/switch-colon-spacing.md index 5380ea59ca1..1106bdb8026 100644 --- a/docs/src/rules/switch-colon-spacing.md +++ b/docs/src/rules/switch-colon-spacing.md @@ -1,4 +1,11 @@ -# switch-colon-spacing +--- +title: switch-colon-spacing +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/switch-colon-spacing.md +rule_type: layout +--- + + Enforces spacing around colons of switch statements. diff --git a/docs/src/rules/symbol-description.md b/docs/src/rules/symbol-description.md index 625d5ab5377..88eabce8f15 100644 --- a/docs/src/rules/symbol-description.md +++ b/docs/src/rules/symbol-description.md @@ -1,4 +1,9 @@ -# symbol-description +--- +title: symbol-description +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/symbol-description.md +rule_type: suggestion +--- Requires symbol descriptions. diff --git a/docs/src/rules/template-curly-spacing.md b/docs/src/rules/template-curly-spacing.md index 65f89f4ff9d..eff2aa98146 100644 --- a/docs/src/rules/template-curly-spacing.md +++ b/docs/src/rules/template-curly-spacing.md @@ -1,4 +1,11 @@ -# template-curly-spacing +--- +title: template-curly-spacing +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/template-curly-spacing.md +rule_type: layout +--- + + Enforces usage of spacing in template strings. diff --git a/docs/src/rules/template-tag-spacing.md b/docs/src/rules/template-tag-spacing.md index 6bbf3e783d4..e6d6f189605 100644 --- a/docs/src/rules/template-tag-spacing.md +++ b/docs/src/rules/template-tag-spacing.md @@ -1,4 +1,11 @@ -# template-tag-spacing +--- +title: template-tag-spacing +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/template-tag-spacing.md +rule_type: layout +--- + + Requires or disallow spacing between template tags and their literals. diff --git a/docs/src/rules/unicode-bom.md b/docs/src/rules/unicode-bom.md index 160440e5237..878dfacca4f 100644 --- a/docs/src/rules/unicode-bom.md +++ b/docs/src/rules/unicode-bom.md @@ -1,4 +1,11 @@ -# unicode-bom +--- +title: unicode-bom +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/unicode-bom.md +rule_type: layout +--- + + Requires or disallows the Unicode Byte Order Mark (BOM). diff --git a/docs/src/rules/use-isnan.md b/docs/src/rules/use-isnan.md index 1560ee254ea..60a4f055173 100644 --- a/docs/src/rules/use-isnan.md +++ b/docs/src/rules/use-isnan.md @@ -1,4 +1,11 @@ -# use-isnan +--- +title: use-isnan +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/use-isnan.md +rule_type: problem +--- + + Requires calls to `isNaN()` when checking for `NaN`. diff --git a/docs/src/rules/valid-jsdoc.md b/docs/src/rules/valid-jsdoc.md index a57a3f65ff1..84eb32b0e4e 100644 --- a/docs/src/rules/valid-jsdoc.md +++ b/docs/src/rules/valid-jsdoc.md @@ -1,4 +1,11 @@ -# valid-jsdoc +--- +title: valid-jsdoc +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/valid-jsdoc.md +rule_type: suggestion +--- + + Enforces valid JSDoc comments. @@ -388,7 +395,7 @@ If you aren't using JSDoc, then you can safely turn this rule off. ## Related Rules -* [require-jsdoc](require-jsdoc.md) +* [require-jsdoc](require-jsdoc) ## Further Reading diff --git a/docs/src/rules/valid-typeof.md b/docs/src/rules/valid-typeof.md index fcf60a97538..a37def6f496 100644 --- a/docs/src/rules/valid-typeof.md +++ b/docs/src/rules/valid-typeof.md @@ -1,4 +1,13 @@ -# valid-typeof +--- +title: valid-typeof +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/valid-typeof.md +rule_type: problem +--- + + + + Enforces comparing `typeof` expressions against valid strings. diff --git a/docs/src/rules/vars-on-top.md b/docs/src/rules/vars-on-top.md index 216a16d9d7f..858689e658b 100644 --- a/docs/src/rules/vars-on-top.md +++ b/docs/src/rules/vars-on-top.md @@ -1,4 +1,9 @@ -# vars-on-top +--- +title: vars-on-top +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/vars-on-top.md +rule_type: suggestion +--- Requires variable declarations to be at the top of their scope. diff --git a/docs/src/rules/wrap-iife.md b/docs/src/rules/wrap-iife.md index 4e5e252b04d..0b9cd2d9748 100644 --- a/docs/src/rules/wrap-iife.md +++ b/docs/src/rules/wrap-iife.md @@ -1,4 +1,11 @@ -# wrap-iife +--- +title: wrap-iife +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/wrap-iife.md +rule_type: layout +--- + + Requires IIFEs to be wrapped. diff --git a/docs/src/rules/wrap-regex.md b/docs/src/rules/wrap-regex.md index e8b5e24b8f3..9249d703ea2 100644 --- a/docs/src/rules/wrap-regex.md +++ b/docs/src/rules/wrap-regex.md @@ -1,4 +1,11 @@ -# wrap-regex +--- +title: wrap-regex +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/wrap-regex.md +rule_type: layout +--- + + Requires regex literals to be wrapped. diff --git a/docs/src/rules/yield-star-spacing.md b/docs/src/rules/yield-star-spacing.md index cc82ee3e63d..dabe6b2a938 100644 --- a/docs/src/rules/yield-star-spacing.md +++ b/docs/src/rules/yield-star-spacing.md @@ -1,4 +1,11 @@ -# yield-star-spacing +--- +title: yield-star-spacing +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/yield-star-spacing.md +rule_type: layout +--- + + Enforces spacing around the `*` in `yield*` expressions. diff --git a/docs/src/rules/yoda.md b/docs/src/rules/yoda.md index 2a22f11d0a2..65efff7ece1 100644 --- a/docs/src/rules/yoda.md +++ b/docs/src/rules/yoda.md @@ -1,4 +1,11 @@ -# yoda +--- +title: yoda +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/yoda.md +rule_type: suggestion +--- + + Requires or disallows "Yoda" conditions. diff --git a/docs/src/user-guide/README.md b/docs/src/user-guide/README.md index 63b7533f732..fd935711dd4 100644 --- a/docs/src/user-guide/README.md +++ b/docs/src/user-guide/README.md @@ -1,8 +1,13 @@ -# User Guide +--- +title: User Guide +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/user-guide/README.md + +--- This guide is intended for those who wish to use ESLint as an end-user. If you're looking for how to extend ESLint or work with the ESLint source code, please see the [Developer Guide](../developer-guide). -## [Getting Started](getting-started.md) +## [Getting Started](getting-started) Want to skip ahead and just start using ESLint? This section gives a high-level overview of installation, setup, and configuration options. @@ -14,15 +19,15 @@ ESLint has a lot of rules that you can configure to fine-tune it to your project Once you've got ESLint running, you'll probably want to adjust the configuration to better suit your project. This section explains all the different ways you can configure ESLint. -## [Command Line Interface](command-line-interface.md) +## [Command Line Interface](command-line-interface) There are a lot of command line flags for ESLint and this section explains what they do. -## [Integrations](integrations.md) +## [Integrations](integrations) Wondering if ESLint will work with your favorite editor or build system? This section has a list of all known integrations (submitted by their authors). -## [Rule Deprecation](rule-deprecation.md) +## [Rule Deprecation](rule-deprecation) The ESLint team is committed to making upgrading as easy and painless as possible. This section outlines the guidelines the team has set in place for the deprecation of rules in future releases. @@ -30,10 +35,10 @@ The ESLint team is committed to making upgrading as easy and painless as possibl If you were using a prior version of ESLint, you can get help with the transition by reading: -* [migrating-to-1.0.0](migrating-to-1.0.0.md) -* [migrating-to-2.0.0](migrating-to-2.0.0.md) -* [migrating-to-3.0.0](migrating-to-3.0.0.md) -* [migrating-to-4.0.0](migrating-to-4.0.0.md) -* [migrating-to-5.0.0](migrating-to-5.0.0.md) -* [migrating-to-6.0.0](migrating-to-6.0.0.md) -* [migrating-to-7.0.0](migrating-to-7.0.0.md) +* [migrating-to-1.0.0](migrating-to-1.0.0) +* [migrating-to-2.0.0](migrating-to-2.0.0) +* [migrating-to-3.0.0](migrating-to-3.0.0) +* [migrating-to-4.0.0](migrating-to-4.0.0) +* [migrating-to-5.0.0](migrating-to-5.0.0) +* [migrating-to-6.0.0](migrating-to-6.0.0) +* [migrating-to-7.0.0](migrating-to-7.0.0) diff --git a/docs/src/user-guide/command-line-interface.md b/docs/src/user-guide/command-line-interface.md index 26600ef96b1..e7c7b32f5ab 100644 --- a/docs/src/user-guide/command-line-interface.md +++ b/docs/src/user-guide/command-line-interface.md @@ -1,4 +1,9 @@ -# Command Line Interface +--- +title: Command Line Interface +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/user-guide/command-line-interface.md + +--- ESLint requires Node.js for installation. Follow the instructions in the [Getting Started Guide](https://eslint.org/docs/user-guide/getting-started) to install ESLint. @@ -124,7 +129,7 @@ If `.eslintrc.*` and/or `package.json` files are also used for configuration (i. #### `--env` -This option enables specific environments. Details about the global variables defined by each environment are available on the [Specifying Environments](configuring/language-options.md#specifying-environments) documentation. This option only enables environments; it does not disable environments set in other configuration files. To specify multiple environments, separate them using commas, or use the option multiple times. +This option enables specific environments. Details about the global variables defined by each environment are available on the [Specifying Environments](configuring/language-options#specifying-environments) documentation. This option only enables environments; it does not disable environments set in other configuration files. To specify multiple environments, separate them using commas, or use the option multiple times. Examples: @@ -284,7 +289,7 @@ Example: #### `--ignore-pattern` -This option allows you to specify patterns of files to ignore (in addition to those in `.eslintignore`). You can repeat the option to provide multiple patterns. The supported syntax is the same as for `.eslintignore` [files](configuring/ignoring-code.md#the-eslintignore-file), which use the same patterns as the `.gitignore` [specification](https://git-scm.com/docs/gitignore). You should quote your patterns in order to avoid shell interpretation of glob patterns. +This option allows you to specify patterns of files to ignore (in addition to those in `.eslintignore`). You can repeat the option to provide multiple patterns. The supported syntax is the same as for `.eslintignore` [files](configuring/ignoring-code#the-eslintignore-file), which use the same patterns as the `.gitignore` [specification](https://git-scm.com/docs/gitignore). You should quote your patterns in order to avoid shell interpretation of glob patterns. Example: @@ -344,16 +349,16 @@ When specified, the given format is output into the provided file name. This option specifies the output format for the console. Possible formats are: -* [checkstyle](formatters.md/#checkstyle) -* [compact](formatters.md/#compact) -* [html](formatters.md/#html) -* [jslint-xml](formatters.md/#jslint-xml) -* [json](formatters.md/#json) -* [junit](formatters.md/#junit) -* [stylish](formatters.md/#stylish) (the default) -* [tap](formatters.md/#tap) -* [unix](formatters.md/#unix) -* [visualstudio](formatters.md/#visualstudio) +* [checkstyle](formatters/#checkstyle) +* [compact](formatters/#compact) +* [html](formatters/#html) +* [jslint-xml](formatters/#jslint-xml) +* [json](formatters/#json) +* [junit](formatters/#junit) +* [stylish](formatters/#stylish) (the default) +* [tap](formatters/#tap) +* [unix](formatters/#unix) +* [visualstudio](formatters/#visualstudio) Example: @@ -505,7 +510,7 @@ ESLint supports `.eslintignore` files to exclude files from the linting process temp.js **/vendor/*.js -A more detailed breakdown of supported patterns and directories ESLint ignores by default can be found in [Ignoring Code](configuring/ignoring-code.md). +A more detailed breakdown of supported patterns and directories ESLint ignores by default can be found in [Ignoring Code](configuring/ignoring-code). ## Exit codes diff --git a/docs/src/user-guide/configuring/README.md b/docs/src/user-guide/configuring/README.md index 2d22421e0c3..0b491c4c99f 100644 --- a/docs/src/user-guide/configuring/README.md +++ b/docs/src/user-guide/configuring/README.md @@ -1,52 +1,56 @@ -# Configuring ESLint +--- +title: Configuring ESLint +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/user-guide/configuring/README.md +--- ESLint is designed to be flexible and configurable for your use case. You can turn off every rule and run only with basic syntax validation or mix and match the bundled rules and your custom rules to fit the needs of your project. There are two primary ways to configure ESLint: 1. **Configuration Comments** - use JavaScript comments to embed configuration information directly into a file. -1. **Configuration Files** - use a JavaScript, JSON, or YAML file to specify configuration information for an entire directory and all of its subdirectories. This can be in the form of an [`.eslintrc.*`](./configuration-files.md#configuration-file-formats) file or an `eslintConfig` field in a [`package.json`](https://docs.npmjs.com/files/package.json) file, both of which ESLint will look for and read automatically, or you can specify a configuration file on the [command line](https://eslint.org/docs/user-guide/command-line-interface). +1. **Configuration Files** - use a JavaScript, JSON, or YAML file to specify configuration information for an entire directory and all of its subdirectories. This can be in the form of an [`.eslintrc.*`](./configuration-files#configuration-file-formats) file or an `eslintConfig` field in a [`package.json`](https://docs.npmjs.com/files/package.json) file, both of which ESLint will look for and read automatically, or you can specify a configuration file on the [command line](https://eslint.org/docs/user-guide/command-line-interface). Here are some of the options that you can configure in ESLint: -* [**Environments**](./language-options.md#specifying-environments) - which environments your script is designed to run in. Each environment brings with it a certain set of predefined global variables. -* [**Globals**](./language-options.md#specifying-globals) - the additional global variables your script accesses during execution. -* [**Rules**](rules.md) - which rules are enabled and at what error level. -* [**Plugins**](plugins.md) - which third-party plugins define additional rules, environments, configs, etc. for ESLint to use. +* [**Environments**](./language-options#specifying-environments) - which environments your script is designed to run in. Each environment brings with it a certain set of predefined global variables. +* [**Globals**](./language-options#specifying-globals) - the additional global variables your script accesses during execution. +* [**Rules**](rules) - which rules are enabled and at what error level. +* [**Plugins**](plugins) - which third-party plugins define additional rules, environments, configs, etc. for ESLint to use. All of these options give you fine-grained control over how ESLint treats your code. ## Table of Contents -[**Configuration Files**](configuration-files.md) +[**Configuration Files**](configuration-files) -* [Configuration File Formats](./configuration-files.md#configuration-file-formats) -* [Using Configuration Files](./configuration-files.md#using-configuration-files) -* [Adding Shared Settings](./configuration-files.md#adding-shared-settings) -* [Cascading and Hierarchy](./configuration-files.md#cascading-and-hierarchy) -* [Extending Configuration Files](./configuration-files.md#extending-configuration-files) -* [Configuration Based on Glob Patterns](./configuration-files.md#configuration-based-on-glob-patterns) -* [Personal Configuration Files](./configuration-files.md#personal-configuration-files-deprecated) +* [Configuration File Formats](./configuration-files#configuration-file-formats) +* [Using Configuration Files](./configuration-files#using-configuration-files) +* [Adding Shared Settings](./configuration-files#adding-shared-settings) +* [Cascading and Hierarchy](./configuration-files#cascading-and-hierarchy) +* [Extending Configuration Files](./configuration-files#extending-configuration-files) +* [Configuration Based on Glob Patterns](./configuration-files#configuration-based-on-glob-patterns) +* [Personal Configuration Files](./configuration-files#personal-configuration-files-deprecated) -[**Language Options**](language-options.md) +[**Language Options**](language-options) -* [Specifying Environments](./language-options.md#specifying-environments) -* [Specifying Globals](./language-options.md#specifying-globals) -* [Specifying Parser Options](./language-options.md#specifying-parser-options) +* [Specifying Environments](./language-options#specifying-environments) +* [Specifying Globals](./language-options#specifying-globals) +* [Specifying Parser Options](./language-options#specifying-parser-options) -[**Rules**](rules.md) +[**Rules**](rules) -* [Configuring Rules](./rules.md#configuring-rules) -* [Disabling Rules](./rules.md#disabling-rules) +* [Configuring Rules](./rules#configuring-rules) +* [Disabling Rules](./rules#disabling-rules) -[**Plugins**](plugins.md) +[**Plugins**](plugins) -* [Specifying Parser](./plugins.md#specifying-parser) -* [Specifying Processor](./plugins.md#specifying-processor) -* [Configuring Plugins](./plugins.md#configuring-plugins) +* [Specifying Parser](./plugins#specifying-parser) +* [Specifying Processor](./plugins#specifying-processor) +* [Configuring Plugins](./plugins#configuring-plugins) -[**Ignoring Code**](ignoring-code.md) +[**Ignoring Code**](ignoring-code) -* [`ignorePatterns` in Config Files](./ignoring-code.md#ignorepatterns-in-config-files) -* [The `.eslintignore` File](./ignoring-code.md#the-eslintignore-file) -* [Using an Alternate File](./ignoring-code.md#using-an-alternate-file) -* [Using eslintIgnore in package.json](./ignoring-code.md#using-eslintignore-in-packagejson) -* [Ignored File Warnings](./ignoring-code.md#ignored-file-warnings) +* [`ignorePatterns` in Config Files](./ignoring-code#ignorepatterns-in-config-files) +* [The `.eslintignore` File](./ignoring-code#the-eslintignore-file) +* [Using an Alternate File](./ignoring-code#using-an-alternate-file) +* [Using eslintIgnore in package.json](./ignoring-code#using-eslintignore-in-packagejson) +* [Ignored File Warnings](./ignoring-code#ignored-file-warnings) diff --git a/docs/src/user-guide/configuring/configuration-files.md b/docs/src/user-guide/configuring/configuration-files.md index d3368e767ac..a21291a477d 100644 --- a/docs/src/user-guide/configuring/configuration-files.md +++ b/docs/src/user-guide/configuring/configuration-files.md @@ -1,4 +1,9 @@ -# Configuration Files +--- +title: Configuration Files +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/user-guide/configuring/configuration-files.md + +--- * [Configuration File Formats](#configuration-file-formats) * [Using Configuration Files](#using-configuration-files) @@ -277,7 +282,7 @@ module.exports = { A [plugin](https://eslint.org/docs/developer-guide/working-with-plugins) is an npm package that can add various extensions to ESLint. A plugin can perform numerous functions, including but not limited to adding new rules and exporting [shareable configurations](https://eslint.org/docs/developer-guide/working-with-plugins#configs-in-plugins). Make sure the package has been installed in a directory where ESLint can require it. -The `plugins` [property value](./plugins.md#configuring-plugins) can omit the `eslint-plugin-` prefix of the package name. +The `plugins` [property value](./plugins#configuring-plugins) can omit the `eslint-plugin-` prefix of the package name. The `extends` property value can consist of: diff --git a/docs/src/user-guide/configuring/ignoring-code.md b/docs/src/user-guide/configuring/ignoring-code.md index 35c2d25dd3f..8aab1336b08 100644 --- a/docs/src/user-guide/configuring/ignoring-code.md +++ b/docs/src/user-guide/configuring/ignoring-code.md @@ -1,4 +1,9 @@ -# Ignoring Code +--- +title: Ignoring Code +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/user-guide/configuring/ignoring-code.md + +--- * [`ignorePatterns` in Config Files](#ignorepatterns-in-config-files) * [The `.eslintignore` File](#the-eslintignore-file) @@ -8,7 +13,7 @@ ## `ignorePatterns` in Config Files -You can tell ESLint to ignore specific files and directories using `ignorePatterns` in your config files. `ignorePatterns` patterns follow the same rules as `.eslintignore`. Please see the [the `.eslintignore` file documentation](./ignoring-code.md#the-eslintignore-file) to learn more. +You can tell ESLint to ignore specific files and directories using `ignorePatterns` in your config files. `ignorePatterns` patterns follow the same rules as `.eslintignore`. Please see the [the `.eslintignore` file documentation](./ignoring-code#the-eslintignore-file) to learn more. ```json { diff --git a/docs/src/user-guide/configuring/language-options.md b/docs/src/user-guide/configuring/language-options.md index 6ba406b827e..5523fbab559 100644 --- a/docs/src/user-guide/configuring/language-options.md +++ b/docs/src/user-guide/configuring/language-options.md @@ -1,4 +1,9 @@ -# Language Options +--- +title: Language Options +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/user-guide/configuring/language-options.md + +--- * [Specifying Environments](#specifying-environments) * [Specifying Globals](#specifying-globals) diff --git a/docs/src/user-guide/configuring/plugins.md b/docs/src/user-guide/configuring/plugins.md index 9d2c9294c4c..f56da1e2f80 100644 --- a/docs/src/user-guide/configuring/plugins.md +++ b/docs/src/user-guide/configuring/plugins.md @@ -1,4 +1,9 @@ -# Plugins +--- +title: Plugins +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/user-guide/configuring/plugins.md + +--- * [Specifying Parser](#specifying-parser) * [Specifying Processor](#specifying-processor) diff --git a/docs/src/user-guide/configuring/rules.md b/docs/src/user-guide/configuring/rules.md index 205a5f11995..36540ea3a9e 100644 --- a/docs/src/user-guide/configuring/rules.md +++ b/docs/src/user-guide/configuring/rules.md @@ -1,4 +1,9 @@ -# Rules +--- +title: Rules +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/user-guide/configuring/rules.md + +--- * [Configuring Rules](#configuring-rules) * [Disabling Rules](#disabling-rules) diff --git a/docs/src/user-guide/getting-started.md b/docs/src/user-guide/getting-started.md index ef80229766c..3e9fcd2b5e0 100644 --- a/docs/src/user-guide/getting-started.md +++ b/docs/src/user-guide/getting-started.md @@ -1,4 +1,9 @@ -# Getting Started with ESLint +--- +title: Getting Started with ESLint +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/user-guide/getting-started.md + +--- ESLint is a tool for identifying and reporting on patterns found in ECMAScript/JavaScript code, with the goal of making code more consistent and avoiding bugs. In many ways, it is similar to JSLint and JSHint with a few exceptions: @@ -46,7 +51,7 @@ It is also possible to install ESLint globally rather than locally (using `npm i ## Configuration -**Note:** If you are coming from a version before 1.0.0 please see the [migration guide](migrating-to-1.0.0.md). +**Note:** If you are coming from a version before 1.0.0 please see the [migration guide](migrating-to-1.0.0). After running `npm init @eslint/config`, you'll have a `.eslintrc.{js,yml,json}` file in your directory. In it, you'll see some rules configured like this: @@ -82,7 +87,7 @@ Because of this line, all of the rules marked "(recommended)" on the [rules page ## Next Steps * Learn about [advanced configuration](configuring/) of ESLint. -* Get familiar with the [command line options](command-line-interface.md). -* Explore [ESLint integrations](integrations.md) into other tools like editors, build systems, and more. -* Can't find just the right rule? Make your own [custom rule](/docs/developer-guide/working-with-rules.md). +* Get familiar with the [command line options](command-line-interface). +* Explore [ESLint integrations](integrations) into other tools like editors, build systems, and more. +* Can't find just the right rule? Make your own [custom rule](/docs/developer-guide/working-with-rules). * Make ESLint even better by [contributing](/docs/developer-guide/contributing/). diff --git a/docs/src/user-guide/integrations.md b/docs/src/user-guide/integrations.md index 08181931e4a..6f5c809c9a8 100644 --- a/docs/src/user-guide/integrations.md +++ b/docs/src/user-guide/integrations.md @@ -1,4 +1,9 @@ -# Integrations +--- +title: Integrations +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/user-guide/integrations.md + +--- ## Editors diff --git a/docs/src/user-guide/migrating-from-jscs.md b/docs/src/user-guide/migrating-from-jscs.md index 66e4fe7a206..c25af456656 100644 --- a/docs/src/user-guide/migrating-from-jscs.md +++ b/docs/src/user-guide/migrating-from-jscs.md @@ -1,4 +1,9 @@ -# Migrating from JSCS +--- +title: Migrating from JSCS +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/user-guide/migrating-from-jscs.md + +--- In April 2016, we [announced](https://eslint.org/blog/2016/04/welcoming-jscs-to-eslint) that the JSCS project was shutting down and the JSCS team would be joining the ESLint team. This guide is intended to help those who are using JSCS to migrate their settings and projects to use ESLint. We've tried to automate as much of the conversion as possible, but there are some manual changes that are needed. diff --git a/docs/src/user-guide/migrating-to-1.0.0.md b/docs/src/user-guide/migrating-to-1.0.0.md index 637e3059e6a..f71b428ed7d 100644 --- a/docs/src/user-guide/migrating-to-1.0.0.md +++ b/docs/src/user-guide/migrating-to-1.0.0.md @@ -1,4 +1,9 @@ -# Migrating to v1.0.0 +--- +title: Migrating to v1.0.0 +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/user-guide/migrating-to-1.0.0.md + +--- ESLint v1.0.0 is the first major version release. As a result, there are some significant changes between how ESLint worked during its life in 0.x and how it will work going forward. These changes are the direct result of feedback from the ESLint community of users and were not made without due consideration for the upgrade path. We believe that these changes make ESLint even better, and while some work is necessary to upgrade, we hope the pain of this upgrade is small enough that you will see the benefit of upgrading. diff --git a/docs/src/user-guide/migrating-to-2.0.0.md b/docs/src/user-guide/migrating-to-2.0.0.md index 4ca97cbe8a8..aa216aa3f49 100644 --- a/docs/src/user-guide/migrating-to-2.0.0.md +++ b/docs/src/user-guide/migrating-to-2.0.0.md @@ -1,4 +1,9 @@ -# Migrating to v2.0.0 +--- +title: Migrating to v2.0.0 +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/user-guide/migrating-to-2.0.0.md + +--- ESLint v2.0.0 is the second major version release. As a result, there are some significant changes between how ESLint worked during its life in 0.x and 1.x and how it will work going forward. These changes are the direct result of feedback from the ESLint community of users and were not made without due consideration for the upgrade path. We believe that these changes make ESLint even better, and while some work is necessary to upgrade, we hope the pain of this upgrade is small enough that you will see the benefit of upgrading. @@ -347,7 +352,7 @@ var sourceCode = new SourceCode(text, ast); ## Rule Changes -* [`strict`](../rules/strict.md) - defaults to `"safe"` (previous default was `"function"`) +* [`strict`](../rules/strict) - defaults to `"safe"` (previous default was `"function"`) ## Plugins No Longer Have Default Configurations diff --git a/docs/src/user-guide/migrating-to-3.0.0.md b/docs/src/user-guide/migrating-to-3.0.0.md index af19c769a56..8435e28ebb3 100644 --- a/docs/src/user-guide/migrating-to-3.0.0.md +++ b/docs/src/user-guide/migrating-to-3.0.0.md @@ -1,4 +1,9 @@ -# Migrating to v3.0.0 +--- +title: Migrating to v3.0.0 +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/user-guide/migrating-to-3.0.0.md + +--- ESLint v3.0.0 is the third major version release. We have made several breaking changes in this release, however, we believe the changes to be small enough that they should not require significant changes for ESLint users. This guide is intended to walk you through the changes. diff --git a/docs/src/user-guide/migrating-to-4.0.0.md b/docs/src/user-guide/migrating-to-4.0.0.md index 8f78291d5cd..cef90a3ddcc 100644 --- a/docs/src/user-guide/migrating-to-4.0.0.md +++ b/docs/src/user-guide/migrating-to-4.0.0.md @@ -1,4 +1,9 @@ -# Migrating to v4.0.0 +--- +title: Migrating to v4.0.0 +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/user-guide/migrating-to-4.0.0.md + +--- ESLint v4.0.0 is the fourth major version release. We have made several breaking changes in this release; however, we expect that most of the changes will only affect a very small percentage of users. This guide is intended to walk you through the changes. diff --git a/docs/src/user-guide/migrating-to-5.0.0.md b/docs/src/user-guide/migrating-to-5.0.0.md index 01bd1e2a644..0bddbe1dcb1 100644 --- a/docs/src/user-guide/migrating-to-5.0.0.md +++ b/docs/src/user-guide/migrating-to-5.0.0.md @@ -1,4 +1,9 @@ -# Migrating to v5.0.0 +--- +title: Migrating to v5.0.0 +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/user-guide/migrating-to-5.0.0.md + +--- ESLint v5.0.0 is the fifth major version release. We have made a few breaking changes in this release, but we expect that most users will be able to upgrade without any modifications to their build. This guide is intended to walk you through the breaking changes. diff --git a/docs/src/user-guide/migrating-to-6.0.0.md b/docs/src/user-guide/migrating-to-6.0.0.md index 225cc4c0e3b..14cc7d868cf 100644 --- a/docs/src/user-guide/migrating-to-6.0.0.md +++ b/docs/src/user-guide/migrating-to-6.0.0.md @@ -1,4 +1,9 @@ -# Migrating to v6.0.0 +--- +title: Migrating to v6.0.0 +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/user-guide/migrating-to-6.0.0.md + +--- ESLint v6.0.0 is a major release of ESLint. We have made a few breaking changes in this release. This guide is intended to walk you through the breaking changes. diff --git a/docs/src/user-guide/migrating-to-7.0.0.md b/docs/src/user-guide/migrating-to-7.0.0.md index 8b57df2444f..b04b143f231 100644 --- a/docs/src/user-guide/migrating-to-7.0.0.md +++ b/docs/src/user-guide/migrating-to-7.0.0.md @@ -1,4 +1,9 @@ -# Migrating to v7.0.0 +--- +title: Migrating to v7.0.0 +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/user-guide/migrating-to-7.0.0.md + +--- ESLint v7.0.0 is a major release of ESLint. We have made a few breaking changes in this release. This guide is intended to walk you through the breaking changes. diff --git a/docs/src/user-guide/migrating-to-8.0.0.md b/docs/src/user-guide/migrating-to-8.0.0.md index 86c2bc757fa..ea3457ff05c 100644 --- a/docs/src/user-guide/migrating-to-8.0.0.md +++ b/docs/src/user-guide/migrating-to-8.0.0.md @@ -1,4 +1,9 @@ -# Migrating to v8.0.0 +--- +title: Migrating to v8.0.0 +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/user-guide/migrating-to-8.0.0.md + +--- ESLint v8.0.0 is a major release of ESLint. We have made a few breaking changes in this release. This guide is intended to walk you through the breaking changes. diff --git a/docs/src/user-guide/rule-deprecation.md b/docs/src/user-guide/rule-deprecation.md index e306916532d..2b929473187 100644 --- a/docs/src/user-guide/rule-deprecation.md +++ b/docs/src/user-guide/rule-deprecation.md @@ -1,4 +1,9 @@ -# Rule Deprecation +--- +title: Rule Deprecation +layout: doc +edit_link: https://github.com/eslint/eslint/edit/main/docs/src/user-guide/rule-deprecation.md + +--- Balancing the trade-offs of improving a tool and the frustration these changes can cause is a difficult task. One key area in which this affects our users is in the removal of rules.