eslint 8.57.1 → 9.39.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +165 -115
- package/bin/eslint.js +112 -89
- package/conf/default-cli-options.js +22 -22
- package/conf/ecma-version.js +16 -0
- package/conf/globals.js +109 -94
- package/conf/replacements.json +24 -20
- package/conf/rule-type-list.json +89 -26
- package/lib/api.js +16 -20
- package/lib/cli-engine/cli-engine.js +841 -810
- package/lib/cli-engine/file-enumerator.js +384 -390
- package/lib/cli-engine/formatters/formatters-meta.json +17 -45
- package/lib/cli-engine/formatters/html.js +110 -102
- package/lib/cli-engine/formatters/json-with-metadata.js +5 -5
- package/lib/cli-engine/formatters/json.js +2 -2
- package/lib/cli-engine/formatters/stylish.js +97 -76
- package/lib/cli-engine/hash.js +1 -1
- package/lib/cli-engine/index.js +1 -1
- package/lib/cli-engine/lint-result-cache.js +165 -148
- package/lib/cli-engine/load-rules.js +17 -17
- package/lib/cli.js +481 -399
- package/lib/config/config-loader.js +816 -0
- package/lib/config/config.js +674 -0
- package/lib/config/default-config.js +57 -46
- package/lib/config/flat-config-array.js +170 -333
- package/lib/config/flat-config-schema.js +389 -389
- package/lib/config-api.js +12 -0
- package/lib/eslint/eslint-helpers.js +1196 -663
- package/lib/eslint/eslint.js +1262 -607
- package/lib/eslint/index.js +3 -3
- package/lib/eslint/legacy-eslint.js +786 -0
- package/lib/eslint/worker.js +173 -0
- package/lib/languages/js/index.js +336 -0
- package/lib/languages/js/source-code/index.js +7 -0
- package/lib/languages/js/source-code/source-code.js +1364 -0
- package/lib/languages/js/source-code/token-store/backward-token-comment-cursor.js +61 -0
- package/lib/languages/js/source-code/token-store/backward-token-cursor.js +57 -0
- package/lib/{source-code → languages/js/source-code}/token-store/cursor.js +36 -36
- package/lib/languages/js/source-code/token-store/cursors.js +120 -0
- package/lib/{source-code → languages/js/source-code}/token-store/decorative-cursor.js +17 -18
- package/lib/{source-code → languages/js/source-code}/token-store/filter-cursor.js +19 -20
- package/lib/languages/js/source-code/token-store/forward-token-comment-cursor.js +65 -0
- package/lib/languages/js/source-code/token-store/forward-token-cursor.js +62 -0
- package/lib/languages/js/source-code/token-store/index.js +721 -0
- package/lib/{source-code → languages/js/source-code}/token-store/limit-cursor.js +17 -18
- package/lib/languages/js/source-code/token-store/padded-token-cursor.js +45 -0
- package/lib/{source-code → languages/js/source-code}/token-store/skip-cursor.js +19 -20
- package/lib/languages/js/source-code/token-store/utils.js +110 -0
- package/lib/languages/js/validate-language-options.js +196 -0
- package/lib/linter/apply-disable-directives.js +490 -371
- package/lib/linter/code-path-analysis/code-path-analyzer.js +650 -674
- package/lib/linter/code-path-analysis/code-path-segment.js +215 -216
- package/lib/linter/code-path-analysis/code-path-state.js +2118 -2096
- package/lib/linter/code-path-analysis/code-path.js +307 -317
- package/lib/linter/code-path-analysis/debug-helpers.js +183 -163
- package/lib/linter/code-path-analysis/fork-context.js +297 -272
- package/lib/linter/code-path-analysis/id-generator.js +22 -23
- package/lib/linter/esquery.js +332 -0
- package/lib/linter/file-context.js +144 -0
- package/lib/linter/file-report.js +608 -0
- package/lib/linter/index.js +3 -5
- package/lib/linter/interpolate.js +38 -16
- package/lib/linter/linter.js +2328 -1785
- package/lib/linter/rule-fixer.js +136 -107
- package/lib/linter/rules.js +37 -46
- package/lib/linter/source-code-fixer.js +96 -94
- package/lib/linter/source-code-traverser.js +333 -0
- package/lib/linter/source-code-visitor.js +81 -0
- package/lib/linter/timing.js +145 -97
- package/lib/linter/vfile.js +115 -0
- package/lib/options.js +464 -326
- package/lib/rule-tester/index.js +3 -1
- package/lib/rule-tester/rule-tester.js +1371 -998
- package/lib/rules/accessor-pairs.js +333 -259
- package/lib/rules/array-bracket-newline.js +250 -220
- package/lib/rules/array-bracket-spacing.js +286 -229
- package/lib/rules/array-callback-return.js +401 -354
- package/lib/rules/array-element-newline.js +358 -295
- package/lib/rules/arrow-body-style.js +400 -278
- package/lib/rules/arrow-parens.js +206 -155
- package/lib/rules/arrow-spacing.js +169 -145
- package/lib/rules/block-scoped-var.js +125 -123
- package/lib/rules/block-spacing.js +186 -158
- package/lib/rules/brace-style.js +262 -181
- package/lib/rules/callback-return.js +203 -174
- package/lib/rules/camelcase.js +403 -380
- package/lib/rules/capitalized-comments.js +253 -228
- package/lib/rules/class-methods-use-this.js +231 -168
- package/lib/rules/comma-dangle.js +379 -328
- package/lib/rules/comma-spacing.js +193 -177
- package/lib/rules/comma-style.js +375 -298
- package/lib/rules/complexity.js +180 -144
- package/lib/rules/computed-property-spacing.js +236 -193
- package/lib/rules/consistent-return.js +181 -170
- package/lib/rules/consistent-this.js +167 -141
- package/lib/rules/constructor-super.js +418 -411
- package/lib/rules/curly.js +407 -468
- package/lib/rules/default-case-last.js +39 -32
- package/lib/rules/default-case.js +89 -83
- package/lib/rules/default-param-last.js +69 -53
- package/lib/rules/dot-location.js +122 -92
- package/lib/rules/dot-notation.js +193 -153
- package/lib/rules/eol-last.js +122 -102
- package/lib/rules/eqeqeq.js +191 -155
- package/lib/rules/for-direction.js +150 -122
- package/lib/rules/func-call-spacing.js +261 -213
- package/lib/rules/func-name-matching.js +294 -209
- package/lib/rules/func-names.js +165 -164
- package/lib/rules/func-style.js +209 -86
- package/lib/rules/function-call-argument-newline.js +152 -111
- package/lib/rules/function-paren-newline.js +349 -273
- package/lib/rules/generator-star-spacing.js +229 -192
- package/lib/rules/getter-return.js +208 -170
- package/lib/rules/global-require.js +85 -58
- package/lib/rules/grouped-accessor-pairs.js +201 -148
- package/lib/rules/guard-for-in.js +72 -63
- package/lib/rules/handle-callback-err.js +108 -87
- package/lib/rules/id-blacklist.js +182 -187
- package/lib/rules/id-denylist.js +174 -179
- package/lib/rules/id-length.js +197 -157
- package/lib/rules/id-match.js +350 -286
- package/lib/rules/implicit-arrow-linebreak.js +102 -61
- package/lib/rules/indent-legacy.js +1345 -1102
- package/lib/rules/indent.js +2272 -1741
- package/lib/rules/index.js +320 -294
- package/lib/rules/init-declarations.js +139 -106
- package/lib/rules/jsx-quotes.js +94 -64
- package/lib/rules/key-spacing.js +750 -615
- package/lib/rules/keyword-spacing.js +648 -587
- package/lib/rules/line-comment-position.js +143 -108
- package/lib/rules/linebreak-style.js +115 -88
- package/lib/rules/lines-around-comment.js +540 -430
- package/lib/rules/lines-around-directive.js +233 -185
- package/lib/rules/lines-between-class-members.js +305 -216
- package/lib/rules/logical-assignment-operators.js +582 -398
- package/lib/rules/max-classes-per-file.js +69 -68
- package/lib/rules/max-depth.js +146 -143
- package/lib/rules/max-len.js +473 -416
- package/lib/rules/max-lines-per-function.js +201 -176
- package/lib/rules/max-lines.js +158 -162
- package/lib/rules/max-nested-callbacks.js +102 -104
- package/lib/rules/max-params.js +102 -75
- package/lib/rules/max-statements-per-line.js +205 -180
- package/lib/rules/max-statements.js +168 -164
- package/lib/rules/multiline-comment-style.js +638 -460
- package/lib/rules/multiline-ternary.js +241 -158
- package/lib/rules/new-cap.js +233 -232
- package/lib/rules/new-parens.js +88 -61
- package/lib/rules/newline-after-var.js +287 -233
- package/lib/rules/newline-before-return.js +229 -204
- package/lib/rules/newline-per-chained-call.js +142 -109
- package/lib/rules/no-alert.js +90 -79
- package/lib/rules/no-array-constructor.js +175 -113
- package/lib/rules/no-async-promise-executor.js +30 -24
- package/lib/rules/no-await-in-loop.js +79 -70
- package/lib/rules/no-bitwise.js +113 -87
- package/lib/rules/no-buffer-constructor.js +61 -37
- package/lib/rules/no-caller.js +39 -33
- package/lib/rules/no-case-declarations.js +61 -45
- package/lib/rules/no-catch-shadow.js +76 -62
- package/lib/rules/no-class-assign.js +51 -48
- package/lib/rules/no-compare-neg-zero.js +62 -48
- package/lib/rules/no-cond-assign.js +148 -132
- package/lib/rules/no-confusing-arrow.js +98 -63
- package/lib/rules/no-console.js +202 -188
- package/lib/rules/no-const-assign.js +58 -41
- package/lib/rules/no-constant-binary-expression.js +501 -407
- package/lib/rules/no-constant-condition.js +158 -131
- package/lib/rules/no-constructor-return.js +49 -49
- package/lib/rules/no-continue.js +25 -26
- package/lib/rules/no-control-regex.js +125 -121
- package/lib/rules/no-debugger.js +28 -30
- package/lib/rules/no-delete-var.js +29 -29
- package/lib/rules/no-div-regex.js +47 -40
- package/lib/rules/no-dupe-args.js +79 -69
- package/lib/rules/no-dupe-class-members.js +102 -89
- package/lib/rules/no-dupe-else-if.js +100 -77
- package/lib/rules/no-dupe-keys.js +133 -110
- package/lib/rules/no-duplicate-case.js +50 -43
- package/lib/rules/no-duplicate-imports.js +266 -188
- package/lib/rules/no-else-return.js +430 -385
- package/lib/rules/no-empty-character-class.js +57 -50
- package/lib/rules/no-empty-function.js +197 -128
- package/lib/rules/no-empty-pattern.js +63 -56
- package/lib/rules/no-empty-static-block.js +61 -35
- package/lib/rules/no-empty.js +135 -85
- package/lib/rules/no-eq-null.js +37 -32
- package/lib/rules/no-eval.js +258 -249
- package/lib/rules/no-ex-assign.js +42 -39
- package/lib/rules/no-extend-native.js +161 -160
- package/lib/rules/no-extra-bind.js +201 -190
- package/lib/rules/no-extra-boolean-cast.js +398 -295
- package/lib/rules/no-extra-label.js +150 -130
- package/lib/rules/no-extra-parens.js +1654 -1307
- package/lib/rules/no-extra-semi.js +146 -126
- package/lib/rules/no-fallthrough.js +200 -136
- package/lib/rules/no-floating-decimal.js +74 -48
- package/lib/rules/no-func-assign.js +54 -55
- package/lib/rules/no-global-assign.js +78 -72
- package/lib/rules/no-implicit-coercion.js +350 -262
- package/lib/rules/no-implicit-globals.js +174 -133
- package/lib/rules/no-implied-eval.js +150 -112
- package/lib/rules/no-import-assign.js +145 -159
- package/lib/rules/no-inline-comments.js +101 -96
- package/lib/rules/no-inner-declarations.js +115 -78
- package/lib/rules/no-invalid-regexp.js +223 -174
- package/lib/rules/no-invalid-this.js +145 -117
- package/lib/rules/no-irregular-whitespace.js +266 -250
- package/lib/rules/no-iterator.js +29 -33
- package/lib/rules/no-label-var.js +59 -61
- package/lib/rules/no-labels.js +138 -131
- package/lib/rules/no-lone-blocks.js +127 -123
- package/lib/rules/no-lonely-if.js +105 -67
- package/lib/rules/no-loop-func.js +245 -184
- package/lib/rules/no-loss-of-precision.js +236 -201
- package/lib/rules/no-magic-numbers.js +339 -217
- package/lib/rules/no-misleading-character-class.js +548 -253
- package/lib/rules/no-mixed-operators.js +188 -164
- package/lib/rules/no-mixed-requires.js +253 -224
- package/lib/rules/no-mixed-spaces-and-tabs.js +135 -103
- package/lib/rules/no-multi-assign.js +46 -47
- package/lib/rules/no-multi-spaces.js +163 -125
- package/lib/rules/no-multi-str.js +42 -40
- package/lib/rules/no-multiple-empty-lines.js +196 -140
- package/lib/rules/no-native-reassign.js +90 -74
- package/lib/rules/no-negated-condition.js +79 -74
- package/lib/rules/no-negated-in-lhs.js +45 -32
- package/lib/rules/no-nested-ternary.js +33 -31
- package/lib/rules/no-new-func.js +71 -62
- package/lib/rules/no-new-native-nonconstructor.js +43 -39
- package/lib/rules/no-new-object.js +48 -39
- package/lib/rules/no-new-require.js +48 -31
- package/lib/rules/no-new-symbol.js +61 -43
- package/lib/rules/no-new-wrappers.js +43 -41
- package/lib/rules/no-new.js +28 -29
- package/lib/rules/no-nonoctal-decimal-escape.js +149 -121
- package/lib/rules/no-obj-calls.js +66 -53
- package/lib/rules/no-object-constructor.js +104 -97
- package/lib/rules/no-octal-escape.js +40 -43
- package/lib/rules/no-octal.js +29 -32
- package/lib/rules/no-param-reassign.js +236 -218
- package/lib/rules/no-path-concat.js +66 -51
- package/lib/rules/no-plusplus.js +60 -63
- package/lib/rules/no-process-env.js +49 -32
- package/lib/rules/no-process-exit.js +48 -28
- package/lib/rules/no-promise-executor-return.js +205 -204
- package/lib/rules/no-proto.js +26 -29
- package/lib/rules/no-prototype-builtins.js +146 -124
- package/lib/rules/no-redeclare.js +154 -155
- package/lib/rules/no-regex-spaces.js +183 -161
- package/lib/rules/no-restricted-exports.js +208 -174
- package/lib/rules/no-restricted-globals.js +254 -112
- package/lib/rules/no-restricted-imports.js +824 -384
- package/lib/rules/no-restricted-modules.js +222 -186
- package/lib/rules/no-restricted-properties.js +218 -153
- package/lib/rules/no-restricted-syntax.js +56 -52
- package/lib/rules/no-return-assign.js +56 -49
- package/lib/rules/no-return-await.js +147 -120
- package/lib/rules/no-script-url.js +53 -46
- package/lib/rules/no-self-assign.js +148 -145
- package/lib/rules/no-self-compare.js +63 -46
- package/lib/rules/no-sequences.js +135 -115
- package/lib/rules/no-setter-return.js +176 -178
- package/lib/rules/no-shadow-restricted-names.js +84 -36
- package/lib/rules/no-shadow.js +598 -310
- package/lib/rules/no-spaced-func.js +82 -60
- package/lib/rules/no-sparse-arrays.js +46 -28
- package/lib/rules/no-sync.js +61 -44
- package/lib/rules/no-tabs.js +83 -54
- package/lib/rules/no-template-curly-in-string.js +33 -32
- package/lib/rules/no-ternary.js +25 -28
- package/lib/rules/no-this-before-super.js +332 -298
- package/lib/rules/no-throw-literal.js +31 -36
- package/lib/rules/no-trailing-spaces.js +208 -174
- package/lib/rules/no-unassigned-vars.js +80 -0
- package/lib/rules/no-undef-init.js +86 -60
- package/lib/rules/no-undef.js +52 -47
- package/lib/rules/no-undefined.js +73 -74
- package/lib/rules/no-underscore-dangle.js +370 -322
- package/lib/rules/no-unexpected-multiline.js +112 -102
- package/lib/rules/no-unmodified-loop-condition.js +254 -254
- package/lib/rules/no-unneeded-ternary.js +212 -146
- package/lib/rules/no-unreachable-loop.js +145 -140
- package/lib/rules/no-unreachable.js +255 -248
- package/lib/rules/no-unsafe-finally.js +93 -85
- package/lib/rules/no-unsafe-negation.js +105 -81
- package/lib/rules/no-unsafe-optional-chaining.js +193 -177
- package/lib/rules/no-unused-expressions.js +199 -158
- package/lib/rules/no-unused-labels.js +139 -124
- package/lib/rules/no-unused-private-class-members.js +206 -182
- package/lib/rules/no-unused-vars.js +1708 -687
- package/lib/rules/no-use-before-define.js +327 -229
- package/lib/rules/no-useless-assignment.js +654 -0
- package/lib/rules/no-useless-backreference.js +212 -143
- package/lib/rules/no-useless-call.js +58 -53
- package/lib/rules/no-useless-catch.js +40 -40
- package/lib/rules/no-useless-computed-key.js +144 -108
- package/lib/rules/no-useless-concat.js +65 -59
- package/lib/rules/no-useless-constructor.js +160 -97
- package/lib/rules/no-useless-escape.js +364 -291
- package/lib/rules/no-useless-rename.js +183 -153
- package/lib/rules/no-useless-return.js +344 -307
- package/lib/rules/no-var.js +245 -212
- package/lib/rules/no-void.js +51 -46
- package/lib/rules/no-warning-comments.js +191 -183
- package/lib/rules/no-whitespace-before-property.js +131 -97
- package/lib/rules/no-with.js +24 -26
- package/lib/rules/nonblock-statement-body-position.js +149 -112
- package/lib/rules/object-curly-newline.js +306 -247
- package/lib/rules/object-curly-spacing.js +360 -296
- package/lib/rules/object-property-newline.js +137 -88
- package/lib/rules/object-shorthand.js +632 -500
- package/lib/rules/one-var-declaration-per-line.js +104 -82
- package/lib/rules/one-var.js +686 -536
- package/lib/rules/operator-assignment.js +219 -158
- package/lib/rules/operator-linebreak.js +295 -233
- package/lib/rules/padded-blocks.js +346 -290
- package/lib/rules/padding-line-between-statements.js +443 -421
- package/lib/rules/prefer-arrow-callback.js +371 -315
- package/lib/rules/prefer-const.js +418 -373
- package/lib/rules/prefer-destructuring.js +309 -278
- package/lib/rules/prefer-exponentiation-operator.js +176 -132
- package/lib/rules/prefer-named-capture-group.js +160 -141
- package/lib/rules/prefer-numeric-literals.js +121 -112
- package/lib/rules/prefer-object-has-own.js +116 -82
- package/lib/rules/prefer-object-spread.js +214 -193
- package/lib/rules/prefer-promise-reject-errors.js +140 -118
- package/lib/rules/prefer-reflect.js +126 -103
- package/lib/rules/prefer-regex-literals.js +561 -463
- package/lib/rules/prefer-rest-params.js +79 -80
- package/lib/rules/prefer-spread.js +47 -43
- package/lib/rules/prefer-template.js +266 -194
- package/lib/rules/preserve-caught-error.js +535 -0
- package/lib/rules/quote-props.js +373 -289
- package/lib/rules/quotes.js +374 -308
- package/lib/rules/radix.js +152 -134
- package/lib/rules/require-atomic-updates.js +316 -282
- package/lib/rules/require-await.js +153 -82
- package/lib/rules/require-unicode-regexp.js +296 -108
- package/lib/rules/require-yield.js +53 -54
- package/lib/rules/rest-spread-spacing.js +128 -98
- package/lib/rules/semi-spacing.js +281 -232
- package/lib/rules/semi-style.js +176 -116
- package/lib/rules/semi.js +456 -418
- package/lib/rules/sort-imports.js +307 -229
- package/lib/rules/sort-keys.js +219 -181
- package/lib/rules/sort-vars.js +127 -91
- package/lib/rules/space-before-blocks.js +199 -171
- package/lib/rules/space-before-function-paren.js +186 -148
- package/lib/rules/space-in-parens.js +359 -270
- package/lib/rules/space-infix-ops.js +237 -183
- package/lib/rules/space-unary-ops.js +356 -280
- package/lib/rules/spaced-comment.js +363 -301
- package/lib/rules/strict.js +266 -229
- package/lib/rules/switch-colon-spacing.js +130 -104
- package/lib/rules/symbol-description.js +45 -48
- package/lib/rules/template-curly-spacing.js +148 -124
- package/lib/rules/template-tag-spacing.js +98 -70
- package/lib/rules/unicode-bom.js +54 -54
- package/lib/rules/use-isnan.js +237 -110
- package/lib/rules/utils/ast-utils.js +2139 -1688
- package/lib/rules/utils/char-source.js +247 -0
- package/lib/rules/utils/fix-tracker.js +99 -88
- package/lib/rules/utils/keywords.js +59 -59
- package/lib/rules/utils/lazy-loading-rule-map.js +81 -78
- package/lib/rules/utils/regular-expressions.js +35 -19
- package/lib/rules/utils/unicode/index.js +9 -4
- package/lib/rules/utils/unicode/is-combining-character.js +1 -1
- package/lib/rules/utils/unicode/is-emoji-modifier.js +1 -1
- package/lib/rules/utils/unicode/is-regional-indicator-symbol.js +1 -1
- package/lib/rules/utils/unicode/is-surrogate-pair.js +1 -1
- package/lib/rules/valid-typeof.js +153 -109
- package/lib/rules/vars-on-top.js +152 -144
- package/lib/rules/wrap-iife.js +204 -173
- package/lib/rules/wrap-regex.js +77 -47
- package/lib/rules/yield-star-spacing.js +145 -116
- package/lib/rules/yoda.js +283 -274
- package/lib/services/parser-service.js +65 -0
- package/lib/services/processor-service.js +101 -0
- package/lib/services/suppressions-service.js +302 -0
- package/lib/services/warning-service.js +98 -0
- package/lib/shared/ajv.js +14 -14
- package/lib/shared/assert.js +21 -0
- package/lib/shared/ast-utils.js +7 -6
- package/lib/shared/deep-merge-arrays.js +62 -0
- package/lib/shared/directives.js +3 -2
- package/lib/shared/flags.js +108 -0
- package/lib/shared/logging.js +24 -16
- package/lib/shared/naming.js +109 -0
- package/lib/shared/option-utils.js +63 -0
- package/lib/shared/relative-module-resolver.js +18 -40
- package/lib/shared/runtime-info.js +138 -128
- package/lib/shared/serialization.js +78 -0
- package/lib/shared/severity.js +22 -22
- package/lib/shared/stats.js +30 -0
- package/lib/shared/string-utils.js +19 -21
- package/lib/shared/text-table.js +68 -0
- package/lib/shared/translate-cli-options.js +281 -0
- package/lib/shared/traverser.js +153 -146
- package/lib/types/config-api.d.ts +12 -0
- package/lib/types/index.d.ts +1473 -0
- package/lib/types/rules.d.ts +5589 -0
- package/lib/types/universal.d.ts +6 -0
- package/lib/types/use-at-your-own-risk.d.ts +87 -0
- package/lib/universal.js +10 -0
- package/lib/unsupported-api.js +8 -9
- package/messages/all-files-ignored.js +3 -3
- package/messages/all-matched-files-ignored.js +21 -0
- package/messages/config-file-missing.js +16 -0
- package/messages/config-plugin-missing.js +14 -0
- package/messages/config-serialize-function.js +30 -0
- package/messages/eslintrc-incompat.js +35 -16
- package/messages/eslintrc-plugins.js +8 -5
- package/messages/extend-config-missing.js +3 -3
- package/messages/failed-to-read-json.js +3 -3
- package/messages/file-not-found.js +3 -3
- package/messages/invalid-rule-options.js +2 -2
- package/messages/invalid-rule-severity.js +2 -2
- package/messages/no-config-found.js +4 -4
- package/messages/plugin-conflict.js +9 -9
- package/messages/plugin-invalid.js +4 -4
- package/messages/plugin-missing.js +4 -4
- package/messages/print-config-with-directory-path.js +2 -2
- package/messages/shared.js +6 -1
- package/messages/whitespace-found.js +3 -3
- package/package.json +105 -60
- package/conf/config-schema.js +0 -93
- package/lib/cli-engine/formatters/checkstyle.js +0 -60
- package/lib/cli-engine/formatters/compact.js +0 -60
- package/lib/cli-engine/formatters/jslint-xml.js +0 -41
- package/lib/cli-engine/formatters/junit.js +0 -82
- package/lib/cli-engine/formatters/tap.js +0 -95
- package/lib/cli-engine/formatters/unix.js +0 -58
- package/lib/cli-engine/formatters/visualstudio.js +0 -63
- package/lib/cli-engine/xml-escape.js +0 -34
- package/lib/config/flat-config-helpers.js +0 -111
- package/lib/config/rule-validator.js +0 -158
- package/lib/eslint/flat-eslint.js +0 -1159
- package/lib/linter/config-comment-parser.js +0 -185
- package/lib/linter/node-event-generator.js +0 -354
- package/lib/linter/report-translator.js +0 -369
- package/lib/linter/safe-emitter.js +0 -52
- package/lib/rule-tester/flat-rule-tester.js +0 -1131
- package/lib/rules/require-jsdoc.js +0 -122
- package/lib/rules/utils/patterns/letters.js +0 -36
- package/lib/rules/valid-jsdoc.js +0 -516
- package/lib/shared/config-validator.js +0 -347
- package/lib/shared/deprecation-warnings.js +0 -58
- package/lib/shared/types.js +0 -216
- package/lib/source-code/index.js +0 -5
- package/lib/source-code/source-code.js +0 -1055
- package/lib/source-code/token-store/backward-token-comment-cursor.js +0 -57
- package/lib/source-code/token-store/backward-token-cursor.js +0 -58
- package/lib/source-code/token-store/cursors.js +0 -90
- package/lib/source-code/token-store/forward-token-comment-cursor.js +0 -57
- package/lib/source-code/token-store/forward-token-cursor.js +0 -63
- package/lib/source-code/token-store/index.js +0 -627
- package/lib/source-code/token-store/padded-token-cursor.js +0 -38
- package/lib/source-code/token-store/utils.js +0 -107
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Rule to check for jsdoc presence.
|
|
3
|
-
* @author Gyandeep Singh
|
|
4
|
-
* @deprecated in ESLint v5.10.0
|
|
5
|
-
*/
|
|
6
|
-
"use strict";
|
|
7
|
-
|
|
8
|
-
/** @type {import('../shared/types').Rule} */
|
|
9
|
-
module.exports = {
|
|
10
|
-
meta: {
|
|
11
|
-
type: "suggestion",
|
|
12
|
-
|
|
13
|
-
docs: {
|
|
14
|
-
description: "Require JSDoc comments",
|
|
15
|
-
recommended: false,
|
|
16
|
-
url: "https://eslint.org/docs/latest/rules/require-jsdoc"
|
|
17
|
-
},
|
|
18
|
-
|
|
19
|
-
schema: [
|
|
20
|
-
{
|
|
21
|
-
type: "object",
|
|
22
|
-
properties: {
|
|
23
|
-
require: {
|
|
24
|
-
type: "object",
|
|
25
|
-
properties: {
|
|
26
|
-
ClassDeclaration: {
|
|
27
|
-
type: "boolean",
|
|
28
|
-
default: false
|
|
29
|
-
},
|
|
30
|
-
MethodDefinition: {
|
|
31
|
-
type: "boolean",
|
|
32
|
-
default: false
|
|
33
|
-
},
|
|
34
|
-
FunctionDeclaration: {
|
|
35
|
-
type: "boolean",
|
|
36
|
-
default: true
|
|
37
|
-
},
|
|
38
|
-
ArrowFunctionExpression: {
|
|
39
|
-
type: "boolean",
|
|
40
|
-
default: false
|
|
41
|
-
},
|
|
42
|
-
FunctionExpression: {
|
|
43
|
-
type: "boolean",
|
|
44
|
-
default: false
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
additionalProperties: false,
|
|
48
|
-
default: {}
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
additionalProperties: false
|
|
52
|
-
}
|
|
53
|
-
],
|
|
54
|
-
|
|
55
|
-
deprecated: true,
|
|
56
|
-
replacedBy: [],
|
|
57
|
-
|
|
58
|
-
messages: {
|
|
59
|
-
missingJSDocComment: "Missing JSDoc comment."
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
|
|
63
|
-
create(context) {
|
|
64
|
-
const source = context.sourceCode;
|
|
65
|
-
const DEFAULT_OPTIONS = {
|
|
66
|
-
FunctionDeclaration: true,
|
|
67
|
-
MethodDefinition: false,
|
|
68
|
-
ClassDeclaration: false,
|
|
69
|
-
ArrowFunctionExpression: false,
|
|
70
|
-
FunctionExpression: false
|
|
71
|
-
};
|
|
72
|
-
const options = Object.assign(DEFAULT_OPTIONS, context.options[0] && context.options[0].require);
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Report the error message
|
|
76
|
-
* @param {ASTNode} node node to report
|
|
77
|
-
* @returns {void}
|
|
78
|
-
*/
|
|
79
|
-
function report(node) {
|
|
80
|
-
context.report({ node, messageId: "missingJSDocComment" });
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Check if the jsdoc comment is present or not.
|
|
85
|
-
* @param {ASTNode} node node to examine
|
|
86
|
-
* @returns {void}
|
|
87
|
-
*/
|
|
88
|
-
function checkJsDoc(node) {
|
|
89
|
-
const jsdocComment = source.getJSDocComment(node);
|
|
90
|
-
|
|
91
|
-
if (!jsdocComment) {
|
|
92
|
-
report(node);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return {
|
|
97
|
-
FunctionDeclaration(node) {
|
|
98
|
-
if (options.FunctionDeclaration) {
|
|
99
|
-
checkJsDoc(node);
|
|
100
|
-
}
|
|
101
|
-
},
|
|
102
|
-
FunctionExpression(node) {
|
|
103
|
-
if (
|
|
104
|
-
(options.MethodDefinition && node.parent.type === "MethodDefinition") ||
|
|
105
|
-
(options.FunctionExpression && (node.parent.type === "VariableDeclarator" || (node.parent.type === "Property" && node === node.parent.value)))
|
|
106
|
-
) {
|
|
107
|
-
checkJsDoc(node);
|
|
108
|
-
}
|
|
109
|
-
},
|
|
110
|
-
ClassDeclaration(node) {
|
|
111
|
-
if (options.ClassDeclaration) {
|
|
112
|
-
checkJsDoc(node);
|
|
113
|
-
}
|
|
114
|
-
},
|
|
115
|
-
ArrowFunctionExpression(node) {
|
|
116
|
-
if (options.ArrowFunctionExpression && node.parent.type === "VariableDeclarator") {
|
|
117
|
-
checkJsDoc(node);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Pattern for detecting any letter (even letters outside of ASCII).
|
|
3
|
-
* NOTE: This file was generated using this script in JSCS based on the Unicode 7.0.0 standard: https://github.com/jscs-dev/node-jscs/blob/f5ed14427deb7e7aac84f3056a5aab2d9f3e563e/publish/helpers/generate-patterns.js
|
|
4
|
-
* Do not edit this file by hand-- please use https://github.com/mathiasbynens/regenerate to regenerate the regular expression exported from this file.
|
|
5
|
-
* @author Kevin Partington
|
|
6
|
-
* @license MIT License (from JSCS). See below.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
/*
|
|
10
|
-
* The MIT License (MIT)
|
|
11
|
-
*
|
|
12
|
-
* Copyright 2013-2016 Dulin Marat and other contributors
|
|
13
|
-
*
|
|
14
|
-
* Permission is hereby granted, free of charge, to any person obtaining
|
|
15
|
-
* a copy of this software and associated documentation files (the
|
|
16
|
-
* "Software"), to deal in the Software without restriction, including
|
|
17
|
-
* without limitation the rights to use, copy, modify, merge, publish,
|
|
18
|
-
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
19
|
-
* permit persons to whom the Software is furnished to do so, subject to
|
|
20
|
-
* the following conditions:
|
|
21
|
-
*
|
|
22
|
-
* The above copyright notice and this permission notice shall be
|
|
23
|
-
* included in all copies or substantial portions of the Software.
|
|
24
|
-
*
|
|
25
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
26
|
-
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
27
|
-
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
28
|
-
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
29
|
-
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
30
|
-
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
31
|
-
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
|
-
"use strict";
|
|
35
|
-
|
|
36
|
-
module.exports = /[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B2\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA7AD\uA7B0\uA7B1\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB5F\uAB64\uAB65\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF30-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDE00-\uDE11\uDE13-\uDE2B\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF5D-\uDF61]|\uD805[\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDE00-\uDE2F\uDE44\uDE80-\uDEAA]|\uD806[\uDCA0-\uDCDF\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF98]|[\uD80C\uD840-\uD868\uD86A-\uD86C][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D]|\uD87E[\uDC00-\uDE1D]/u;
|
package/lib/rules/valid-jsdoc.js
DELETED
|
@@ -1,516 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Validates JSDoc comments are syntactically correct
|
|
3
|
-
* @author Nicholas C. Zakas
|
|
4
|
-
* @deprecated in ESLint v5.10.0
|
|
5
|
-
*/
|
|
6
|
-
"use strict";
|
|
7
|
-
|
|
8
|
-
//------------------------------------------------------------------------------
|
|
9
|
-
// Requirements
|
|
10
|
-
//------------------------------------------------------------------------------
|
|
11
|
-
|
|
12
|
-
const doctrine = require("doctrine");
|
|
13
|
-
|
|
14
|
-
//------------------------------------------------------------------------------
|
|
15
|
-
// Rule Definition
|
|
16
|
-
//------------------------------------------------------------------------------
|
|
17
|
-
|
|
18
|
-
/** @type {import('../shared/types').Rule} */
|
|
19
|
-
module.exports = {
|
|
20
|
-
meta: {
|
|
21
|
-
type: "suggestion",
|
|
22
|
-
|
|
23
|
-
docs: {
|
|
24
|
-
description: "Enforce valid JSDoc comments",
|
|
25
|
-
recommended: false,
|
|
26
|
-
url: "https://eslint.org/docs/latest/rules/valid-jsdoc"
|
|
27
|
-
},
|
|
28
|
-
|
|
29
|
-
schema: [
|
|
30
|
-
{
|
|
31
|
-
type: "object",
|
|
32
|
-
properties: {
|
|
33
|
-
prefer: {
|
|
34
|
-
type: "object",
|
|
35
|
-
additionalProperties: {
|
|
36
|
-
type: "string"
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
preferType: {
|
|
40
|
-
type: "object",
|
|
41
|
-
additionalProperties: {
|
|
42
|
-
type: "string"
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
requireReturn: {
|
|
46
|
-
type: "boolean",
|
|
47
|
-
default: true
|
|
48
|
-
},
|
|
49
|
-
requireParamDescription: {
|
|
50
|
-
type: "boolean",
|
|
51
|
-
default: true
|
|
52
|
-
},
|
|
53
|
-
requireReturnDescription: {
|
|
54
|
-
type: "boolean",
|
|
55
|
-
default: true
|
|
56
|
-
},
|
|
57
|
-
matchDescription: {
|
|
58
|
-
type: "string"
|
|
59
|
-
},
|
|
60
|
-
requireReturnType: {
|
|
61
|
-
type: "boolean",
|
|
62
|
-
default: true
|
|
63
|
-
},
|
|
64
|
-
requireParamType: {
|
|
65
|
-
type: "boolean",
|
|
66
|
-
default: true
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
additionalProperties: false
|
|
70
|
-
}
|
|
71
|
-
],
|
|
72
|
-
|
|
73
|
-
fixable: "code",
|
|
74
|
-
messages: {
|
|
75
|
-
unexpectedTag: "Unexpected @{{title}} tag; function has no return statement.",
|
|
76
|
-
expected: "Expected JSDoc for '{{name}}' but found '{{jsdocName}}'.",
|
|
77
|
-
use: "Use @{{name}} instead.",
|
|
78
|
-
useType: "Use '{{expectedTypeName}}' instead of '{{currentTypeName}}'.",
|
|
79
|
-
syntaxError: "JSDoc syntax error.",
|
|
80
|
-
missingBrace: "JSDoc type missing brace.",
|
|
81
|
-
missingParamDesc: "Missing JSDoc parameter description for '{{name}}'.",
|
|
82
|
-
missingParamType: "Missing JSDoc parameter type for '{{name}}'.",
|
|
83
|
-
missingReturnType: "Missing JSDoc return type.",
|
|
84
|
-
missingReturnDesc: "Missing JSDoc return description.",
|
|
85
|
-
missingReturn: "Missing JSDoc @{{returns}} for function.",
|
|
86
|
-
missingParam: "Missing JSDoc for parameter '{{name}}'.",
|
|
87
|
-
duplicateParam: "Duplicate JSDoc parameter '{{name}}'.",
|
|
88
|
-
unsatisfiedDesc: "JSDoc description does not satisfy the regex pattern."
|
|
89
|
-
},
|
|
90
|
-
|
|
91
|
-
deprecated: true,
|
|
92
|
-
replacedBy: []
|
|
93
|
-
},
|
|
94
|
-
|
|
95
|
-
create(context) {
|
|
96
|
-
|
|
97
|
-
const options = context.options[0] || {},
|
|
98
|
-
prefer = options.prefer || {},
|
|
99
|
-
sourceCode = context.sourceCode,
|
|
100
|
-
|
|
101
|
-
// these both default to true, so you have to explicitly make them false
|
|
102
|
-
requireReturn = options.requireReturn !== false,
|
|
103
|
-
requireParamDescription = options.requireParamDescription !== false,
|
|
104
|
-
requireReturnDescription = options.requireReturnDescription !== false,
|
|
105
|
-
requireReturnType = options.requireReturnType !== false,
|
|
106
|
-
requireParamType = options.requireParamType !== false,
|
|
107
|
-
preferType = options.preferType || {},
|
|
108
|
-
checkPreferType = Object.keys(preferType).length !== 0;
|
|
109
|
-
|
|
110
|
-
//--------------------------------------------------------------------------
|
|
111
|
-
// Helpers
|
|
112
|
-
//--------------------------------------------------------------------------
|
|
113
|
-
|
|
114
|
-
// Using a stack to store if a function returns or not (handling nested functions)
|
|
115
|
-
const fns = [];
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Check if node type is a Class
|
|
119
|
-
* @param {ASTNode} node node to check.
|
|
120
|
-
* @returns {boolean} True is its a class
|
|
121
|
-
* @private
|
|
122
|
-
*/
|
|
123
|
-
function isTypeClass(node) {
|
|
124
|
-
return node.type === "ClassExpression" || node.type === "ClassDeclaration";
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* When parsing a new function, store it in our function stack.
|
|
129
|
-
* @param {ASTNode} node A function node to check.
|
|
130
|
-
* @returns {void}
|
|
131
|
-
* @private
|
|
132
|
-
*/
|
|
133
|
-
function startFunction(node) {
|
|
134
|
-
fns.push({
|
|
135
|
-
returnPresent: (node.type === "ArrowFunctionExpression" && node.body.type !== "BlockStatement") ||
|
|
136
|
-
isTypeClass(node) || node.async
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Indicate that return has been found in the current function.
|
|
142
|
-
* @param {ASTNode} node The return node.
|
|
143
|
-
* @returns {void}
|
|
144
|
-
* @private
|
|
145
|
-
*/
|
|
146
|
-
function addReturn(node) {
|
|
147
|
-
const functionState = fns[fns.length - 1];
|
|
148
|
-
|
|
149
|
-
if (functionState && node.argument !== null) {
|
|
150
|
-
functionState.returnPresent = true;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* Check if return tag type is void or undefined
|
|
156
|
-
* @param {Object} tag JSDoc tag
|
|
157
|
-
* @returns {boolean} True if its of type void or undefined
|
|
158
|
-
* @private
|
|
159
|
-
*/
|
|
160
|
-
function isValidReturnType(tag) {
|
|
161
|
-
return tag.type === null || tag.type.name === "void" || tag.type.type === "UndefinedLiteral";
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Check if type should be validated based on some exceptions
|
|
166
|
-
* @param {Object} type JSDoc tag
|
|
167
|
-
* @returns {boolean} True if it can be validated
|
|
168
|
-
* @private
|
|
169
|
-
*/
|
|
170
|
-
function canTypeBeValidated(type) {
|
|
171
|
-
return type !== "UndefinedLiteral" && // {undefined} as there is no name property available.
|
|
172
|
-
type !== "NullLiteral" && // {null}
|
|
173
|
-
type !== "NullableLiteral" && // {?}
|
|
174
|
-
type !== "FunctionType" && // {function(a)}
|
|
175
|
-
type !== "AllLiteral"; // {*}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Extract the current and expected type based on the input type object
|
|
180
|
-
* @param {Object} type JSDoc tag
|
|
181
|
-
* @returns {{currentType: Doctrine.Type, expectedTypeName: string}} The current type annotation and
|
|
182
|
-
* the expected name of the annotation
|
|
183
|
-
* @private
|
|
184
|
-
*/
|
|
185
|
-
function getCurrentExpectedTypes(type) {
|
|
186
|
-
let currentType;
|
|
187
|
-
|
|
188
|
-
if (type.name) {
|
|
189
|
-
currentType = type;
|
|
190
|
-
} else if (type.expression) {
|
|
191
|
-
currentType = type.expression;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
return {
|
|
195
|
-
currentType,
|
|
196
|
-
expectedTypeName: currentType && preferType[currentType.name]
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* Gets the location of a JSDoc node in a file
|
|
202
|
-
* @param {Token} jsdocComment The comment that this node is parsed from
|
|
203
|
-
* @param {{range: number[]}} parsedJsdocNode A tag or other node which was parsed from this comment
|
|
204
|
-
* @returns {{start: SourceLocation, end: SourceLocation}} The 0-based source location for the tag
|
|
205
|
-
*/
|
|
206
|
-
function getAbsoluteRange(jsdocComment, parsedJsdocNode) {
|
|
207
|
-
return {
|
|
208
|
-
start: sourceCode.getLocFromIndex(jsdocComment.range[0] + 2 + parsedJsdocNode.range[0]),
|
|
209
|
-
end: sourceCode.getLocFromIndex(jsdocComment.range[0] + 2 + parsedJsdocNode.range[1])
|
|
210
|
-
};
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* Validate type for a given JSDoc node
|
|
215
|
-
* @param {Object} jsdocNode JSDoc node
|
|
216
|
-
* @param {Object} type JSDoc tag
|
|
217
|
-
* @returns {void}
|
|
218
|
-
* @private
|
|
219
|
-
*/
|
|
220
|
-
function validateType(jsdocNode, type) {
|
|
221
|
-
if (!type || !canTypeBeValidated(type.type)) {
|
|
222
|
-
return;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
const typesToCheck = [];
|
|
226
|
-
let elements = [];
|
|
227
|
-
|
|
228
|
-
switch (type.type) {
|
|
229
|
-
case "TypeApplication": // {Array.<String>}
|
|
230
|
-
elements = type.applications[0].type === "UnionType" ? type.applications[0].elements : type.applications;
|
|
231
|
-
typesToCheck.push(getCurrentExpectedTypes(type));
|
|
232
|
-
break;
|
|
233
|
-
case "RecordType": // {{20:String}}
|
|
234
|
-
elements = type.fields;
|
|
235
|
-
break;
|
|
236
|
-
case "UnionType": // {String|number|Test}
|
|
237
|
-
case "ArrayType": // {[String, number, Test]}
|
|
238
|
-
elements = type.elements;
|
|
239
|
-
break;
|
|
240
|
-
case "FieldType": // Array.<{count: number, votes: number}>
|
|
241
|
-
if (type.value) {
|
|
242
|
-
typesToCheck.push(getCurrentExpectedTypes(type.value));
|
|
243
|
-
}
|
|
244
|
-
break;
|
|
245
|
-
default:
|
|
246
|
-
typesToCheck.push(getCurrentExpectedTypes(type));
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
elements.forEach(validateType.bind(null, jsdocNode));
|
|
250
|
-
|
|
251
|
-
typesToCheck.forEach(typeToCheck => {
|
|
252
|
-
if (typeToCheck.expectedTypeName &&
|
|
253
|
-
typeToCheck.expectedTypeName !== typeToCheck.currentType.name) {
|
|
254
|
-
context.report({
|
|
255
|
-
node: jsdocNode,
|
|
256
|
-
messageId: "useType",
|
|
257
|
-
loc: getAbsoluteRange(jsdocNode, typeToCheck.currentType),
|
|
258
|
-
data: {
|
|
259
|
-
currentTypeName: typeToCheck.currentType.name,
|
|
260
|
-
expectedTypeName: typeToCheck.expectedTypeName
|
|
261
|
-
},
|
|
262
|
-
fix(fixer) {
|
|
263
|
-
return fixer.replaceTextRange(
|
|
264
|
-
typeToCheck.currentType.range.map(indexInComment => jsdocNode.range[0] + 2 + indexInComment),
|
|
265
|
-
typeToCheck.expectedTypeName
|
|
266
|
-
);
|
|
267
|
-
}
|
|
268
|
-
});
|
|
269
|
-
}
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
* Validate the JSDoc node and output warnings if anything is wrong.
|
|
275
|
-
* @param {ASTNode} node The AST node to check.
|
|
276
|
-
* @returns {void}
|
|
277
|
-
* @private
|
|
278
|
-
*/
|
|
279
|
-
function checkJSDoc(node) {
|
|
280
|
-
const jsdocNode = sourceCode.getJSDocComment(node),
|
|
281
|
-
functionData = fns.pop(),
|
|
282
|
-
paramTagsByName = Object.create(null),
|
|
283
|
-
paramTags = [];
|
|
284
|
-
let hasReturns = false,
|
|
285
|
-
returnsTag,
|
|
286
|
-
hasConstructor = false,
|
|
287
|
-
isInterface = false,
|
|
288
|
-
isOverride = false,
|
|
289
|
-
isAbstract = false;
|
|
290
|
-
|
|
291
|
-
// make sure only to validate JSDoc comments
|
|
292
|
-
if (jsdocNode) {
|
|
293
|
-
let jsdoc;
|
|
294
|
-
|
|
295
|
-
try {
|
|
296
|
-
jsdoc = doctrine.parse(jsdocNode.value, {
|
|
297
|
-
strict: true,
|
|
298
|
-
unwrap: true,
|
|
299
|
-
sloppy: true,
|
|
300
|
-
range: true
|
|
301
|
-
});
|
|
302
|
-
} catch (ex) {
|
|
303
|
-
|
|
304
|
-
if (/braces/iu.test(ex.message)) {
|
|
305
|
-
context.report({ node: jsdocNode, messageId: "missingBrace" });
|
|
306
|
-
} else {
|
|
307
|
-
context.report({ node: jsdocNode, messageId: "syntaxError" });
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
return;
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
jsdoc.tags.forEach(tag => {
|
|
314
|
-
|
|
315
|
-
switch (tag.title.toLowerCase()) {
|
|
316
|
-
|
|
317
|
-
case "param":
|
|
318
|
-
case "arg":
|
|
319
|
-
case "argument":
|
|
320
|
-
paramTags.push(tag);
|
|
321
|
-
break;
|
|
322
|
-
|
|
323
|
-
case "return":
|
|
324
|
-
case "returns":
|
|
325
|
-
hasReturns = true;
|
|
326
|
-
returnsTag = tag;
|
|
327
|
-
break;
|
|
328
|
-
|
|
329
|
-
case "constructor":
|
|
330
|
-
case "class":
|
|
331
|
-
hasConstructor = true;
|
|
332
|
-
break;
|
|
333
|
-
|
|
334
|
-
case "override":
|
|
335
|
-
case "inheritdoc":
|
|
336
|
-
isOverride = true;
|
|
337
|
-
break;
|
|
338
|
-
|
|
339
|
-
case "abstract":
|
|
340
|
-
case "virtual":
|
|
341
|
-
isAbstract = true;
|
|
342
|
-
break;
|
|
343
|
-
|
|
344
|
-
case "interface":
|
|
345
|
-
isInterface = true;
|
|
346
|
-
break;
|
|
347
|
-
|
|
348
|
-
// no default
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
// check tag preferences
|
|
352
|
-
if (Object.prototype.hasOwnProperty.call(prefer, tag.title) && tag.title !== prefer[tag.title]) {
|
|
353
|
-
const entireTagRange = getAbsoluteRange(jsdocNode, tag);
|
|
354
|
-
|
|
355
|
-
context.report({
|
|
356
|
-
node: jsdocNode,
|
|
357
|
-
messageId: "use",
|
|
358
|
-
loc: {
|
|
359
|
-
start: entireTagRange.start,
|
|
360
|
-
end: {
|
|
361
|
-
line: entireTagRange.start.line,
|
|
362
|
-
column: entireTagRange.start.column + `@${tag.title}`.length
|
|
363
|
-
}
|
|
364
|
-
},
|
|
365
|
-
data: { name: prefer[tag.title] },
|
|
366
|
-
fix(fixer) {
|
|
367
|
-
return fixer.replaceTextRange(
|
|
368
|
-
[
|
|
369
|
-
jsdocNode.range[0] + tag.range[0] + 3,
|
|
370
|
-
jsdocNode.range[0] + tag.range[0] + tag.title.length + 3
|
|
371
|
-
],
|
|
372
|
-
prefer[tag.title]
|
|
373
|
-
);
|
|
374
|
-
}
|
|
375
|
-
});
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
// validate the types
|
|
379
|
-
if (checkPreferType && tag.type) {
|
|
380
|
-
validateType(jsdocNode, tag.type);
|
|
381
|
-
}
|
|
382
|
-
});
|
|
383
|
-
|
|
384
|
-
paramTags.forEach(param => {
|
|
385
|
-
if (requireParamType && !param.type) {
|
|
386
|
-
context.report({
|
|
387
|
-
node: jsdocNode,
|
|
388
|
-
messageId: "missingParamType",
|
|
389
|
-
loc: getAbsoluteRange(jsdocNode, param),
|
|
390
|
-
data: { name: param.name }
|
|
391
|
-
});
|
|
392
|
-
}
|
|
393
|
-
if (!param.description && requireParamDescription) {
|
|
394
|
-
context.report({
|
|
395
|
-
node: jsdocNode,
|
|
396
|
-
messageId: "missingParamDesc",
|
|
397
|
-
loc: getAbsoluteRange(jsdocNode, param),
|
|
398
|
-
data: { name: param.name }
|
|
399
|
-
});
|
|
400
|
-
}
|
|
401
|
-
if (paramTagsByName[param.name]) {
|
|
402
|
-
context.report({
|
|
403
|
-
node: jsdocNode,
|
|
404
|
-
messageId: "duplicateParam",
|
|
405
|
-
loc: getAbsoluteRange(jsdocNode, param),
|
|
406
|
-
data: { name: param.name }
|
|
407
|
-
});
|
|
408
|
-
} else if (!param.name.includes(".")) {
|
|
409
|
-
paramTagsByName[param.name] = param;
|
|
410
|
-
}
|
|
411
|
-
});
|
|
412
|
-
|
|
413
|
-
if (hasReturns) {
|
|
414
|
-
if (!requireReturn && !functionData.returnPresent && (returnsTag.type === null || !isValidReturnType(returnsTag)) && !isAbstract) {
|
|
415
|
-
context.report({
|
|
416
|
-
node: jsdocNode,
|
|
417
|
-
messageId: "unexpectedTag",
|
|
418
|
-
loc: getAbsoluteRange(jsdocNode, returnsTag),
|
|
419
|
-
data: {
|
|
420
|
-
title: returnsTag.title
|
|
421
|
-
}
|
|
422
|
-
});
|
|
423
|
-
} else {
|
|
424
|
-
if (requireReturnType && !returnsTag.type) {
|
|
425
|
-
context.report({ node: jsdocNode, messageId: "missingReturnType" });
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
if (!isValidReturnType(returnsTag) && !returnsTag.description && requireReturnDescription) {
|
|
429
|
-
context.report({ node: jsdocNode, messageId: "missingReturnDesc" });
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
// check for functions missing @returns
|
|
435
|
-
if (!isOverride && !hasReturns && !hasConstructor && !isInterface &&
|
|
436
|
-
node.parent.kind !== "get" && node.parent.kind !== "constructor" &&
|
|
437
|
-
node.parent.kind !== "set" && !isTypeClass(node)) {
|
|
438
|
-
if (requireReturn || (functionData.returnPresent && !node.async)) {
|
|
439
|
-
context.report({
|
|
440
|
-
node: jsdocNode,
|
|
441
|
-
messageId: "missingReturn",
|
|
442
|
-
data: {
|
|
443
|
-
returns: prefer.returns || "returns"
|
|
444
|
-
}
|
|
445
|
-
});
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
// check the parameters
|
|
450
|
-
const jsdocParamNames = Object.keys(paramTagsByName);
|
|
451
|
-
|
|
452
|
-
if (node.params) {
|
|
453
|
-
node.params.forEach((param, paramsIndex) => {
|
|
454
|
-
const bindingParam = param.type === "AssignmentPattern"
|
|
455
|
-
? param.left
|
|
456
|
-
: param;
|
|
457
|
-
|
|
458
|
-
// TODO(nzakas): Figure out logical things to do with destructured, default, rest params
|
|
459
|
-
if (bindingParam.type === "Identifier") {
|
|
460
|
-
const name = bindingParam.name;
|
|
461
|
-
|
|
462
|
-
if (jsdocParamNames[paramsIndex] && (name !== jsdocParamNames[paramsIndex])) {
|
|
463
|
-
context.report({
|
|
464
|
-
node: jsdocNode,
|
|
465
|
-
messageId: "expected",
|
|
466
|
-
loc: getAbsoluteRange(jsdocNode, paramTagsByName[jsdocParamNames[paramsIndex]]),
|
|
467
|
-
data: {
|
|
468
|
-
name,
|
|
469
|
-
jsdocName: jsdocParamNames[paramsIndex]
|
|
470
|
-
}
|
|
471
|
-
});
|
|
472
|
-
} else if (!paramTagsByName[name] && !isOverride) {
|
|
473
|
-
context.report({
|
|
474
|
-
node: jsdocNode,
|
|
475
|
-
messageId: "missingParam",
|
|
476
|
-
data: {
|
|
477
|
-
name
|
|
478
|
-
}
|
|
479
|
-
});
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
});
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
if (options.matchDescription) {
|
|
486
|
-
const regex = new RegExp(options.matchDescription, "u");
|
|
487
|
-
|
|
488
|
-
if (!regex.test(jsdoc.description)) {
|
|
489
|
-
context.report({ node: jsdocNode, messageId: "unsatisfiedDesc" });
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
//--------------------------------------------------------------------------
|
|
498
|
-
// Public
|
|
499
|
-
//--------------------------------------------------------------------------
|
|
500
|
-
|
|
501
|
-
return {
|
|
502
|
-
ArrowFunctionExpression: startFunction,
|
|
503
|
-
FunctionExpression: startFunction,
|
|
504
|
-
FunctionDeclaration: startFunction,
|
|
505
|
-
ClassExpression: startFunction,
|
|
506
|
-
ClassDeclaration: startFunction,
|
|
507
|
-
"ArrowFunctionExpression:exit": checkJSDoc,
|
|
508
|
-
"FunctionExpression:exit": checkJSDoc,
|
|
509
|
-
"FunctionDeclaration:exit": checkJSDoc,
|
|
510
|
-
"ClassExpression:exit": checkJSDoc,
|
|
511
|
-
"ClassDeclaration:exit": checkJSDoc,
|
|
512
|
-
ReturnStatement: addReturn
|
|
513
|
-
};
|
|
514
|
-
|
|
515
|
-
}
|
|
516
|
-
};
|