Skip to content

Commit

Permalink
Docs: add url to each of the rules (refs #6582) (#9788)
Browse files Browse the repository at this point in the history
* Docs: add url to each of the rules (refs #6582)

Code mod:

export default function transformer(file, api) {
    const j = api.jscodeshift;

    const name = file.path.split('/').pop().replace(/.js$/, '');

    return j(file.source)
      .find(j.ObjectExpression)
      .filter(path => path.parentPath.node.key && path.parentPath.node.key.name === 'docs')
      .forEach(path => {
        const prop = j.property('init', j.identifier('url'), j.literal(`https://eslint.org/docs/rules/${name}`));
        j(path).replaceWith(j.objectExpression([...path.node.properties, prop]));
      })
      .toSource({lineTerminator: '\n'});
  }

* New: internal-rules/consistent-docs-url (refs #6582)

Add a lint rule to ensure that each rule has a meta.docs.url property with the correct value.
  • Loading branch information
Patrick McElhaney authored and ilyavolodin committed Jan 5, 2018
1 parent fc44da9 commit fc7f404
Show file tree
Hide file tree
Showing 263 changed files with 706 additions and 259 deletions.
1 change: 1 addition & 0 deletions lib/rules/.eslintrc.yml
@@ -1,3 +1,4 @@
rules:
rulesdir/no-invalid-meta: "error"
rulesdir/consistent-docs-description: "error"
rulesdir/consistent-docs-url: "error"
3 changes: 2 additions & 1 deletion lib/rules/accessor-pairs.js
Expand Up @@ -75,7 +75,8 @@ module.exports = {
docs: {
description: "enforce getter and setter pairs in objects",
category: "Best Practices",
recommended: false
recommended: false,
url: "https://eslint.org/docs/rules/accessor-pairs"
},
schema: [{
type: "object",
Expand Down
3 changes: 2 additions & 1 deletion lib/rules/array-bracket-newline.js
Expand Up @@ -16,7 +16,8 @@ module.exports = {
docs: {
description: "enforce linebreaks after opening and before closing array brackets",
category: "Stylistic Issues",
recommended: false
recommended: false,
url: "https://eslint.org/docs/rules/array-bracket-newline"
},
fixable: "whitespace",
schema: [
Expand Down
3 changes: 2 additions & 1 deletion lib/rules/array-bracket-spacing.js
Expand Up @@ -15,7 +15,8 @@ module.exports = {
docs: {
description: "enforce consistent spacing inside array brackets",
category: "Stylistic Issues",
recommended: false
recommended: false,
url: "https://eslint.org/docs/rules/array-bracket-spacing"
},
fixable: "whitespace",
schema: [
Expand Down
3 changes: 2 additions & 1 deletion lib/rules/array-callback-return.js
Expand Up @@ -142,7 +142,8 @@ module.exports = {
docs: {
description: "enforce `return` statements in callbacks of array methods",
category: "Best Practices",
recommended: false
recommended: false,
url: "https://eslint.org/docs/rules/array-callback-return"
},

schema: [
Expand Down
3 changes: 2 additions & 1 deletion lib/rules/array-element-newline.js
Expand Up @@ -16,7 +16,8 @@ module.exports = {
docs: {
description: "enforce line breaks after each array element",
category: "Stylistic Issues",
recommended: false
recommended: false,
url: "https://eslint.org/docs/rules/array-element-newline"
},
fixable: "whitespace",
schema: [
Expand Down
3 changes: 2 additions & 1 deletion lib/rules/arrow-body-style.js
Expand Up @@ -19,7 +19,8 @@ module.exports = {
docs: {
description: "require braces around arrow function bodies",
category: "ECMAScript 6",
recommended: false
recommended: false,
url: "https://eslint.org/docs/rules/arrow-body-style"
},

schema: {
Expand Down
3 changes: 2 additions & 1 deletion lib/rules/arrow-parens.js
Expand Up @@ -19,7 +19,8 @@ module.exports = {
docs: {
description: "require parentheses around arrow function arguments",
category: "ECMAScript 6",
recommended: false
recommended: false,
url: "https://eslint.org/docs/rules/arrow-parens"
},

fixable: "code",
Expand Down
3 changes: 2 additions & 1 deletion lib/rules/arrow-spacing.js
Expand Up @@ -19,7 +19,8 @@ module.exports = {
docs: {
description: "enforce consistent spacing before and after the arrow in arrow functions",
category: "ECMAScript 6",
recommended: false
recommended: false,
url: "https://eslint.org/docs/rules/arrow-spacing"
},

fixable: "whitespace",
Expand Down
3 changes: 2 additions & 1 deletion lib/rules/block-scoped-var.js
Expand Up @@ -13,7 +13,8 @@ module.exports = {
docs: {
description: "enforce the use of variables within the scope they are defined",
category: "Best Practices",
recommended: false
recommended: false,
url: "https://eslint.org/docs/rules/block-scoped-var"
},

schema: []
Expand Down
3 changes: 2 additions & 1 deletion lib/rules/block-spacing.js
Expand Up @@ -16,7 +16,8 @@ module.exports = {
docs: {
description: "disallow or enforce spaces inside of blocks after opening block and before closing block",
category: "Stylistic Issues",
recommended: false
recommended: false,
url: "https://eslint.org/docs/rules/block-spacing"
},

fixable: "whitespace",
Expand Down
3 changes: 2 additions & 1 deletion lib/rules/brace-style.js
Expand Up @@ -16,7 +16,8 @@ module.exports = {
docs: {
description: "enforce consistent brace style for blocks",
category: "Stylistic Issues",
recommended: false
recommended: false,
url: "https://eslint.org/docs/rules/brace-style"
},

schema: [
Expand Down
3 changes: 2 additions & 1 deletion lib/rules/callback-return.js
Expand Up @@ -13,7 +13,8 @@ module.exports = {
docs: {
description: "require `return` statements after callbacks",
category: "Node.js and CommonJS",
recommended: false
recommended: false,
url: "https://eslint.org/docs/rules/callback-return"
},

schema: [{
Expand Down
3 changes: 2 additions & 1 deletion lib/rules/camelcase.js
Expand Up @@ -14,7 +14,8 @@ module.exports = {
docs: {
description: "enforce camelcase naming convention",
category: "Stylistic Issues",
recommended: false
recommended: false,
url: "https://eslint.org/docs/rules/camelcase"
},

schema: [
Expand Down
3 changes: 2 additions & 1 deletion lib/rules/capitalized-comments.js
Expand Up @@ -113,7 +113,8 @@ module.exports = {
docs: {
description: "enforce or disallow capitalization of the first letter of a comment",
category: "Stylistic Issues",
recommended: false
recommended: false,
url: "https://eslint.org/docs/rules/capitalized-comments"
},
fixable: "code",
schema: [
Expand Down
3 changes: 2 additions & 1 deletion lib/rules/class-methods-use-this.js
Expand Up @@ -14,7 +14,8 @@ module.exports = {
docs: {
description: "enforce that class methods utilize `this`",
category: "Best Practices",
recommended: false
recommended: false,
url: "https://eslint.org/docs/rules/class-methods-use-this"
},
schema: [{
type: "object",
Expand Down
3 changes: 2 additions & 1 deletion lib/rules/comma-dangle.js
Expand Up @@ -79,7 +79,8 @@ module.exports = {
docs: {
description: "require or disallow trailing commas",
category: "Stylistic Issues",
recommended: false
recommended: false,
url: "https://eslint.org/docs/rules/comma-dangle"
},
fixable: "code",
schema: {
Expand Down
3 changes: 2 additions & 1 deletion lib/rules/comma-spacing.js
Expand Up @@ -15,7 +15,8 @@ module.exports = {
docs: {
description: "enforce consistent spacing before and after commas",
category: "Stylistic Issues",
recommended: false
recommended: false,
url: "https://eslint.org/docs/rules/comma-spacing"
},

fixable: "whitespace",
Expand Down
3 changes: 2 additions & 1 deletion lib/rules/comma-style.js
Expand Up @@ -16,7 +16,8 @@ module.exports = {
docs: {
description: "enforce consistent comma style",
category: "Stylistic Issues",
recommended: false
recommended: false,
url: "https://eslint.org/docs/rules/comma-style"
},
fixable: "code",
schema: [
Expand Down
3 changes: 2 additions & 1 deletion lib/rules/complexity.js
Expand Up @@ -23,7 +23,8 @@ module.exports = {
docs: {
description: "enforce a maximum cyclomatic complexity allowed in a program",
category: "Best Practices",
recommended: false
recommended: false,
url: "https://eslint.org/docs/rules/complexity"
},

schema: [
Expand Down
3 changes: 2 additions & 1 deletion lib/rules/computed-property-spacing.js
Expand Up @@ -15,7 +15,8 @@ module.exports = {
docs: {
description: "enforce consistent spacing inside computed property brackets",
category: "Stylistic Issues",
recommended: false
recommended: false,
url: "https://eslint.org/docs/rules/computed-property-spacing"
},

fixable: "whitespace",
Expand Down
3 changes: 2 additions & 1 deletion lib/rules/consistent-return.js
Expand Up @@ -56,7 +56,8 @@ module.exports = {
docs: {
description: "require `return` statements to either always or never specify values",
category: "Best Practices",
recommended: false
recommended: false,
url: "https://eslint.org/docs/rules/consistent-return"
},

schema: [{
Expand Down
3 changes: 2 additions & 1 deletion lib/rules/consistent-this.js
Expand Up @@ -13,7 +13,8 @@ module.exports = {
docs: {
description: "enforce consistent naming when capturing the current execution context",
category: "Stylistic Issues",
recommended: false
recommended: false,
url: "https://eslint.org/docs/rules/consistent-this"
},

schema: {
Expand Down
3 changes: 2 additions & 1 deletion lib/rules/constructor-super.js
Expand Up @@ -95,7 +95,8 @@ module.exports = {
docs: {
description: "require `super()` calls in constructors",
category: "ECMAScript 6",
recommended: true
recommended: true,
url: "https://eslint.org/docs/rules/constructor-super"
},

schema: []
Expand Down
3 changes: 2 additions & 1 deletion lib/rules/curly.js
Expand Up @@ -19,7 +19,8 @@ module.exports = {
docs: {
description: "enforce consistent brace style for all control statements",
category: "Best Practices",
recommended: false
recommended: false,
url: "https://eslint.org/docs/rules/curly"
},

schema: {
Expand Down
3 changes: 2 additions & 1 deletion lib/rules/default-case.js
Expand Up @@ -15,7 +15,8 @@ module.exports = {
docs: {
description: "require `default` cases in `switch` statements",
category: "Best Practices",
recommended: false
recommended: false,
url: "https://eslint.org/docs/rules/default-case"
},

schema: [{
Expand Down
3 changes: 2 additions & 1 deletion lib/rules/dot-location.js
Expand Up @@ -16,7 +16,8 @@ module.exports = {
docs: {
description: "enforce consistent newlines before and after dots",
category: "Best Practices",
recommended: false
recommended: false,
url: "https://eslint.org/docs/rules/dot-location"
},

schema: [
Expand Down
3 changes: 2 additions & 1 deletion lib/rules/dot-notation.js
Expand Up @@ -22,7 +22,8 @@ module.exports = {
docs: {
description: "enforce dot notation whenever possible",
category: "Best Practices",
recommended: false
recommended: false,
url: "https://eslint.org/docs/rules/dot-notation"
},

schema: [
Expand Down
3 changes: 2 additions & 1 deletion lib/rules/eol-last.js
Expand Up @@ -19,7 +19,8 @@ module.exports = {
docs: {
description: "require or disallow newline at the end of files",
category: "Stylistic Issues",
recommended: false
recommended: false,
url: "https://eslint.org/docs/rules/eol-last"
},
fixable: "whitespace",
schema: [
Expand Down
3 changes: 2 additions & 1 deletion lib/rules/eqeqeq.js
Expand Up @@ -20,7 +20,8 @@ module.exports = {
docs: {
description: "require the use of `===` and `!==`",
category: "Best Practices",
recommended: false
recommended: false,
url: "https://eslint.org/docs/rules/eqeqeq"
},

schema: {
Expand Down
3 changes: 2 additions & 1 deletion lib/rules/for-direction.js
Expand Up @@ -14,7 +14,8 @@ module.exports = {
docs: {
description: "enforce \"for\" loop update clause moving the counter in the right direction.",
category: "Possible Errors",
recommended: false
recommended: false,
url: "https://eslint.org/docs/rules/for-direction"
},
fixable: null,
schema: []
Expand Down
3 changes: 2 additions & 1 deletion lib/rules/func-call-spacing.js
Expand Up @@ -20,7 +20,8 @@ module.exports = {
docs: {
description: "require or disallow spacing between function identifiers and their invocations",
category: "Stylistic Issues",
recommended: false
recommended: false,
url: "https://eslint.org/docs/rules/func-call-spacing"
},

fixable: "whitespace",
Expand Down
3 changes: 2 additions & 1 deletion lib/rules/func-name-matching.js
Expand Up @@ -70,7 +70,8 @@ module.exports = {
docs: {
description: "require function names to match the name of the variable or property to which they are assigned",
category: "Stylistic Issues",
recommended: false
recommended: false,
url: "https://eslint.org/docs/rules/func-name-matching"
},

schema: {
Expand Down
3 changes: 2 additions & 1 deletion lib/rules/func-names.js
Expand Up @@ -29,7 +29,8 @@ module.exports = {
docs: {
description: "require or disallow named `function` expressions",
category: "Stylistic Issues",
recommended: false
recommended: false,
url: "https://eslint.org/docs/rules/func-names"
},

schema: [
Expand Down
3 changes: 2 additions & 1 deletion lib/rules/func-style.js
Expand Up @@ -13,7 +13,8 @@ module.exports = {
docs: {
description: "enforce the consistent use of either `function` declarations or expressions",
category: "Stylistic Issues",
recommended: false
recommended: false,
url: "https://eslint.org/docs/rules/func-style"
},

schema: [
Expand Down
3 changes: 2 additions & 1 deletion lib/rules/function-paren-newline.js
Expand Up @@ -19,7 +19,8 @@ module.exports = {
docs: {
description: "enforce consistent line breaks inside function parentheses",
category: "Stylistic Issues",
recommended: false
recommended: false,
url: "https://eslint.org/docs/rules/function-paren-newline"
},
fixable: "whitespace",
schema: [
Expand Down
3 changes: 2 additions & 1 deletion lib/rules/generator-star-spacing.js
Expand Up @@ -30,7 +30,8 @@ module.exports = {
docs: {
description: "enforce consistent spacing around `*` operators in generator functions",
category: "ECMAScript 6",
recommended: false
recommended: false,
url: "https://eslint.org/docs/rules/generator-star-spacing"
},

fixable: "whitespace",
Expand Down
3 changes: 2 additions & 1 deletion lib/rules/getter-return.js
Expand Up @@ -47,7 +47,8 @@ module.exports = {
docs: {
description: "enforce `return` statements in getters",
category: "Possible Errors",
recommended: false
recommended: false,
url: "https://eslint.org/docs/rules/getter-return"
},
fixable: null,
schema: [
Expand Down
3 changes: 2 additions & 1 deletion lib/rules/global-require.js
Expand Up @@ -51,7 +51,8 @@ module.exports = {
docs: {
description: "require `require()` calls to be placed at top-level module scope",
category: "Node.js and CommonJS",
recommended: false
recommended: false,
url: "https://eslint.org/docs/rules/global-require"
},

schema: []
Expand Down
3 changes: 2 additions & 1 deletion lib/rules/guard-for-in.js
Expand Up @@ -14,7 +14,8 @@ module.exports = {
docs: {
description: "require `for-in` loops to include an `if` statement",
category: "Best Practices",
recommended: false
recommended: false,
url: "https://eslint.org/docs/rules/guard-for-in"
},

schema: []
Expand Down

0 comments on commit fc7f404

Please sign in to comment.