Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: update 'Related Rules' and 'Further Reading' in remaining rules #15884

Merged
merged 6 commits into from May 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile.js
Expand Up @@ -775,7 +775,7 @@ target.checkRuleFiles = function() {
const docText = cat(docFilename);
const docMarkdown = marked.lexer(docText, { gfm: true, silent: false });
const ruleCode = cat(filename);
const knownHeaders = ["Rule Details", "Options", "Environments", "Examples", "Known Limitations", "When Not To Use It", "Related Rules", "Compatibility", "Further Reading"];
const knownHeaders = ["Rule Details", "Options", "Environments", "Examples", "Known Limitations", "When Not To Use It", "Compatibility"];

/**
* Check if basename is present in rule-types.json file.
Expand Down
18 changes: 7 additions & 11 deletions docs/src/rules/accessor-pairs.md
Expand Up @@ -3,6 +3,13 @@ title: accessor-pairs
layout: doc
edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/accessor-pairs.md
rule_type: suggestion
related_rules:
- no-dupe-keys
- no-dupe-class-members
further_reading:
- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/set
- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get
- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects
---

Enforces getter/setter pairs in objects and classes.
Expand Down Expand Up @@ -287,14 +294,3 @@ See [no-dupe-class-members](no-dupe-class-members) if you also want to disallow
## When Not To Use It

You can turn this rule off if you are not concerned with the simultaneous presence of setters and getters on objects.

## Related Rules

* [no-dupe-keys](no-dupe-keys)
* [no-dupe-class-members](no-dupe-class-members)

## Further Reading

* [Object Setters](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/set)
* [Object Getters](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get)
* [Working with Objects](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects)
6 changes: 2 additions & 4 deletions docs/src/rules/array-bracket-newline.md
Expand Up @@ -3,6 +3,8 @@ 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
related_rules:
- array-bracket-spacing
---

<!--FIXABLE-->
Expand Down Expand Up @@ -280,10 +282,6 @@ var e = [

If you don't want to enforce line breaks after opening and before closing array brackets, don't enable this rule.

## Related Rules

* [array-bracket-spacing](array-bracket-spacing)

## Compatibility

* **JSCS:** [validateNewlineAfterArrayElements](https://jscs-dev.github.io/rule/validateNewlineAfterArrayElements)
10 changes: 4 additions & 6 deletions docs/src/rules/array-bracket-spacing.md
Expand Up @@ -3,6 +3,10 @@ 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
related_rules:
- space-in-parens
- object-curly-spacing
- computed-property-spacing
---

<!--FIXABLE-->
Expand Down Expand Up @@ -224,9 +228,3 @@ var arr = [[ 1, 2 ], 2, [ 3, 4 ]];
## When Not To Use It

You can turn this rule off if you are not concerned with the consistency of spacing between array brackets.

## Related Rules

* [space-in-parens](space-in-parens)
* [object-curly-spacing](object-curly-spacing)
* [computed-property-spacing](computed-property-spacing)
20 changes: 9 additions & 11 deletions docs/src/rules/array-element-newline.md
Expand Up @@ -3,6 +3,15 @@ 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
related_rules:
- array-bracket-spacing
- array-bracket-newline
- object-property-newline
- object-curly-spacing
- object-curly-newline
- max-statements-per-line
- block-spacing
- brace-style
---

<!--FIXABLE-->
Expand Down Expand Up @@ -383,17 +392,6 @@ var [i = function foo() {

If you don't want to enforce linebreaks between array elements, don't enable this rule.

## Related Rules

* [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

* **JSCS:** [validateNewlineAfterArrayElements](https://jscs-dev.github.io/rule/validateNewlineAfterArrayElements)
7 changes: 2 additions & 5 deletions docs/src/rules/arrow-parens.md
Expand Up @@ -3,6 +3,8 @@ title: arrow-parens
layout: doc
edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/arrow-parens.md
rule_type: layout
further_reading:
- https://github.com/airbnb/javascript#arrows--one-arg-parens
---

<!--FIXABLE-->
Expand Down Expand Up @@ -230,8 +232,3 @@ a((foo) => { if (true) {} });
([a, b]) => a;
({a, b}) => a;
```

## Further Reading

* The `"as-needed", { "requireForBlockBody": true }` rule is directly inspired by the Airbnb
[JS Style Guide](https://github.com/airbnb/javascript#arrows--one-arg-parens).
8 changes: 3 additions & 5 deletions docs/src/rules/block-spacing.md
Expand Up @@ -3,6 +3,9 @@ title: block-spacing
layout: doc
edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/block-spacing.md
rule_type: layout
related_rules:
- space-before-blocks
- brace-style
---

<!--FIXABLE-->
Expand Down Expand Up @@ -82,8 +85,3 @@ class C {
## When Not To Use It

If you don't want to be notified about spacing style inside of blocks, you can safely disable this rule.

## Related Rules

* [space-before-blocks](space-before-blocks)
* [brace-style](brace-style)
14 changes: 5 additions & 9 deletions docs/src/rules/brace-style.md
Expand Up @@ -3,6 +3,11 @@ title: brace-style
layout: doc
edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/brace-style.md
rule_type: layout
related_rules:
- block-spacing
- space-before-blocks
further_reading:
- https://en.wikipedia.org/wiki/Indent_style
---

<!--FIXABLE-->
Expand Down Expand Up @@ -392,12 +397,3 @@ class D { static { foo(); } }
## When Not To Use It

If you don't want to enforce a particular brace style, don't enable this rule.

## Related Rules

* [block-spacing](block-spacing)
* [space-before-blocks](space-before-blocks)

## Further Reading

* [Indent style](https://en.wikipedia.org/wiki/Indent_style)
14 changes: 5 additions & 9 deletions docs/src/rules/callback-return.md
Expand Up @@ -3,6 +3,11 @@ title: callback-return
layout: doc
edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/callback-return.md
rule_type: suggestion
related_rules:
- handle-callback-err
further_reading:
- https://github.com/maxogden/art-of-node#callbacks
- https://web.archive.org/web/20171224042620/https://docs.nodejitsu.com/articles/errors/what-are-the-error-conventions/
---

Enforces return after callback.
Expand Down Expand Up @@ -171,12 +176,3 @@ function foo(err, callback) {
There are some cases where you might want to call a callback function more than once. In those cases this rule
may lead to incorrect behavior. In those cases you may want to reserve a special name for those callbacks and
not include that in the list of callbacks that trigger warnings.

## Related Rules

* [handle-callback-err](handle-callback-err)

## Further Reading

* [The Art Of Node: Callbacks](https://github.com/maxogden/art-of-node#callbacks)
* [Nodejitsu: What are the error conventions?](https://docs.nodejitsu.com/articles/errors/what-are-the-error-conventions/)
8 changes: 3 additions & 5 deletions docs/src/rules/class-methods-use-this.md
Expand Up @@ -3,6 +3,9 @@ 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
further_reading:
- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes
- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/static
---

Enforces that class methods utilize `this`.
Expand Down Expand Up @@ -173,8 +176,3 @@ class A {
foo = () => {}
}
```

## Further Reading

* [Classes](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes)
* [Static Methods](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/static)
28 changes: 12 additions & 16 deletions docs/src/rules/comma-spacing.md
Expand Up @@ -3,6 +3,18 @@ title: comma-spacing
layout: doc
edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/comma-spacing.md
rule_type: layout
related_rules:
- array-bracket-spacing
- comma-style
- space-in-brackets
- space-in-parens
- space-infix-ops
- space-after-keywords
- space-unary-ops
- space-return-throw-case
further_reading:
- https://www.crockford.com/code.html
- https://dojotoolkit.org/reference-guide/1.9/developer/styleguide.html
---

<!--FIXABLE-->
Expand Down Expand Up @@ -118,19 +130,3 @@ var arr = [,2 ,3]
## When Not To Use It

If your project will not be following a consistent comma-spacing pattern, turn this rule off.

## Related Rules

* [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

* [JavaScript](http://javascript.crockford.com/code.html)
* [Dojo Style Guide](https://dojotoolkit.org/reference-guide/1.9/developer/styleguide.html)
15 changes: 4 additions & 11 deletions docs/src/rules/comma-style.md
Expand Up @@ -3,6 +3,10 @@ title: comma-style
layout: doc
edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/comma-style.md
rule_type: layout
related_rules:
- operator-linebreak
further_reading:
- https://gist.github.com/isaacs/357981
---

<!--FIXABLE-->
Expand Down Expand Up @@ -165,14 +169,3 @@ var o = {fst:1,
## When Not To Use It

This rule can safely be turned off if your project does not care about enforcing a consistent comma style.

## Related Rules

* [operator-linebreak](operator-linebreak)

## Further Reading

For more information on the Comma First style:

* [A better coding convention for lists and object literals in JavaScript by isaacs](https://gist.github.com/isaacs/357981)
* [npm coding style guideline](https://docs.npmjs.com/misc/coding-style)
32 changes: 14 additions & 18 deletions docs/src/rules/complexity.md
Expand Up @@ -3,6 +3,20 @@ title: complexity
layout: doc
edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/complexity.md
rule_type: suggestion
related_rules:
- max-depth
- max-len
- max-lines
- max-lines-per-function
- max-nested-callbacks
- max-params
- max-statements
further_reading:
- https://en.wikipedia.org/wiki/Cyclomatic_complexity
- https://ariya.io/2012/12/complexity-analysis-of-javascript-code
- https://craftsmanshipforsoftware.com/2015/05/25/complexity-for-javascript/
- https://web.archive.org/web/20160808115119/http://jscomplexity.org/complexity
- https://github.com/eslint/eslint/issues/4808#issuecomment-167795140
---

Enforces a maximum cyclomatic complexity.
Expand Down Expand Up @@ -130,21 +144,3 @@ is equivalent to
## When Not To Use It

If you can't determine an appropriate complexity limit for your code, then it's best to disable this rule.

## Related Rules

* [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

* [Cyclomatic Complexity](https://en.wikipedia.org/wiki/Cyclomatic_complexity)
* [Complexity Analysis of JavaScript Code](https://ariya.io/2012/12/complexity-analysis-of-javascript-code)
* [More about Complexity in JavaScript](https://craftsmanshipforsoftware.com/2015/05/25/complexity-for-javascript/)
* [About Complexity](https://web.archive.org/web/20160808115119/http://jscomplexity.org/complexity)
* [Discussion about Complexity in ESLint and more links](https://github.com/eslint/eslint/issues/4808#issuecomment-167795140)
10 changes: 4 additions & 6 deletions docs/src/rules/computed-property-spacing.md
Expand Up @@ -3,6 +3,10 @@ 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
related_rules:
- array-bracket-spacing
- comma-spacing
- space-in-parens
---

<!--FIXABLE-->
Expand Down Expand Up @@ -180,9 +184,3 @@ const Bar = class {
## When Not To Use It

You can turn this rule off if you are not concerned with the consistency of computed properties.

## Related Rules

* [array-bracket-spacing](array-bracket-spacing)
* [comma-spacing](comma-spacing)
* [space-in-parens](space-in-parens)
12 changes: 4 additions & 8 deletions docs/src/rules/default-case-last.md
Expand Up @@ -3,6 +3,10 @@ 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
related_rules:
- default-case
further_reading:
- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/switch
---

Enforces default clauses in switch statements to be last.
Expand Down Expand Up @@ -122,11 +126,3 @@ if (foo !== 0) {
}
doSomethingAnyway();
```

## Related Rules

* [default-case](default-case)

## Further Reading

* [MDN switch statement](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/switch)
6 changes: 2 additions & 4 deletions docs/src/rules/default-case.md
Expand Up @@ -3,6 +3,8 @@ title: default-case
layout: doc
edit_link: https://github.com/eslint/eslint/edit/main/docs/src/rules/default-case.md
rule_type: suggestion
related_rules:
- no-fallthrough
---

Requires a `default` case in switch statements.
Expand Down Expand Up @@ -126,7 +128,3 @@ switch(a) {
## When Not To Use It

If you don't want to enforce a `default` case for `switch` statements, you can safely disable this rule.

## Related Rules

* [no-fallthrough](no-fallthrough)