Skip to content
Permalink
Browse files

chore: Add documentation validation tool (#531)

  • Loading branch information...
bradzacher committed May 16, 2019
1 parent c480eab commit 4edf0d71ef0a8a3370165e804dd693033d6207bc
Showing with 405 additions and 181 deletions.
  1. +1 −0 .prettierignore
  2. +4 −0 azure-pipelines.yml
  3. +1 −0 package.json
  4. +45 −45 packages/eslint-plugin/README.md
  5. +6 −4 packages/eslint-plugin/package.json
  6. +5 −0 packages/eslint-plugin/src/configs/all.json
  7. +1 −0 packages/eslint-plugin/src/configs/recommended.json
  8. +0 −1 packages/eslint-plugin/src/rules/adjacent-overload-signatures.ts
  9. +0 −1 packages/eslint-plugin/src/rules/array-type.ts
  10. +0 −1 packages/eslint-plugin/src/rules/await-thenable.ts
  11. +1 −2 packages/eslint-plugin/src/rules/ban-ts-ignore.ts
  12. +0 −1 packages/eslint-plugin/src/rules/ban-types.ts
  13. +0 −1 packages/eslint-plugin/src/rules/class-name-casing.ts
  14. +0 −1 packages/eslint-plugin/src/rules/explicit-member-accessibility.ts
  15. +1 −1 packages/eslint-plugin/src/rules/func-call-spacing.ts
  16. +0 −1 packages/eslint-plugin/src/rules/indent.ts
  17. +0 −1 packages/eslint-plugin/src/rules/interface-name-prefix.ts
  18. +1 −1 packages/eslint-plugin/src/rules/member-naming.ts
  19. +0 −1 packages/eslint-plugin/src/rules/member-ordering.ts
  20. +0 −1 packages/eslint-plugin/src/rules/no-angle-bracket-type-assertion.ts
  21. +0 −1 packages/eslint-plugin/src/rules/no-empty-interface.ts
  22. +0 −1 packages/eslint-plugin/src/rules/no-explicit-any.ts
  23. +1 −1 packages/eslint-plugin/src/rules/no-extra-parens.ts
  24. +0 −1 packages/eslint-plugin/src/rules/no-extraneous-class.ts
  25. +0 −1 packages/eslint-plugin/src/rules/no-for-in-array.ts
  26. +1 −2 packages/eslint-plugin/src/rules/no-inferrable-types.ts
  27. +1 −6 packages/eslint-plugin/src/rules/no-magic-numbers.ts
  28. +1 −2 packages/eslint-plugin/src/rules/no-misused-new.ts
  29. +0 −1 packages/eslint-plugin/src/rules/no-namespace.ts
  30. +0 −1 packages/eslint-plugin/src/rules/no-non-null-assertion.ts
  31. +0 −1 packages/eslint-plugin/src/rules/no-object-literal-type-assertion.ts
  32. +1 −2 packages/eslint-plugin/src/rules/no-parameter-properties.ts
  33. +1 −2 packages/eslint-plugin/src/rules/no-require-imports.ts
  34. +0 −1 packages/eslint-plugin/src/rules/no-this-alias.ts
  35. +0 −1 packages/eslint-plugin/src/rules/no-triple-slash-reference.ts
  36. +0 −1 packages/eslint-plugin/src/rules/no-type-alias.ts
  37. +1 −2 packages/eslint-plugin/src/rules/no-unnecessary-qualifier.ts
  38. +0 −1 packages/eslint-plugin/src/rules/no-unnecessary-type-assertion.ts
  39. +0 −1 packages/eslint-plugin/src/rules/no-unused-vars.ts
  40. +0 −1 packages/eslint-plugin/src/rules/no-var-requires.ts
  41. +1 −2 packages/eslint-plugin/src/rules/prefer-for-of.ts
  42. +0 −1 packages/eslint-plugin/src/rules/prefer-function-type.ts
  43. +0 −1 packages/eslint-plugin/src/rules/prefer-interface.ts
  44. +1 −2 packages/eslint-plugin/src/rules/prefer-namespace-keyword.ts
  45. +1 −1 packages/eslint-plugin/src/rules/prefer-regexp-exec.ts
  46. +1 −1 packages/eslint-plugin/src/rules/prefer-string-starts-ends-with.ts
  47. +1 −2 packages/eslint-plugin/src/rules/promise-function-async.ts
  48. +1 −2 packages/eslint-plugin/src/rules/restrict-plus-operands.ts
  49. +0 −1 packages/eslint-plugin/src/rules/type-annotation-spacing.ts
  50. +1 −2 packages/eslint-plugin/src/rules/unbound-method.ts
  51. +1 −2 packages/eslint-plugin/src/rules/unified-signatures.ts
  52. +29 −5 packages/eslint-plugin/tools/generate-configs.ts
  53. +27 −0 packages/eslint-plugin/tools/validate-docs/check-for-rule-docs.ts
  54. +34 −0 packages/eslint-plugin/tools/validate-docs/index.ts
  55. +20 −0 packages/eslint-plugin/tools/validate-docs/log.ts
  56. +29 −0 packages/eslint-plugin/tools/validate-docs/parse-readme.ts
  57. +123 −0 packages/eslint-plugin/tools/validate-docs/validate-table-rules.ts
  58. +48 −0 packages/eslint-plugin/tools/validate-docs/validate-table-structure.ts
  59. +1 −6 packages/experimental-utils/src/eslint-utils/RuleCreator.ts
  60. +13 −60 yarn.lock
@@ -7,3 +7,4 @@
**/.nyc_output
packages/eslint-plugin-tslint/tests/test-tslint-rules-directory/alwaysFailRule.js
.github
packages/eslint-plugin/src/configs/*.json
@@ -31,6 +31,10 @@ jobs:
yarn lint
displayName: 'Run linting'
- script: |
yarn docs:check
displayName: 'Validate documentation'
- script: |
yarn test
displayName: 'Run unit tests'
@@ -20,6 +20,7 @@
"build": "lerna run build",
"clean": "lerna clean && lerna run clean",
"cz": "git-cz",
"docs:check": "lerna run docs:check",
"generate-contributors": "yarn ts-node ./tools/generate-contributors.ts && yarn all-contributors generate",
"format": "prettier --write \"./**/*.{ts,js,json,md}\"",
"format-check": "prettier --list-different \"./**/*.{ts,js,json,md}\"",

Large diffs are not rendered by default.

@@ -28,12 +28,12 @@
"build": "tsc -p tsconfig.build.json",
"clean": "rimraf dist/",
"docs": "eslint-docs",
"docs:check": "eslint-docs check",
"test": "jest --coverage",
"generate:configs": "ts-node --files tools/generate-configs.ts",
"docs:check": "ts-node --files ./tools/validate-docs/index.ts",
"format": "prettier --write \"./**/*.{ts,js,json,md}\" --ignore-path ../../.prettierignore",
"generate:configs": "ts-node --files tools/generate-configs.ts",
"prebuild": "npm run clean",
"recommended:update": "ts-node tools/update-recommended.ts",
"test": "jest --coverage",
"typecheck": "tsc --noEmit"
},
"dependencies": {
@@ -44,7 +44,9 @@
"tsutils": "^3.7.0"
},
"devDependencies": {
"eslint-docs": "^0.2.6"
"@types/marked": "^0.6.5",
"chalk": "^2.4.2",
"marked": "^0.6.2"
},
"peerDependencies": {
"@typescript-eslint/parser": "1.9.0",
@@ -11,6 +11,7 @@
"@typescript-eslint/class-name-casing": "error",
"@typescript-eslint/explicit-function-return-type": "error",
"@typescript-eslint/explicit-member-accessibility": "error",
"func-call-spacing": "off",
"@typescript-eslint/func-call-spacing": "error",
"@typescript-eslint/generic-type-naming": "error",
"indent": "off",
@@ -24,10 +25,12 @@
"@typescript-eslint/no-array-constructor": "error",
"@typescript-eslint/no-empty-interface": "error",
"@typescript-eslint/no-explicit-any": "error",
"no-extra-parens": "off",
"@typescript-eslint/no-extra-parens": "error",
"@typescript-eslint/no-extraneous-class": "error",
"@typescript-eslint/no-for-in-array": "error",
"@typescript-eslint/no-inferrable-types": "error",
"no-magic-numbers": "off",
"@typescript-eslint/no-magic-numbers": "error",
"@typescript-eslint/no-misused-new": "error",
"@typescript-eslint/no-namespace": "error",
@@ -42,6 +45,7 @@
"@typescript-eslint/no-unnecessary-type-assertion": "error",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "error",
"no-use-before-define": "off",
"@typescript-eslint/no-use-before-define": "error",
"no-useless-constructor": "off",
"@typescript-eslint/no-useless-constructor": "error",
@@ -56,6 +60,7 @@
"@typescript-eslint/promise-function-async": "error",
"@typescript-eslint/require-array-sort-compare": "error",
"@typescript-eslint/restrict-plus-operands": "error",
"semi": "off",
"@typescript-eslint/semi": "error",
"@typescript-eslint/type-annotation-spacing": "error",
"@typescript-eslint/unbound-method": "error",
@@ -27,6 +27,7 @@
"@typescript-eslint/no-triple-slash-reference": "error",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "warn",
"no-use-before-define": "off",
"@typescript-eslint/no-use-before-define": "error",
"@typescript-eslint/no-var-requires": "error",
"@typescript-eslint/prefer-interface": "error",
@@ -19,7 +19,6 @@ export default util.createRule({
docs: {
description: 'Require that member overloads be consecutive',
category: 'Best Practices',
tslintName: 'adjacent-overload-signatures',
recommended: 'error',
},
schema: [],
@@ -85,7 +85,6 @@ export default util.createRule<Options, MessageIds>({
type: 'suggestion',
docs: {
description: 'Requires using either `T[]` or `Array<T>` for arrays',
tslintRuleName: 'array-type',
category: 'Stylistic Issues',
recommended: 'error',
},
@@ -10,7 +10,6 @@ export default util.createRule({
description: 'Disallows awaiting a value that is not a Thenable',
category: 'Best Practices',
recommended: false,
tslintName: 'await-thenable',
},
messages: {
await: 'Unexpected `await` of a non-Promise (non-"Thenable") value.',
@@ -5,8 +5,7 @@ export default util.createRule({
meta: {
type: 'problem',
docs: {
description: 'Bans “// @ts-ignore” comments from being used.',
tslintRuleName: 'ban-ts-ignore',
description: 'Bans “// @ts-ignore” comments from being used',
category: 'Best Practices',
recommended: false,
},
@@ -26,7 +26,6 @@ export default util.createRule<Options, MessageIds>({
type: 'suggestion',
docs: {
description: 'Enforces that types will not to be used',
tslintRuleName: 'ban-types',
category: 'Best Practices',
recommended: 'error',
},
@@ -10,7 +10,6 @@ export default util.createRule({
type: 'suggestion',
docs: {
description: 'Require PascalCased class and interface names',
tslintRuleName: 'class-name',
category: 'Best Practices',
recommended: 'error',
},
@@ -33,7 +33,6 @@ export default util.createRule<Options, MessageIds>({
docs: {
description:
'Require explicit accessibility modifiers on class properties and methods',
tslintRuleName: 'member-access',
category: 'Best Practices',
recommended: 'error',
},
@@ -16,7 +16,7 @@ export default util.createRule<Options, MessageIds>({
type: 'layout',
docs: {
description:
'require or disallow spacing between function identifiers and their invocations',
'Require or disallow spacing between function identifiers and their invocations',
category: 'Stylistic Issues',
recommended: false,
},
@@ -88,7 +88,6 @@ export default util.createRule<Options, MessageIds>({
type: 'layout',
docs: {
description: 'Enforce consistent indentation',
tslintRuleName: 'indent',
category: 'Stylistic Issues',
recommended: 'error',
},
@@ -9,7 +9,6 @@ export default util.createRule<Options, MessageIds>({
type: 'suggestion',
docs: {
description: 'Require that interface names be prefixed with `I`',
tslintRuleName: 'interface-name',
category: 'Stylistic Issues',
recommended: 'error',
},
@@ -16,7 +16,7 @@ export default util.createRule<Options, MessageIds>({
type: 'suggestion',
docs: {
description:
'Enforces naming conventions for class members by visibility.',
'Enforces naming conventions for class members by visibility',
category: 'Stylistic Issues',
recommended: false,
},
@@ -46,7 +46,6 @@ export default util.createRule<Options, MessageIds>({
type: 'suggestion',
docs: {
description: 'Require a consistent member declaration order',
tslintRuleName: 'member-ordering',
category: 'Stylistic Issues',
recommended: false,
},
@@ -7,7 +7,6 @@ export default util.createRule({
docs: {
description:
'Enforces the use of `as Type` assertions instead of `<Type>` assertions',
tslintRuleName: 'no-angle-bracket-type-assertion',
category: 'Stylistic Issues',
recommended: 'error',
},
@@ -13,7 +13,6 @@ export default util.createRule<Options, MessageIds>({
type: 'suggestion',
docs: {
description: 'Disallow the declaration of empty interfaces',
tslintRuleName: 'no-empty-interface',
category: 'Best Practices',
recommended: 'error',
},
@@ -6,7 +6,6 @@ export default util.createRule({
type: 'suggestion',
docs: {
description: 'Disallow usage of the `any` type',
tslintRuleName: 'no-any',
category: 'Best Practices',
recommended: 'warn',
},
@@ -14,7 +14,7 @@ export default util.createRule<Options, MessageIds>({
meta: {
type: 'layout',
docs: {
description: 'disallow unnecessary parentheses',
description: 'Disallow unnecessary parentheses',
category: 'Possible Errors',
recommended: false,
},
@@ -19,7 +19,6 @@ export default util.createRule<Options, MessageIds>({
type: 'suggestion',
docs: {
description: 'Forbids the use of classes as namespaces',
tslintRuleName: 'no-unnecessary-class',
category: 'Best Practices',
recommended: false,
},
@@ -8,7 +8,6 @@ export default util.createRule({
description: 'Disallow iterating over an array with a for-in loop',
category: 'Best Practices',
recommended: false,
tslintName: 'no-for-in-array',
},
messages: {
forInViolation:
@@ -18,8 +18,7 @@ export default util.createRule<Options, MessageIds>({
type: 'suggestion',
docs: {
description:
'Disallows explicit type declarations for variables or parameters initialized to a number, string, or boolean.',
tslintRuleName: 'no-inferrable-types',
'Disallows explicit type declarations for variables or parameters initialized to a number, string, or boolean',
category: 'Best Practices',
recommended: 'error',
},
@@ -1,8 +1,3 @@
/**
* @fileoverview Rule to flag statements that use magic numbers (adapted from https://github.com/danielstjules/buddy.js)
* @author Scott O'Hara
*/

import {
TSESTree,
AST_NODE_TYPES,
@@ -21,7 +16,7 @@ export default util.createRule<Options, MessageIds>({
meta: {
type: 'suggestion',
docs: {
description: 'Disallow magic numbers',
description: 'Disallows magic numbers',
category: 'Best Practices',
recommended: false,
},
@@ -9,8 +9,7 @@ export default util.createRule({
meta: {
type: 'problem',
docs: {
description: 'Enforce valid definition of `new` and `constructor`.',
tslintRuleName: 'no-misused-new',
description: 'Enforce valid definition of `new` and `constructor`',
category: 'Best Practices',
recommended: 'error',
},
@@ -19,7 +19,6 @@ export default util.createRule<Options, MessageIds>({
docs: {
description:
'Disallow the use of custom TypeScript modules and namespaces',
tslintRuleName: 'no-namespace',
category: 'Best Practices',
recommended: 'error',
},
@@ -7,7 +7,6 @@ export default util.createRule({
docs: {
description:
'Disallows non-null assertions using the `!` postfix operator',
tslintRuleName: 'no-non-null-assertion',
category: 'Stylistic Issues',
recommended: 'error',
},
@@ -18,7 +18,6 @@ export default util.createRule<Options, MessageIds>({
docs: {
description:
'Forbids an object literal to appear in a type assertion expression',
tslintRuleName: 'no-object-literal-type-assertion',
category: 'Stylistic Issues',
recommended: 'error',
},
@@ -25,8 +25,7 @@ export default util.createRule<Options, MessageIds>({
type: 'problem',
docs: {
description:
'Disallow the use of parameter properties in class constructors.',
tslintRuleName: 'no-parameter-properties',
'Disallow the use of parameter properties in class constructors',
category: 'Stylistic Issues',
recommended: 'error',
},
@@ -6,8 +6,7 @@ export default util.createRule({
meta: {
type: 'problem',
docs: {
description: 'Disallows invocation of `require()`.',
tslintName: 'no-require-imports',
description: 'Disallows invocation of `require()`',
category: 'Best Practices',
recommended: false,
},
@@ -18,7 +18,6 @@ export default util.createRule<Options, MessageIds>({
type: 'suggestion',
docs: {
description: 'Disallow aliasing `this`',
tslintRuleName: 'no-this-assignment',
category: 'Best Practices',
recommended: false,
},
@@ -6,7 +6,6 @@ export default util.createRule({
type: 'suggestion',
docs: {
description: 'Disallow `/// <reference path="" />` comments',
tslintRuleName: 'no-reference',
category: 'Best Practices',
recommended: 'error',
},
@@ -36,7 +36,6 @@ export default util.createRule<Options, MessageIds>({
type: 'suggestion',
docs: {
description: 'Disallow the use of type aliases',
tslintRuleName: 'interface-over-type-literal',
category: 'Stylistic Issues',
recommended: false,
},
@@ -8,9 +8,8 @@ export default util.createRule({
meta: {
docs: {
category: 'Best Practices',
description: 'Warns when a namespace qualifier is unnecessary.',
description: 'Warns when a namespace qualifier is unnecessary',
recommended: false,
tslintName: 'no-unnecessary-qualifier',
},
fixable: 'code',
messages: {
@@ -28,7 +28,6 @@ export default util.createRule<Options, MessageIds>({
'Warns if a type assertion does not change the type of an expression',
category: 'Best Practices',
recommended: false,
tslintRuleName: 'no-unnecessary-type-assertion',
},
fixable: 'code',
messages: {
@@ -11,7 +11,6 @@ export default util.createRule({
type: 'problem',
docs: {
description: 'Disallow unused variables',
tslintRuleName: 'no-unused-variable',
category: 'Variables',
recommended: 'warn',
},
@@ -11,7 +11,6 @@ export default util.createRule<Options, MessageIds>({
docs: {
description:
'Disallows the use of require statements except in import statements',
tslintRuleName: 'no-var-requires',
category: 'Best Practices',
recommended: 'error',
},
@@ -11,10 +11,9 @@ export default util.createRule({
type: 'suggestion',
docs: {
description:
'Prefer a ‘for-of’ loop over a standard ‘for’ loop if the index is only used to access the array being iterated.',
'Prefer a ‘for-of’ loop over a standard ‘for’ loop if the index is only used to access the array being iterated',
category: 'Stylistic Issues',
recommended: false,
tslintName: 'prefer-for-of',
},
messages: {
preferForOf:

0 comments on commit 4edf0d7

Please sign in to comment.
You can’t perform that action at this time.