Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
docs: trimmed rules h1s to just be rule names (#15514)
* docs: trimmed rules h1s to just be rule names

* Adjusted Makefile unit test

* Standardized backticks a bit
  • Loading branch information
JoshuaKGoldberg committed Jan 26, 2022
1 parent 851f1f1 commit ccbc35f
Show file tree
Hide file tree
Showing 305 changed files with 937 additions and 329 deletions.
13 changes: 3 additions & 10 deletions Makefile.js
Expand Up @@ -809,17 +809,10 @@ target.checkRuleFiles = function() {
* @param {string} id id to check for
* @returns {boolean} true if present
* @private
* @todo Will remove this check when the main heading is automatically generated from rule metadata.
*/
function hasIdInTitle(id) {
const idOldAtEndOfTitleRegExp = new RegExp(`^# (.*?) \\(${id}\\)`, "u"); // original format
const idNewAtBeginningOfTitleRegExp = new RegExp(`^# ${id}: `, "u"); // new format is same as rules index
/*
* 1. Added support for new format.
* 2. Will remove support for old format after all docs files have new format.
* 3. Will remove this check when the main heading is automatically generated from rule metadata.
*/

return idNewAtBeginningOfTitleRegExp.test(docText) || idOldAtEndOfTitleRegExp.test(docText);
return new RegExp(`^# ${id}`, "u").test(docText);
}

/**
Expand Down Expand Up @@ -879,7 +872,7 @@ target.checkRuleFiles = function() {
errors++;
} else {

// check for proper doc format
// check for proper doc h1 format
if (!hasIdInTitle(basename)) {
console.error("Missing id in the doc page's title of rule %s", basename);
errors++;
Expand Down
4 changes: 3 additions & 1 deletion docs/rules/accessor-pairs.md
@@ -1,4 +1,6 @@
# Enforces getter/setter pairs in objects and classes (accessor-pairs)
# accessor-pairs

Enforces getter/setter pairs in objects and classes.

It's a common mistake in JavaScript to create an object with just a setter for a property but never have a corresponding getter defined for it. Without a getter, you cannot read the property, so it ends up not being used.

Expand Down
4 changes: 3 additions & 1 deletion docs/rules/array-bracket-newline.md
@@ -1,4 +1,6 @@
# enforce line breaks after opening and before closing array brackets (array-bracket-newline)
# array-bracket-newline

Enforces line breaks after opening and before closing array brackets.

A number of style guides require or disallow line breaks inside of array brackets.

Expand Down
4 changes: 3 additions & 1 deletion docs/rules/array-bracket-spacing.md
@@ -1,4 +1,6 @@
# Disallow or enforce spaces inside of brackets (array-bracket-spacing)
# array-bracket-spacing

Disallows or enforce spaces inside of brackets.

A number of style guides require or disallow spaces between array brackets and other tokens. This rule
applies to both array literals and destructuring assignments (ECMAScript 6).
Expand Down
4 changes: 3 additions & 1 deletion docs/rules/array-callback-return.md
@@ -1,4 +1,6 @@
# Enforces return statements in callbacks of array's methods (array-callback-return)
# array-callback-return

Enforces return statements in callbacks of array's methods.

`Array` has several methods for filtering, mapping, and folding.
If we forget to write `return` statement in a callback of those, it's probably a mistake. If you don't want to use a return or don't need the returned results, consider using [.forEach](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach) instead.
Expand Down
4 changes: 3 additions & 1 deletion docs/rules/array-element-newline.md
@@ -1,4 +1,6 @@
# enforce line breaks between array elements (array-element-newline)
# array-element-newline

Enforces line breaks between array elements.

A number of style guides require or disallow line breaks between array elements.

Expand Down
4 changes: 3 additions & 1 deletion docs/rules/arrow-body-style.md
@@ -1,4 +1,6 @@
# Require braces in arrow function body (arrow-body-style)
# arrow-body-style

Requires braces in arrow function bodies.

Arrow functions have two syntactic forms for their function bodies. They may be defined with a *block* body (denoted by curly braces) `() => { ... }` or with a single expression `() => ...`, whose value is implicitly returned.

Expand Down
4 changes: 3 additions & 1 deletion docs/rules/arrow-parens.md
@@ -1,4 +1,6 @@
# Require parens in arrow function arguments (arrow-parens)
# arrow-parens

Requires parens in arrow function arguments.

Arrow functions can omit parentheses when they have exactly one parameter. In all other cases the parameter(s) must
be wrapped in parentheses. This rule enforces the consistent use of parentheses in arrow functions.
Expand Down
4 changes: 3 additions & 1 deletion docs/rules/arrow-spacing.md
@@ -1,4 +1,6 @@
# Require space before/after arrow function's arrow (arrow-spacing)
# arrow-spacing

Requires space before/after arrow function's arrow.

This rule normalize style of spacing before/after an arrow function's arrow(`=>`).

Expand Down
4 changes: 3 additions & 1 deletion docs/rules/block-scoped-var.md
@@ -1,4 +1,6 @@
# Treat var as Block Scoped (block-scoped-var)
# block-scoped-var

Enforces treating `var` as block scoped.

The `block-scoped-var` rule generates warnings when variables are used outside of the block in which they were defined. This emulates C-style block scope.

Expand Down
4 changes: 3 additions & 1 deletion docs/rules/block-spacing.md
@@ -1,4 +1,6 @@
# Disallow or enforce spaces inside of blocks after opening block and before closing block (block-spacing)
# block-spacing

Disallows or enforces spaces inside of blocks after opening blocks and before closing blocks.

## Rule Details

Expand Down
4 changes: 3 additions & 1 deletion docs/rules/brace-style.md
@@ -1,4 +1,6 @@
# Require Brace Style (brace-style)
# brace-style

Enforces consistent brace style for blocks.

Brace style is closely related to [indent style](https://en.wikipedia.org/wiki/Indent_style) in programming and describes the placement of braces relative to their control statement and body. There are probably a dozen, if not more, brace styles in the world.

Expand Down
4 changes: 3 additions & 1 deletion docs/rules/callback-return.md
@@ -1,4 +1,6 @@
# Enforce Return After Callback (callback-return)
# callback-return

Enforces return after callback.

This rule was **deprecated** in ESLint v7.0.0. Please use the corresponding rule in [`eslint-plugin-node`](https://github.com/mysticatea/eslint-plugin-node).

Expand Down
4 changes: 3 additions & 1 deletion docs/rules/camelcase.md
@@ -1,4 +1,6 @@
# Require CamelCase (camelcase)
# camelcase

Enforces camelcase naming convention.

When it comes to naming variables, style guides generally fall into one of two camps: camelcase (`variableName`) and underscores (`variable_name`). This rule focuses on using the camelcase approach. If your style guide calls for camelCasing your variable names, then this rule is for you!

Expand Down
4 changes: 3 additions & 1 deletion docs/rules/capitalized-comments.md
@@ -1,4 +1,6 @@
# enforce or disallow capitalization of the first letter of a comment (capitalized-comments)
# capitalized-comments

Enforces or disallows capitalization of the first letter of a comment.

Comments are useful for leaving information for future developers. In order for that information to be useful and not distracting, it is sometimes desirable for comments to follow a particular style. One element of comment formatting styles is whether the first word of a comment should be capitalized or lowercase.

Expand Down
4 changes: 3 additions & 1 deletion docs/rules/class-methods-use-this.md
@@ -1,4 +1,6 @@
# Enforce that class methods utilize `this` (class-methods-use-this)
# class-methods-use-this

Enforces that class methods utilize `this`.

If a class method does not use `this`, it can *sometimes* be made into a static function. If you do convert the method into a static function, instances of the class that call that particular method have to be converted to a static call as well (`MyClass.callStaticMethod()`)

Expand Down
4 changes: 3 additions & 1 deletion docs/rules/comma-dangle.md
@@ -1,4 +1,6 @@
# require or disallow trailing commas (comma-dangle)
# comma-dangle

Requires or disallows trailing commas.

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.

Expand Down
4 changes: 3 additions & 1 deletion docs/rules/comma-spacing.md
@@ -1,4 +1,6 @@
# Enforces spacing around commas (comma-spacing)
# comma-spacing

Enforces spacing around commas.

Spacing around commas improves readability of a list of items. Although most of the style guidelines for languages prescribe adding a space after a comma and not before it, it is subjective to the preferences of a project.

Expand Down
4 changes: 3 additions & 1 deletion docs/rules/comma-style.md
@@ -1,4 +1,6 @@
# Comma style (comma-style)
# comma-style

Enforces consistent comma styles.

The Comma Style rule enforces styles for comma-separated lists. There are two comma styles primarily used in JavaScript:

Expand Down
4 changes: 3 additions & 1 deletion docs/rules/complexity.md
@@ -1,4 +1,6 @@
# Limit Cyclomatic Complexity (complexity)
# complexity

Enforces a maximum cyclomatic complexity.

Cyclomatic complexity measures the number of linearly independent paths through a program's source code. This rule allows setting a cyclomatic complexity threshold.

Expand Down
4 changes: 3 additions & 1 deletion docs/rules/computed-property-spacing.md
@@ -1,4 +1,6 @@
# Disallow or enforce spaces inside of computed properties (computed-property-spacing)
# computed-property-spacing

Disallows or enforces spaces inside of computed properties.

While formatting preferences are very personal, a number of style guides require
or disallow spaces between computed properties in the following situations:
Expand Down
4 changes: 3 additions & 1 deletion docs/rules/consistent-return.md
@@ -1,4 +1,6 @@
# require `return` statements to either always or never specify values (consistent-return)
# consistent-return

Requires `return` statements to either always or never specify values.

Unlike statically-typed languages which enforce that a function returns a specified type of value, JavaScript allows different code paths in a function to return different types of values.

Expand Down
4 changes: 3 additions & 1 deletion docs/rules/consistent-this.md
@@ -1,4 +1,6 @@
# Require Consistent This (consistent-this)
# consistent-this

Enforces consistent naming when capturing the current execution context.

It is often necessary to capture the current execution context in order to make it available subsequently. A prominent example of this are jQuery callbacks:

Expand Down
4 changes: 3 additions & 1 deletion docs/rules/constructor-super.md
@@ -1,4 +1,6 @@
# Verify calls of `super()` in constructors (constructor-super)
# constructor-super

Verifies calls of `super()` in constructors.

Constructors of derived classes must call `super()`.
Constructors of non derived classes must not call `super()`.
Expand Down
4 changes: 3 additions & 1 deletion docs/rules/curly.md
@@ -1,4 +1,6 @@
# Require Following Curly Brace Conventions (curly)
# curly

Requires following curly brace conventions.

JavaScript allows the omission of curly braces when a block contains only one statement. However, it is considered by many to be best practice to _never_ omit curly braces around blocks, even when they are optional, because it can lead to bugs and reduces code clarity. So the following:

Expand Down
4 changes: 3 additions & 1 deletion docs/rules/default-case-last.md
@@ -1,4 +1,6 @@
# Enforce default clauses in switch statements to be last (default-case-last)
# default-case-last

Enforces default clauses in switch statements to be last.

A `switch` statement can optionally have a `default` clause.

Expand Down
6 changes: 4 additions & 2 deletions docs/rules/default-case.md
@@ -1,4 +1,6 @@
# Require Default Case in Switch Statements (default-case)
# default-case

Requires a `default` case in switch statements.

Some code conventions require that all `switch` statements have a `default` case, even if the default case is empty, such as:

Expand All @@ -13,7 +15,7 @@ switch (foo) {
break;

default:
// do nothing
// do nothing
}
```

Expand Down
4 changes: 3 additions & 1 deletion docs/rules/default-param-last.md
@@ -1,4 +1,6 @@
# enforce default parameters to be last (default-param-last)
# default-param-last

Enforces default parameters to be last.

Putting default parameter at last allows function calls to omit optional tail arguments.

Expand Down
4 changes: 3 additions & 1 deletion docs/rules/dot-location.md
@@ -1,4 +1,6 @@
# Enforce newline before and after dot (dot-location)
# dot-location

Enforces newline before and after dots.

JavaScript allows you to place newlines before or after a dot in a member expression.

Expand Down
4 changes: 3 additions & 1 deletion docs/rules/dot-notation.md
@@ -1,4 +1,6 @@
# Require Dot Notation (dot-notation)
# dot-notation

Enforces dot notation whenever possible.

In JavaScript, one can access properties using the dot notation (`foo.bar`) or square-bracket notation (`foo["bar"]`). However, the dot notation is often preferred because it is easier to read, less verbose, and works better with aggressive JavaScript minimizers.

Expand Down
4 changes: 3 additions & 1 deletion docs/rules/eol-last.md
@@ -1,4 +1,6 @@
# require or disallow newline at the end of files (eol-last)
# eol-last

Requires or disallows newline at the end of files.

Trailing newlines in non-empty files are a common UNIX idiom. Benefits of
trailing newlines include the ability to concatenate or append to files as well
Expand Down
4 changes: 3 additions & 1 deletion docs/rules/eqeqeq.md
@@ -1,4 +1,6 @@
# Require === and !== (eqeqeq)
# eqeqeq

Requires the use of `===` and `!==`.

It is considered good practice to use the type-safe equality operators `===` and `!==` instead of their regular counterparts `==` and `!=`.

Expand Down
4 changes: 3 additions & 1 deletion docs/rules/for-direction.md
@@ -1,4 +1,6 @@
# Enforce "for" loop update clause moving the counter in the right direction. (for-direction)
# for-direction

Enforces `for` loop update clause moving the counter in the right direction.

## Rule Details

Expand Down
4 changes: 3 additions & 1 deletion docs/rules/func-call-spacing.md
@@ -1,4 +1,6 @@
# require or disallow spacing between function identifiers and their invocations (func-call-spacing)
# func-call-spacing

Requires or disallows spacing between function identifiers and their invocations.

When calling a function, developers may insert optional whitespace between the function's name and the parentheses that invoke it. The following pairs of function calls are equivalent:

Expand Down
4 changes: 3 additions & 1 deletion docs/rules/func-name-matching.md
@@ -1,4 +1,6 @@
# require function names to match the name of the variable or property to which they are assigned (func-name-matching)
# func-name-matching

Requires function names to match the name of the variable or property to which they are assigned.

## Rule Details

Expand Down
4 changes: 3 additions & 1 deletion docs/rules/func-names.md
@@ -1,4 +1,6 @@
# Require or disallow named `function` expressions (func-names)
# func-names

Requires or disallows named `function` expressions.

A pattern that's becoming more common is to give function expressions names to aid in debugging. For example:

Expand Down
4 changes: 3 additions & 1 deletion docs/rules/func-style.md
@@ -1,4 +1,6 @@
# enforce the consistent use of either `function` declarations or expressions (func-style)
# func-style

Enforces the consistent use of either `function` declarations or expressions.

There are two ways of defining functions in JavaScript: `function` declarations and `function` expressions. Declarations contain the `function` keyword first, followed by a name and then its arguments and the function body, for example:

Expand Down
4 changes: 3 additions & 1 deletion docs/rules/function-call-argument-newline.md
@@ -1,4 +1,6 @@
# enforce line breaks between arguments of a function call (function-call-argument-newline)
# function-call-argument-newline

Enforces line breaks between arguments of a function call.

A number of style guides require or disallow line breaks between arguments of a function call.

Expand Down
4 changes: 3 additions & 1 deletion docs/rules/function-paren-newline.md
@@ -1,4 +1,6 @@
# enforce consistent line breaks inside function parentheses (function-paren-newline)
# function-paren-newline

Enforces consistent line breaks inside function parentheses.

Many style guides require or disallow newlines inside of function parentheses.

Expand Down
4 changes: 3 additions & 1 deletion docs/rules/generator-star-spacing.md
@@ -1,4 +1,6 @@
# Enforce spacing around the * in generator functions (generator-star-spacing)
# generator-star-spacing

Enforces spacing around the `*` in generator functions.

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.
Expand Down
4 changes: 3 additions & 1 deletion docs/rules/generator-star.md
@@ -1,4 +1,6 @@
# generator-star: enforce consistent spacing around the asterisk in generator functions
# generator-star

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.

Expand Down
4 changes: 3 additions & 1 deletion docs/rules/getter-return.md
@@ -1,4 +1,6 @@
# Enforces that a return statement is present in property getters (getter-return)
# getter-return

Enforces that a `return` statement is present in property getters.

The get syntax binds an object property to a function that will be called when that property is looked up. It was first introduced in ECMAScript 5:

Expand Down

0 comments on commit ccbc35f

Please sign in to comment.