]>
git.proxmox.com Git - pve-eslint.git/blob - eslint/.eslintrc.js
4 * Any changes made to this file must also be made to eslint.config.js.
6 * Internally, ESLint is using the eslint.config.js file to lint itself.
7 * This file is needed too, because:
9 * 1. There are tests that expect .eslintrc.js to be present to actually run.
10 * 2. ESLint VS Code extension expects eslintrc config files to be
11 * present to work correctly.
13 * Once we no longer need to support both eslintrc and flat config, we will
20 const path
= require("path");
22 const INTERNAL_FILES
= {
23 CLI_ENGINE_PATTERN
: "lib/cli-engine/**/*",
24 LINTER_PATTERN
: "lib/linter/**/*",
25 RULE_TESTER_PATTERN
: "lib/rule-tester/**/*",
26 RULES_PATTERN
: "lib/rules/**/*",
27 SOURCE_CODE_PATTERN
: "lib/source-code/**/*"
31 * Resolve an absolute path or glob pattern.
32 * @param {string} pathOrPattern the path or glob pattern.
33 * @returns {string} The resolved path or glob pattern.
35 function resolveAbsolutePath(pathOrPattern
) {
36 return path
.resolve(__dirname
, pathOrPattern
);
40 * Create an array of `no-restricted-require` entries for ESLint's core files.
41 * @param {string} [pattern] The glob pattern to create the entries for.
42 * @returns {Object[]} The array of `no-restricted-require` entries.
44 function createInternalFilesPatterns(pattern
= null) {
45 return Object
.values(INTERNAL_FILES
)
46 .filter(p
=> p
!== pattern
)
50 // Disallow all children modules.
51 resolveAbsolutePath(p
),
53 // Allow the main `index.js` module.
54 `!${resolveAbsolutePath(p.replace(/\*\*\/\*$/u, "index.js"))}`
73 * it fixes eslint-plugin-jsdoc's reports: "Invalid JSDoc tag name "template" jsdoc/check-tag-names"
74 * refs: https://github.com/gajus/eslint-plugin-jsdoc#check-tag-names
82 "internal-rules/multiline-comment-style": "error"
86 files
: ["tools/*.js"],
92 files
: ["lib/rules/*", "tools/internal-rules/*"],
93 excludedFiles
: ["index.js"],
95 "plugin:eslint-plugin/rules-recommended"
98 "eslint-plugin/no-missing-message-ids": "error",
99 "eslint-plugin/no-unused-message-ids": "error",
100 "eslint-plugin/prefer-message-ids": "error",
101 "eslint-plugin/prefer-placeholders": "error",
102 "eslint-plugin/prefer-replace-text": "error",
103 "eslint-plugin/report-message-format": ["error", "[^a-z].*\\.$"],
104 "eslint-plugin/require-meta-docs-description": ["error", { pattern
: "^(Enforce|Require|Disallow)" }],
105 "internal-rules/no-invalid-meta": "error"
109 files
: ["lib/rules/*"],
110 excludedFiles
: ["index.js"],
112 "eslint-plugin/require-meta-docs-url": ["error", { pattern
: "https://eslint.org/docs/rules/{{name}}" }]
116 files
: ["tests/lib/rules/*", "tests/tools/internal-rules/*"],
118 "plugin:eslint-plugin/tests-recommended"
121 "eslint-plugin/prefer-output-null": "error",
122 "eslint-plugin/test-case-property-ordering": "error",
123 "eslint-plugin/test-case-shorthand-strings": "error"
127 files
: ["tests/**/*"],
128 env
: { mocha
: true },
130 "no-restricted-syntax": ["error", {
131 selector
: "CallExpression[callee.object.name='assert'][callee.property.name='doesNotThrow']",
132 message
: "`assert.doesNotThrow()` should be replaced with a comment next to the code."
137 // Restrict relative path imports
140 excludedFiles
: ["lib/unsupported-api.js"],
142 "n/no-restricted-require": ["error", [
143 ...createInternalFilesPatterns()
148 files
: [INTERNAL_FILES
.CLI_ENGINE_PATTERN
],
150 "n/no-restricted-require": ["error", [
151 ...createInternalFilesPatterns(INTERNAL_FILES
.CLI_ENGINE_PATTERN
)
156 files
: [INTERNAL_FILES
.LINTER_PATTERN
],
158 "n/no-restricted-require": ["error", [
159 ...createInternalFilesPatterns(INTERNAL_FILES
.LINTER_PATTERN
),
161 resolveAbsolutePath("lib/cli-engine/index.js"),
162 resolveAbsolutePath("lib/rule-tester/index.js")
167 files
: [INTERNAL_FILES
.RULES_PATTERN
],
169 "n/no-restricted-require": ["error", [
170 ...createInternalFilesPatterns(INTERNAL_FILES
.RULES_PATTERN
),
172 resolveAbsolutePath("lib/cli-engine/index.js"),
173 resolveAbsolutePath("lib/linter/index.js"),
174 resolveAbsolutePath("lib/rule-tester/index.js"),
175 resolveAbsolutePath("lib/source-code/index.js")
180 files
: ["lib/shared/**/*"],
182 "n/no-restricted-require": ["error", [
183 ...createInternalFilesPatterns(),
184 resolveAbsolutePath("lib/cli-engine/index.js"),
185 resolveAbsolutePath("lib/linter/index.js"),
186 resolveAbsolutePath("lib/rule-tester/index.js"),
187 resolveAbsolutePath("lib/source-code/index.js")
192 files
: [INTERNAL_FILES
.SOURCE_CODE_PATTERN
],
194 "n/no-restricted-require": ["error", [
195 ...createInternalFilesPatterns(INTERNAL_FILES
.SOURCE_CODE_PATTERN
),
197 resolveAbsolutePath("lib/cli-engine/index.js"),
198 resolveAbsolutePath("lib/linter/index.js"),
199 resolveAbsolutePath("lib/rule-tester/index.js"),
200 resolveAbsolutePath("lib/rules/index.js")
205 files
: [INTERNAL_FILES
.RULE_TESTER_PATTERN
],
207 "n/no-restricted-require": ["error", [
208 ...createInternalFilesPatterns(INTERNAL_FILES
.RULE_TESTER_PATTERN
),
209 resolveAbsolutePath("lib/cli-engine/index.js")