eslint-config-un 0.3.1 → 0.4.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 +3 -1
- package/dist/index.cjs +145 -95
- package/dist/index.d.cts +11228 -6336
- package/dist/index.d.ts +11228 -6336
- package/dist/index.js +140 -91
- package/package.json +56 -51
package/README.md
CHANGED
|
@@ -25,7 +25,7 @@ Includes the rules from the following configs & plugins:
|
|
|
25
25
|
- [promise](https://www.npmjs.com/package/eslint-plugin-promise)
|
|
26
26
|
- [regexp](https://www.npmjs.com/package/eslint-plugin-regexp)
|
|
27
27
|
- [security](https://www.npmjs.com/package/eslint-plugin-security)
|
|
28
|
-
- [sonar](https://www.npmjs.com/package/eslint-plugin-sonarjs)
|
|
28
|
+
- [sonar](https://www.npmjs.com/package/eslint-plugin-sonarjs) (v3 since v0.4.0, v1 before)
|
|
29
29
|
- [tailwind](https://www.npmjs.com/package/eslint-plugin-tailwindcss)
|
|
30
30
|
- [jsonc](https://www.npmjs.com/package/eslint-plugin-jsonc) (since v0.1.4)
|
|
31
31
|
- [yaml](https://www.npmjs.com/package/eslint-plugin-yaml) (since v0.1.0)
|
|
@@ -38,6 +38,7 @@ Includes the rules from the following configs & plugins:
|
|
|
38
38
|
- [jest](https://www.npmjs.com/package/eslint-plugin-jest) (+ [jest-extended](https://www.npmjs.com/package/eslint-plugin-jest-extended)) (since v0.3.0)
|
|
39
39
|
- [vitest](https://www.npmjs.com/package/@vitest/eslint-plugin) (since v0.3.0)
|
|
40
40
|
- [jsdoc](https://www.npmjs.com/package/eslint-plugin-jsdoc) (since v0.3.1)
|
|
41
|
+
- [perfectionist](https://www.npmjs.com/package/eslint-plugin-perfectionist) (since v0.4.0)
|
|
41
42
|
|
|
42
43
|
## Features
|
|
43
44
|
|
|
@@ -73,6 +74,7 @@ export default eslintConfig({
|
|
|
73
74
|
- `yaml`
|
|
74
75
|
- `toml`
|
|
75
76
|
- `package-json`
|
|
77
|
+
- `perfectionist`
|
|
76
78
|
- Some rules are set to warn by default. You can change some or even all such rule's reporting level using `errorsInsteadOfWarnings` option. You can find all such rules by inspecting the source code of this package.
|
|
77
79
|
|
|
78
80
|
### Certain rules are disabled for code blocks inside `*.md` files
|
package/dist/index.cjs
CHANGED
|
@@ -33,19 +33,19 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
33
33
|
));
|
|
34
34
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
35
35
|
|
|
36
|
-
// node_modules/.pnpm/tsup@8.3.5_jiti@2.0.0_postcss@8.4.47_tsx@4.16.2_typescript@5.7.
|
|
36
|
+
// node_modules/.pnpm/tsup@8.3.5_jiti@2.0.0_postcss@8.4.47_tsx@4.16.2_typescript@5.7.3_yaml@2.4.5/node_modules/tsup/assets/cjs_shims.js
|
|
37
37
|
var init_cjs_shims = __esm({
|
|
38
|
-
"node_modules/.pnpm/tsup@8.3.5_jiti@2.0.0_postcss@8.4.47_tsx@4.16.2_typescript@5.7.
|
|
38
|
+
"node_modules/.pnpm/tsup@8.3.5_jiti@2.0.0_postcss@8.4.47_tsx@4.16.2_typescript@5.7.3_yaml@2.4.5/node_modules/tsup/assets/cjs_shims.js"() {
|
|
39
39
|
"use strict";
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
42
|
|
|
43
|
-
// node_modules/.pnpm/@eslint+js@9.
|
|
43
|
+
// node_modules/.pnpm/@eslint+js@9.18.0/node_modules/@eslint/js/package.json
|
|
44
44
|
var require_package = __commonJS({
|
|
45
|
-
"node_modules/.pnpm/@eslint+js@9.
|
|
45
|
+
"node_modules/.pnpm/@eslint+js@9.18.0/node_modules/@eslint/js/package.json"(exports2, module2) {
|
|
46
46
|
module2.exports = {
|
|
47
47
|
name: "@eslint/js",
|
|
48
|
-
version: "9.
|
|
48
|
+
version: "9.18.0",
|
|
49
49
|
description: "ESLint JavaScript language implementation",
|
|
50
50
|
main: "./src/index.js",
|
|
51
51
|
types: "./types/index.d.ts",
|
|
@@ -81,9 +81,9 @@ var require_package = __commonJS({
|
|
|
81
81
|
}
|
|
82
82
|
});
|
|
83
83
|
|
|
84
|
-
// node_modules/.pnpm/@eslint+js@9.
|
|
84
|
+
// node_modules/.pnpm/@eslint+js@9.18.0/node_modules/@eslint/js/src/configs/eslint-all.js
|
|
85
85
|
var require_eslint_all = __commonJS({
|
|
86
|
-
"node_modules/.pnpm/@eslint+js@9.
|
|
86
|
+
"node_modules/.pnpm/@eslint+js@9.18.0/node_modules/@eslint/js/src/configs/eslint-all.js"(exports2, module2) {
|
|
87
87
|
"use strict";
|
|
88
88
|
init_cjs_shims();
|
|
89
89
|
module2.exports = Object.freeze({
|
|
@@ -290,9 +290,9 @@ var require_eslint_all = __commonJS({
|
|
|
290
290
|
}
|
|
291
291
|
});
|
|
292
292
|
|
|
293
|
-
// node_modules/.pnpm/@eslint+js@9.
|
|
293
|
+
// node_modules/.pnpm/@eslint+js@9.18.0/node_modules/@eslint/js/src/configs/eslint-recommended.js
|
|
294
294
|
var require_eslint_recommended = __commonJS({
|
|
295
|
-
"node_modules/.pnpm/@eslint+js@9.
|
|
295
|
+
"node_modules/.pnpm/@eslint+js@9.18.0/node_modules/@eslint/js/src/configs/eslint-recommended.js"(exports2, module2) {
|
|
296
296
|
"use strict";
|
|
297
297
|
init_cjs_shims();
|
|
298
298
|
module2.exports = Object.freeze({
|
|
@@ -363,15 +363,15 @@ var require_eslint_recommended = __commonJS({
|
|
|
363
363
|
}
|
|
364
364
|
});
|
|
365
365
|
|
|
366
|
-
// node_modules/.pnpm/@eslint+js@9.
|
|
366
|
+
// node_modules/.pnpm/@eslint+js@9.18.0/node_modules/@eslint/js/src/index.js
|
|
367
367
|
var require_src = __commonJS({
|
|
368
|
-
"node_modules/.pnpm/@eslint+js@9.
|
|
368
|
+
"node_modules/.pnpm/@eslint+js@9.18.0/node_modules/@eslint/js/src/index.js"(exports2, module2) {
|
|
369
369
|
"use strict";
|
|
370
370
|
init_cjs_shims();
|
|
371
|
-
var { version } = require_package();
|
|
371
|
+
var { name, version } = require_package();
|
|
372
372
|
module2.exports = {
|
|
373
373
|
meta: {
|
|
374
|
-
name
|
|
374
|
+
name,
|
|
375
375
|
version
|
|
376
376
|
},
|
|
377
377
|
configs: {
|
|
@@ -383,12 +383,13 @@ var require_src = __commonJS({
|
|
|
383
383
|
});
|
|
384
384
|
|
|
385
385
|
// src/index.ts
|
|
386
|
-
var
|
|
387
|
-
__export(
|
|
386
|
+
var index_exports = {};
|
|
387
|
+
__export(index_exports, {
|
|
388
388
|
DEFAULT_GLOBAL_IGNORES: () => DEFAULT_GLOBAL_IGNORES,
|
|
389
|
-
eslintConfig: () => eslintConfig
|
|
389
|
+
eslintConfig: () => eslintConfig,
|
|
390
|
+
isInEditor: () => import_is_in_editor.isInEditor
|
|
390
391
|
});
|
|
391
|
-
module.exports = __toCommonJS(
|
|
392
|
+
module.exports = __toCommonJS(index_exports);
|
|
392
393
|
init_cjs_shims();
|
|
393
394
|
var import_node_fs = __toESM(require("fs"), 1);
|
|
394
395
|
var import_eslint_plugin2 = __toESM(require("@stylistic/eslint-plugin"), 1);
|
|
@@ -496,14 +497,15 @@ var ConfigEntryBuilder = class {
|
|
|
496
497
|
const errorsInsteadOfWarnings = this.internalOptions.globalOptions?.errorsInsteadOfWarnings;
|
|
497
498
|
const severityFinal = configOptions.forceSeverity ?? (severity === WARNING && (errorsInsteadOfWarnings === true || Array.isArray(errorsInsteadOfWarnings) && errorsInsteadOfWarnings.includes(ruleName)) ? ERROR : severity);
|
|
498
499
|
const ruleNameFinal = `${options?.disableAutofix ? "disable-autofix/" : ""}${ruleName}`;
|
|
499
|
-
|
|
500
|
+
configFinal.rules ||= {};
|
|
501
|
+
configFinal.rules[ruleNameFinal] = [severityFinal, ...ruleOptions || []];
|
|
500
502
|
if (options?.disableAutofix) {
|
|
501
|
-
|
|
503
|
+
configFinal.rules[ruleName] = 0;
|
|
502
504
|
}
|
|
503
505
|
if (options?.overrideBaseRule) {
|
|
504
506
|
const baseRuleName = typeof options.overrideBaseRule === "string" ? options.overrideBaseRule : ruleName.split("/").slice(1).join("/");
|
|
505
507
|
if (baseRuleName) {
|
|
506
|
-
|
|
508
|
+
configFinal.rules[baseRuleName] = 0;
|
|
507
509
|
}
|
|
508
510
|
}
|
|
509
511
|
return result;
|
|
@@ -514,11 +516,13 @@ var ConfigEntryBuilder = class {
|
|
|
514
516
|
addRule: generateAddRuleFn(),
|
|
515
517
|
addAnyRule: generateAddRuleFn(),
|
|
516
518
|
addOverrides: () => {
|
|
517
|
-
|
|
519
|
+
configFinal.rules ||= {};
|
|
520
|
+
Object.assign(configFinal.rules, this.options.overrides);
|
|
518
521
|
return result;
|
|
519
522
|
},
|
|
520
523
|
addBulkRules: (rules) => {
|
|
521
|
-
|
|
524
|
+
configFinal.rules ||= {};
|
|
525
|
+
Object.assign(configFinal.rules, rules);
|
|
522
526
|
return result;
|
|
523
527
|
}
|
|
524
528
|
};
|
|
@@ -1192,7 +1196,7 @@ var packageJsonEslintConfig = (options = {}, internalOptions = {}) => {
|
|
|
1192
1196
|
parser: import_jsonc_eslint_parser2.default
|
|
1193
1197
|
}
|
|
1194
1198
|
}
|
|
1195
|
-
).addBulkRules(import_recommended.default.rules).addRule("package-json/order-properties", ERROR, [
|
|
1199
|
+
).addBulkRules(import_recommended.default.rules).addRule("package-json/no-redundant-files", ERROR).addRule("package-json/order-properties", ERROR, [
|
|
1196
1200
|
{ order: options.order ?? "sort-package-json" }
|
|
1197
1201
|
]).addRule("package-json/repository-shorthand", ERROR, [
|
|
1198
1202
|
{ form: options.repositoryShorthand ?? "object" }
|
|
@@ -1205,6 +1209,19 @@ var packageJsonEslintConfig = (options = {}, internalOptions = {}) => {
|
|
|
1205
1209
|
return builder.getAllConfigs();
|
|
1206
1210
|
};
|
|
1207
1211
|
|
|
1212
|
+
// src/configs/perfectionist.ts
|
|
1213
|
+
init_cjs_shims();
|
|
1214
|
+
var import_eslint_plugin_perfectionist = __toESM(require("eslint-plugin-perfectionist"), 1);
|
|
1215
|
+
var perfectionistEslintConfig = (options = {}, internalOptions = {}) => {
|
|
1216
|
+
const builder = new ConfigEntryBuilder(options, internalOptions);
|
|
1217
|
+
builder.addConfig(["perfectionist", { includeDefaultFilesAndIgnores: true }], {
|
|
1218
|
+
plugins: {
|
|
1219
|
+
perfectionist: import_eslint_plugin_perfectionist.default
|
|
1220
|
+
}
|
|
1221
|
+
}).addRule("perfectionist/sort-array-includes", OFF).addRule("perfectionist/sort-classes", OFF).addRule("perfectionist/sort-decorators", OFF).addRule("perfectionist/sort-enums", OFF).addRule("perfectionist/sort-exports", OFF).addRule("perfectionist/sort-heritage-clauses", OFF).addRule("perfectionist/sort-imports", OFF).addRule("perfectionist/sort-interfaces", OFF).addRule("perfectionist/sort-intersection-types", OFF).addRule("perfectionist/sort-jsx-props", OFF).addRule("perfectionist/sort-maps", OFF).addRule("perfectionist/sort-modules", OFF).addRule("perfectionist/sort-named-exports", OFF).addRule("perfectionist/sort-named-imports", OFF).addRule("perfectionist/sort-object-types", OFF).addRule("perfectionist/sort-objects", OFF).addRule("perfectionist/sort-sets", OFF).addRule("perfectionist/sort-switch-case", OFF).addRule("perfectionist/sort-union-types", OFF).addRule("perfectionist/sort-variable-declarations", OFF).addOverrides();
|
|
1222
|
+
return builder.getAllConfigs();
|
|
1223
|
+
};
|
|
1224
|
+
|
|
1208
1225
|
// src/configs/prefer-arrow-functions.ts
|
|
1209
1226
|
init_cjs_shims();
|
|
1210
1227
|
var import_eslint_plugin_prefer_arrow_functions = __toESM(require("eslint-plugin-prefer-arrow-functions"), 1);
|
|
@@ -1212,7 +1229,7 @@ var preferArrowFunctionsEslintConfig = (options = {}, internalOptions = {}) => {
|
|
|
1212
1229
|
const builder = new ConfigEntryBuilder(options, internalOptions);
|
|
1213
1230
|
builder.addConfig(["prefer-arrow-functions", { includeDefaultFilesAndIgnores: true }], {
|
|
1214
1231
|
plugins: {
|
|
1215
|
-
//
|
|
1232
|
+
// @ts-expect-error types mismatch
|
|
1216
1233
|
"prefer-arrow-functions": import_eslint_plugin_prefer_arrow_functions.default
|
|
1217
1234
|
}
|
|
1218
1235
|
}).addRule("prefer-arrow-functions/prefer-arrow-functions", WARNING).addOverrides();
|
|
@@ -1268,13 +1285,16 @@ var securityEslintConfig = (options = {}, internalOptions = {}) => {
|
|
|
1268
1285
|
init_cjs_shims();
|
|
1269
1286
|
var import_eslint_plugin_sonarjs = __toESM(require("eslint-plugin-sonarjs"), 1);
|
|
1270
1287
|
var sonarEslintConfig = (options = {}, internalOptions = {}) => {
|
|
1288
|
+
const { enableAwsRules = true, testsRules = true } = options;
|
|
1289
|
+
const awsRulesSeverity = enableAwsRules ? ERROR : OFF;
|
|
1290
|
+
const testsRulesSeverity = testsRules ? ERROR : OFF;
|
|
1271
1291
|
const builder = new ConfigEntryBuilder(options, internalOptions);
|
|
1272
|
-
builder.addConfig(
|
|
1292
|
+
builder.addConfig("sonar/setup", {
|
|
1273
1293
|
plugins: {
|
|
1274
|
-
// @ts-expect-error small types mismatch
|
|
1275
1294
|
sonarjs: import_eslint_plugin_sonarjs.default
|
|
1276
1295
|
}
|
|
1277
|
-
})
|
|
1296
|
+
});
|
|
1297
|
+
builder.addConfig(["sonar", { includeDefaultFilesAndIgnores: true }]).addBulkRules(import_eslint_plugin_sonarjs.default.configs.recommended.rules).addRule("sonarjs/argument-type", OFF).addRule("sonarjs/array-callback-without-return", OFF).addRule("sonarjs/assertions-in-tests", testsRulesSeverity).addRule("sonarjs/aws-apigateway-public-api", awsRulesSeverity).addRule("sonarjs/aws-ec2-rds-dms-public", awsRulesSeverity).addRule("sonarjs/aws-ec2-unencrypted-ebs-volume", awsRulesSeverity).addRule("sonarjs/aws-efs-unencrypted", awsRulesSeverity).addRule("sonarjs/aws-iam-all-privileges", awsRulesSeverity).addRule("sonarjs/aws-iam-all-resources-accessible", OFF).addRule("sonarjs/aws-iam-privilege-escalation", awsRulesSeverity).addRule("sonarjs/aws-iam-public-access", awsRulesSeverity).addRule("sonarjs/aws-opensearchservice-domain", awsRulesSeverity).addRule("sonarjs/aws-rds-unencrypted-databases", awsRulesSeverity).addRule("sonarjs/aws-restricted-ip-admin-access", awsRulesSeverity).addRule("sonarjs/aws-s3-bucket-granted-access", awsRulesSeverity).addRule("sonarjs/aws-s3-bucket-insecure-http", awsRulesSeverity).addRule("sonarjs/aws-s3-bucket-public-access", awsRulesSeverity).addRule("sonarjs/aws-s3-bucket-server-encryption", OFF).addRule("sonarjs/aws-s3-bucket-versioning", awsRulesSeverity).addRule("sonarjs/aws-sagemaker-unencrypted-notebook", awsRulesSeverity).addRule("sonarjs/aws-sns-unencrypted-topics", awsRulesSeverity).addRule("sonarjs/aws-sqs-unencrypted-queue", awsRulesSeverity).addRule("sonarjs/block-scoped-var", OFF).addRule("sonarjs/call-argument-line", OFF).addRule("sonarjs/chai-determinate-assertion", testsRulesSeverity).addRule("sonarjs/class-name", OFF).addRule("sonarjs/code-eval", OFF).addRule("sonarjs/cognitive-complexity", OFF).addRule("sonarjs/concise-regex", OFF).addRule("sonarjs/conditional-indentation", OFF).addRule("sonarjs/constructor-for-side-effects", OFF).addRule("sonarjs/deprecation", OFF).addRule("sonarjs/different-types-comparison", OFF).addRule("sonarjs/disabled-timeout", testsRulesSeverity).addRule("sonarjs/duplicates-in-character-class", OFF).addRule("sonarjs/empty-string-repetition", OFF).addRule("sonarjs/fixme-tag", OFF).addRule("sonarjs/function-inside-loop", OFF).addRule("sonarjs/function-return-type", OFF).addRule("sonarjs/generator-without-yield", OFF).addRule("sonarjs/in-operator-type-error", OFF).addRule("sonarjs/inverted-assertion-arguments", testsRulesSeverity).addRule("sonarjs/label-position", OFF).addRule("sonarjs/max-switch-cases", OFF).addRule("sonarjs/misplaced-loop-counter", WARNING).addRule("sonarjs/new-operator-misuse", OFF).addRule("sonarjs/no-alphabetical-sort", OFF).addRule("sonarjs/no-array-delete", OFF).addRule("sonarjs/no-associative-arrays", OFF).addRule("sonarjs/no-async-constructor", OFF).addRule("sonarjs/no-code-after-done", testsRulesSeverity).addRule("sonarjs/no-commented-code", OFF).addRule("sonarjs/no-control-regex", OFF).addRule("sonarjs/no-dead-store", OFF).addRule("sonarjs/no-duplicate-in-composite", OFF).addRule("sonarjs/no-empty-alternatives", OFF).addRule("sonarjs/no-empty-character-class", OFF).addRule("sonarjs/no-empty-group", OFF).addRule("sonarjs/no-empty-test-file", OFF).addRule("sonarjs/no-exclusive-tests", OFF).addRule("sonarjs/no-fallthrough", OFF).addRule("sonarjs/no-for-in-iterable", ERROR).addRule("sonarjs/no-hardcoded-ip", WARNING).addRule("sonarjs/no-identical-conditions", OFF).addRule("sonarjs/no-implicit-dependencies", OFF).addRule("sonarjs/no-incomplete-assertions", testsRulesSeverity).addRule("sonarjs/no-invalid-await", OFF).addRule("sonarjs/no-invalid-regexp", OFF).addRule("sonarjs/no-labels", OFF).addRule("sonarjs/no-misleading-character-class", OFF).addRule("sonarjs/no-nested-assignment", OFF).addRule("sonarjs/no-nested-conditional", OFF).addRule("sonarjs/no-nested-functions", OFF).addRule("sonarjs/no-nested-template-literals", OFF).addRule("sonarjs/no-one-iteration-loop", OFF).addRule("sonarjs/no-primitive-wrappers", OFF).addRule("sonarjs/no-regex-spaces", OFF).addRule("sonarjs/no-same-argument-assert", testsRulesSeverity).addRule("sonarjs/no-same-line-conditional", OFF).addRule("sonarjs/no-selector-parameter", OFF).addRule("sonarjs/no-skipped-tests", OFF).addRule("sonarjs/no-try-promise", OFF).addRule("sonarjs/no-unenclosed-multiline-block", OFF).addRule("sonarjs/no-unthrown-error", OFF).addRule("sonarjs/no-unused-vars", OFF).addRule("sonarjs/no-useless-catch", OFF).addRule("sonarjs/no-useless-intersection", OFF).addRule("sonarjs/no-vue-bypass-sanitization", OFF).addRule("sonarjs/null-dereference", OFF).addRule("sonarjs/prefer-default-last", OFF).addRule("sonarjs/prefer-object-literal", ERROR).addRule("sonarjs/prefer-read-only-props", OFF).addRule("sonarjs/prefer-regexp-exec", OFF).addRule("sonarjs/production-debug", ERROR).addRule("sonarjs/pseudo-random", OFF).addRule("sonarjs/redundant-type-aliases", OFF).addRule("sonarjs/regex-complexity", WARNING, [{ threshold: 40 }]).addRule("sonarjs/single-char-in-character-classes", OFF).addRule("sonarjs/single-character-alternation", OFF).addRule("sonarjs/slow-regex", OFF).addRule("sonarjs/stable-tests", testsRulesSeverity).addRule("sonarjs/strings-comparison", WARNING).addRule("sonarjs/super-invocation", OFF).addRule("sonarjs/table-header", WARNING).addRule("sonarjs/table-header-reference", WARNING).addRule("sonarjs/todo-tag", OFF).addRule("sonarjs/unused-import", OFF).addRule("sonarjs/unverified-hostname", ERROR).addRule("sonarjs/updated-const-var", OFF).addRule("sonarjs/updated-loop-counter", WARNING).addRule("sonarjs/use-type-alias", WARNING).addRule("sonarjs/void-use", OFF).addOverrides();
|
|
1278
1298
|
return builder.getAllConfigs();
|
|
1279
1299
|
};
|
|
1280
1300
|
|
|
@@ -1366,32 +1386,40 @@ var tomlEslintConfig = (options = {}, internalOptions = {}) => {
|
|
|
1366
1386
|
init_cjs_shims();
|
|
1367
1387
|
var import_eslint_plugin_no_type_assertion = __toESM(require("eslint-plugin-no-type-assertion"), 1);
|
|
1368
1388
|
var import_typescript_eslint = require("typescript-eslint");
|
|
1389
|
+
var TS_FILES_DEFAULT = [GLOB_TS, GLOB_TSX];
|
|
1369
1390
|
var tsEslintConfig = (options = {}, internalOptions = {}) => {
|
|
1370
|
-
const
|
|
1371
|
-
const
|
|
1372
|
-
const
|
|
1391
|
+
const extraFilesNONTypeAware = [];
|
|
1392
|
+
const extraFilesTypeAware = [];
|
|
1393
|
+
const extraFilesToIgnoreNONTypeAware = [];
|
|
1373
1394
|
const extraFilesToIgnoreTypeAware = [
|
|
1374
1395
|
GLOB_MARKDOWN_SUPPORTED_CODE_BLOCKS
|
|
1375
1396
|
];
|
|
1376
1397
|
const { vueOptions } = internalOptions;
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
const
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1398
|
+
const enforceTsInVueOptions = vueOptions?.enforceTypescriptInScriptSection;
|
|
1399
|
+
if (enforceTsInVueOptions) {
|
|
1400
|
+
const tsInVueOptions = typeof enforceTsInVueOptions === "object" ? enforceTsInVueOptions : { files: vueOptions.files || [GLOB_VUE] };
|
|
1401
|
+
if (tsInVueOptions.typescriptRules !== false) {
|
|
1402
|
+
const vueFilesWithTs = tsInVueOptions.files || [];
|
|
1403
|
+
extraFilesNONTypeAware.push(...vueFilesWithTs);
|
|
1404
|
+
if (tsInVueOptions.typescriptRules !== "only-non-type-aware") {
|
|
1405
|
+
extraFilesTypeAware.push(...vueFilesWithTs);
|
|
1406
|
+
}
|
|
1407
|
+
extraFilesToIgnoreNONTypeAware.push(...tsInVueOptions.ignores || []);
|
|
1408
|
+
extraFilesToIgnoreTypeAware.push(...tsInVueOptions.ignores || []);
|
|
1409
|
+
}
|
|
1383
1410
|
}
|
|
1384
|
-
const
|
|
1385
|
-
const
|
|
1386
|
-
const
|
|
1387
|
-
|
|
1388
|
-
...
|
|
1411
|
+
const filesNONTypeAwareDefault = [...options.files || TS_FILES_DEFAULT];
|
|
1412
|
+
const filesNONTypeAware = [...filesNONTypeAwareDefault, ...extraFilesNONTypeAware];
|
|
1413
|
+
const ignoresNONTypeAware = [...options.ignores || [], ...extraFilesToIgnoreNONTypeAware];
|
|
1414
|
+
const filesTypeAware = options.filesTypeAware === false ? [] : [
|
|
1415
|
+
...Array.isArray(options.filesTypeAware) ? options.filesTypeAware : filesNONTypeAwareDefault,
|
|
1416
|
+
// Lint the same files, excluding extra non-TA ones
|
|
1417
|
+
...extraFilesTypeAware
|
|
1389
1418
|
];
|
|
1390
1419
|
const ignoresTypeAware = [
|
|
1391
1420
|
...options.ignoresTypeAware === true ? options.ignores || [] : options.ignoresTypeAware || [],
|
|
1392
1421
|
...extraFilesToIgnoreTypeAware
|
|
1393
1422
|
];
|
|
1394
|
-
const filesAll = [...onlyTsFiles, ...filesTypeAware];
|
|
1395
1423
|
const tsVersion = options.typescriptVersion ? Number.parseFloat(options.typescriptVersion) : void 0;
|
|
1396
1424
|
const generateBaseOptions = (isTypeAware) => ({
|
|
1397
1425
|
languageOptions: {
|
|
@@ -1418,8 +1446,8 @@ var tsEslintConfig = (options = {}, internalOptions = {}) => {
|
|
|
1418
1446
|
const noUnsafeRulesSeverity = options.disableNoUnsafeRules ? OFF : WARNING;
|
|
1419
1447
|
builder.addConfig("ts/rules-regular", {
|
|
1420
1448
|
...generateBaseOptions(false),
|
|
1421
|
-
files:
|
|
1422
|
-
...
|
|
1449
|
+
files: filesNONTypeAware,
|
|
1450
|
+
...ignoresNONTypeAware.length > 0 && { ignores: ignoresNONTypeAware }
|
|
1423
1451
|
}).addBulkRules(
|
|
1424
1452
|
import_typescript_eslint.configs.strict.reduce(
|
|
1425
1453
|
(result, config) => Object.assign(result, config.rules),
|
|
@@ -1456,61 +1484,72 @@ var tsEslintConfig = (options = {}, internalOptions = {}) => {
|
|
|
1456
1484
|
).addRule("@typescript-eslint/no-use-before-define", ERROR, RULE_NO_USE_BEFORE_DEFINE_OPTIONS, {
|
|
1457
1485
|
overrideBaseRule: true
|
|
1458
1486
|
}).addRule("@typescript-eslint/no-useless-empty-export", ERROR).addAnyRule("no-useless-constructor", OFF).addAnyRule("dot-notation", OFF).addOverrides();
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
ignoreArrowShorthand: true
|
|
1476
|
-
}
|
|
1477
|
-
]).addRule("@typescript-eslint/no-deprecated", WARNING).addRule("@typescript-eslint/no-floating-promises", ERROR, [
|
|
1478
|
-
{
|
|
1479
|
-
checkThenables: true,
|
|
1480
|
-
ignoreVoid: true
|
|
1481
|
-
// Default
|
|
1482
|
-
}
|
|
1483
|
-
]).addRule("@typescript-eslint/no-implied-eval", ERROR, [], { overrideBaseRule: true }).addRule(
|
|
1484
|
-
"@typescript-eslint/no-unnecessary-condition",
|
|
1485
|
-
ERROR,
|
|
1486
|
-
[
|
|
1487
|
+
if (filesTypeAware.length > 0) {
|
|
1488
|
+
builder.addConfig("ts/rules-type-aware", {
|
|
1489
|
+
...generateBaseOptions(true),
|
|
1490
|
+
files: filesTypeAware,
|
|
1491
|
+
...ignoresTypeAware.length > 0 && { ignores: ignoresTypeAware }
|
|
1492
|
+
}).addBulkRules(
|
|
1493
|
+
import_typescript_eslint.configs.strictTypeCheckedOnly.reduce(
|
|
1494
|
+
(result, config) => Object.assign(result, config.rules),
|
|
1495
|
+
{}
|
|
1496
|
+
)
|
|
1497
|
+
).addBulkRules(
|
|
1498
|
+
import_typescript_eslint.configs.stylisticTypeCheckedOnly.reduce(
|
|
1499
|
+
(result, config) => Object.assign(result, config.rules),
|
|
1500
|
+
{}
|
|
1501
|
+
)
|
|
1502
|
+
).addRule("@typescript-eslint/no-confusing-void-expression", ERROR, [
|
|
1487
1503
|
{
|
|
1488
|
-
|
|
1489
|
-
checkTypePredicates: true
|
|
1490
|
-
// >=8.8.0
|
|
1504
|
+
ignoreArrowShorthand: true
|
|
1491
1505
|
}
|
|
1492
|
-
],
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
ERROR,
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1506
|
+
]).addRule("@typescript-eslint/no-deprecated", WARNING).addRule("@typescript-eslint/no-floating-promises", ERROR, [
|
|
1507
|
+
{
|
|
1508
|
+
checkThenables: true,
|
|
1509
|
+
ignoreVoid: true
|
|
1510
|
+
// Default
|
|
1511
|
+
}
|
|
1512
|
+
]).addRule("@typescript-eslint/no-implied-eval", ERROR, [], { overrideBaseRule: true }).addRule("@typescript-eslint/no-misused-spread", ERROR).addRule(
|
|
1513
|
+
"@typescript-eslint/no-unnecessary-condition",
|
|
1514
|
+
ERROR,
|
|
1515
|
+
[
|
|
1516
|
+
{
|
|
1517
|
+
allowConstantLoopConditions: true,
|
|
1518
|
+
checkTypePredicates: true
|
|
1519
|
+
// >=8.8.0
|
|
1520
|
+
}
|
|
1521
|
+
],
|
|
1522
|
+
{ disableAutofix: true }
|
|
1523
|
+
).addRule("@typescript-eslint/no-unnecessary-type-arguments", ERROR, [], {
|
|
1524
|
+
disableAutofix: true
|
|
1525
|
+
}).addRule("@typescript-eslint/no-unsafe-argument", noUnsafeRulesSeverity).addRule("@typescript-eslint/no-unsafe-assignment", noUnsafeRulesSeverity).addRule("@typescript-eslint/no-unsafe-call", noUnsafeRulesSeverity).addRule("@typescript-eslint/no-unsafe-enum-comparison", noUnsafeRulesSeverity).addRule("@typescript-eslint/no-unsafe-member-access", noUnsafeRulesSeverity).addRule("@typescript-eslint/no-unsafe-return", noUnsafeRulesSeverity).addAnyRule("no-throw-literal", OFF).addRule("@typescript-eslint/prefer-promise-reject-errors", ERROR, [], {
|
|
1526
|
+
overrideBaseRule: true
|
|
1527
|
+
}).addRule("@typescript-eslint/require-await", ERROR, [], { overrideBaseRule: true }).addRule("@typescript-eslint/restrict-template-expressions", ERROR, [
|
|
1528
|
+
{ allowAny: false, allowRegExp: false }
|
|
1529
|
+
]).addRule(
|
|
1530
|
+
"@typescript-eslint/dot-notation",
|
|
1531
|
+
ERROR,
|
|
1532
|
+
[{ allowIndexSignaturePropertyAccess: true }],
|
|
1533
|
+
{ overrideBaseRule: true }
|
|
1534
|
+
).addAnyRule("unicorn/prefer-includes", OFF).addRule("@typescript-eslint/prefer-nullish-coalescing", OFF).addRule("@typescript-eslint/prefer-regexp-exec", OFF).addRule("@typescript-eslint/prefer-string-starts-ends-with", ERROR, [
|
|
1535
|
+
{ allowSingleElementEquality: "always" }
|
|
1536
|
+
]).addRule("@typescript-eslint/consistent-type-exports", ERROR, [
|
|
1537
|
+
{ fixMixedExportsWithInlineTypeSpecifier: true }
|
|
1538
|
+
]).addRule(
|
|
1539
|
+
"@typescript-eslint/prefer-destructuring",
|
|
1540
|
+
ERROR,
|
|
1541
|
+
RULE_PREFER_DESTRUCTURING_OPTIONS,
|
|
1542
|
+
{
|
|
1543
|
+
overrideBaseRule: true
|
|
1544
|
+
}
|
|
1545
|
+
).addAnyRule("unicorn/prefer-array-find", OFF).addRule("@typescript-eslint/prefer-readonly", ERROR).addAnyRule("no-return-await", OFF).addRule("@typescript-eslint/return-await", ERROR, ["always"]).addRule("@typescript-eslint/switch-exhaustiveness-check", ERROR).addBulkRules(options.overridesTypeAware);
|
|
1546
|
+
}
|
|
1508
1547
|
builder.addConfig("ts/disable-handled-by-ts-compiler-rules", {
|
|
1509
|
-
files:
|
|
1548
|
+
files: [...TS_FILES_DEFAULT, ...filesNONTypeAware, ...filesTypeAware]
|
|
1510
1549
|
}).addAnyRule("constructor-super", OFF).addAnyRule("getter-return", OFF).addAnyRule("no-const-assign", OFF).addAnyRule("no-dupe-args", OFF).addAnyRule("no-dupe-class-members", OFF).addAnyRule("no-dupe-keys", OFF).addAnyRule("no-func-assign", OFF).addAnyRule("no-new-native-nonconstructor", OFF).addAnyRule("no-obj-calls", OFF).addAnyRule("no-setter-return", OFF).addAnyRule("no-this-before-super", OFF).addAnyRule("no-undef", OFF).addAnyRule("no-unsafe-negation", OFF).addAnyRule("no-duplicate-imports", OFF);
|
|
1511
1550
|
builder.addConfig("ts/dts", {
|
|
1512
1551
|
files: ["**/*.d.?([cm])ts"]
|
|
1513
|
-
}).addRule("@typescript-eslint/consistent-indexed-object-style", OFF).addRule("@typescript-eslint/method-signature-style", OFF).addRule("@typescript-eslint/no-empty-object-type", OFF).addRule("@typescript-eslint/no-explicit-any", OFF).addRule("@typescript-eslint/no-shadow", OFF).addRule("@typescript-eslint/no-unnecessary-type-parameters", OFF).addRule("@typescript-eslint/no-unused-vars", OFF).addRule("@typescript-eslint/no-use-before-define", OFF).addAnyRule("import/newline-after-import", OFF).addAnyRule("import/no-default-export", OFF).addAnyRule("vars-on-top", OFF).addAnyRule("no-var", OFF);
|
|
1552
|
+
}).addRule("@typescript-eslint/consistent-indexed-object-style", OFF).addRule("@typescript-eslint/method-signature-style", OFF).addRule("@typescript-eslint/no-empty-object-type", OFF).addRule("@typescript-eslint/no-explicit-any", OFF).addRule("@typescript-eslint/no-shadow", OFF).addRule("@typescript-eslint/no-unnecessary-type-parameters", OFF).addRule("@typescript-eslint/no-unused-vars", OFF).addRule("@typescript-eslint/no-use-before-define", OFF).addAnyRule("import/newline-after-import", OFF).addAnyRule("import/no-default-export", OFF).addAnyRule("vars-on-top", OFF).addAnyRule("no-var", OFF).addAnyRule("sonarjs/no-redundant-optional", OFF);
|
|
1514
1553
|
if (options.noTypeAssertion) {
|
|
1515
1554
|
builder.addConfig("ts/no-type-assertion", {
|
|
1516
1555
|
plugins: {
|
|
@@ -1941,7 +1980,12 @@ var yamlEslintConfig = (options = {}, internalOptions = {}) => {
|
|
|
1941
1980
|
};
|
|
1942
1981
|
|
|
1943
1982
|
// src/index.ts
|
|
1944
|
-
var
|
|
1983
|
+
var import_is_in_editor = require("is-in-editor");
|
|
1984
|
+
var RULES_NOT_TO_DISABLE_IN_CONFIG_PRETTIER = /* @__PURE__ */ new Set([
|
|
1985
|
+
"curly",
|
|
1986
|
+
"unicorn/template-indent",
|
|
1987
|
+
"@stylistic/quotes"
|
|
1988
|
+
]);
|
|
1945
1989
|
var eslintConfig = (options = {}) => {
|
|
1946
1990
|
const globalIgnores = [
|
|
1947
1991
|
...options.overrideIgnores ? [] : DEFAULT_GLOBAL_IGNORES,
|
|
@@ -2052,6 +2096,10 @@ var eslintConfig = (options = {}) => {
|
|
|
2052
2096
|
const packageJsonOptions = {
|
|
2053
2097
|
...assignOptions(configsOptions, "packageJson")
|
|
2054
2098
|
};
|
|
2099
|
+
const isPerfectionistEnabled = Boolean(configsOptions.perfectionist ?? false);
|
|
2100
|
+
const perfectionistOptions = {
|
|
2101
|
+
...assignOptions(configsOptions, "perfectionist")
|
|
2102
|
+
};
|
|
2055
2103
|
const internalOptions = {
|
|
2056
2104
|
globalOptions: options,
|
|
2057
2105
|
isTypescriptEnabled,
|
|
@@ -2109,6 +2157,7 @@ var eslintConfig = (options = {}) => {
|
|
|
2109
2157
|
isTomlEnabled && tomlEslintConfig(tomlOptions, internalOptions),
|
|
2110
2158
|
isJsoncEnabled && jsoncEslintConfig(jsoncOptions, internalOptions),
|
|
2111
2159
|
isPackageJsonEnabled && packageJsonEslintConfig(packageJsonOptions, internalOptions),
|
|
2160
|
+
isPerfectionistEnabled && perfectionistEslintConfig(perfectionistOptions, internalOptions),
|
|
2112
2161
|
isTypescriptEnabled && tsEslintConfig(tsOptions, internalOptions),
|
|
2113
2162
|
// Must come after all rulesets for vanilla JS
|
|
2114
2163
|
isVueEnabled && vueEslintConfig(vueOptions, internalOptions),
|
|
@@ -2152,5 +2201,6 @@ var eslintConfig = (options = {}) => {
|
|
|
2152
2201
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2153
2202
|
0 && (module.exports = {
|
|
2154
2203
|
DEFAULT_GLOBAL_IGNORES,
|
|
2155
|
-
eslintConfig
|
|
2204
|
+
eslintConfig,
|
|
2205
|
+
isInEditor
|
|
2156
2206
|
});
|