eslint-config-un 0.0.2 → 0.0.4
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 +17 -5
- package/dist/index.cjs +54 -30
- package/dist/index.d.cts +25125 -7
- package/dist/index.d.ts +25125 -7
- package/dist/index.js +60 -36
- package/package.json +39 -36
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# eslint-config-un
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/eslint-config-un)
|
|
4
4
|
|
|
5
5
|
Grown out of the personal collection of rules, an ESLint config aspiring to cover as many rules as possible, be reasonably strict and easily configurable. Only supports ESLint 9 and the flat config format.
|
|
6
6
|
|
|
@@ -14,7 +14,7 @@ yarn add -D eslint-config-un
|
|
|
14
14
|
|
|
15
15
|
## List of configs
|
|
16
16
|
|
|
17
|
-
Includes the following
|
|
17
|
+
Includes the rules from the following configs & plugins:
|
|
18
18
|
- [Vanilla ESLint rules](https://eslint.org/docs/latest/rules/)
|
|
19
19
|
- [typescript-eslint](https://typescript-eslint.io/rules/)
|
|
20
20
|
- [vue](https://eslint.vuejs.org/rules/) (+ [vuejs-accessibility](https://www.npmjs.com/package/eslint-plugin-vuejs-accessibility) and [pinia](https://www.npmjs.com/package/eslint-plugin-pinia))
|
|
@@ -33,6 +33,7 @@ Includes the following rules, configs & plugins:
|
|
|
33
33
|
- Automatically detects the presence of `typescript`, `vue`, `nuxt` and `pinia` packages and enables corresponding configurations (which can also be enabled or disabled explicitly).
|
|
34
34
|
- Every block of rules supports `overrides` for rules.
|
|
35
35
|
- Designed to be used separately from Prettier: *almost* all the rules potentially conflicting with Prettier are disabled *by default*.
|
|
36
|
+
- Written in TypeScript so all the options are typed.
|
|
36
37
|
|
|
37
38
|
## Usage
|
|
38
39
|
|
|
@@ -47,11 +48,22 @@ export default eslintConfig({
|
|
|
47
48
|
});
|
|
48
49
|
```
|
|
49
50
|
|
|
50
|
-
##
|
|
51
|
+
## Notes
|
|
51
52
|
|
|
53
|
+
- You don't need to install any of the mentioned configs/plugins as they are all the dependencies of this package.
|
|
52
54
|
- This package has a peer dependency of `eslint>=9`. Please ensure you have installed the correct version. Some package managers are installing non-optional peer dependencies automatically.
|
|
53
55
|
- Packages lookup (such as `typescript` or `vue`) is performed using [`local-pkg`](https://www.npmjs.com/package/local-pkg).
|
|
54
56
|
- Type-checked, or type-aware TypeScript rules are *enabled* by default which are known to be performance-demanding. It's just a little heads-up and you should make your own decision whether to keep them enabled. [More about type-aware linting](https://typescript-eslint.io/getting-started/typed-linting).
|
|
55
|
-
- By default, TypeScript rules will
|
|
57
|
+
- By default, TypeScript rules will be enabled in `.vue` files if `enforceTypescriptInScriptSection` is set to true in vue's config options which in turn is *automatically* set to true if `typescript` package found installed. If you have `.vue` files authored in both TypeScript and JavaScript, use `enforceTypescriptInScriptSection.{files,ignores}` to manually specify TS & JS Vue components respectively. It is not currently possible to apply different ESLint rules depending on the value of `lang` attribute of `<script>` SFC section.
|
|
56
58
|
- All plugins listed above are enabled by default or enabled automatically under certain conditions, but there is one that is *disabled* by default: `security`.
|
|
57
|
-
- 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
|
|
59
|
+
- 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.
|
|
60
|
+
|
|
61
|
+
## Troubleshooting
|
|
62
|
+
|
|
63
|
+
### TypeError: Key `rules`: Key `disable-autofix/<rule name>`: Could not find `<rule name>` in plugin `disable-autofix`
|
|
64
|
+
|
|
65
|
+
We disable autofix for some rules in this package via `eslint-plugin-disable-autofix`. However, it requires all the configs/plugins packages to be hoisted (installed to the top level of `node_modules`). You might need to reinstall this package, re-create `node_modules` directory (do not delete your lock file!) or set `shamefully-hoist=true` in your `.npmrc` if you're using pnpm. Sometimes you'll need to manually install some packages refused to be hoisted (happens with `@typescript-eslint/eslint-plugin`: `npm i @typescript-eslint/eslint-plugin -D --legacy-peer-deps`);
|
|
66
|
+
|
|
67
|
+
### TypeError: Key `languageOptions`: Key `globals`: Global `AudioWorkletGlobalScope ` has leading or trailing whitespace.
|
|
68
|
+
|
|
69
|
+
Install `globals` package as a dev dependency.
|
package/dist/index.cjs
CHANGED
|
@@ -33,16 +33,16 @@ 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.1.
|
|
36
|
+
// node_modules/.pnpm/tsup@8.2.2_jiti@1.21.6_postcss@8.4.39_tsx@4.16.2_typescript@5.5.4_yaml@2.4.5/node_modules/tsup/assets/cjs_shims.js
|
|
37
37
|
var init_cjs_shims = __esm({
|
|
38
|
-
"node_modules/.pnpm/tsup@8.1.
|
|
38
|
+
"node_modules/.pnpm/tsup@8.2.2_jiti@1.21.6_postcss@8.4.39_tsx@4.16.2_typescript@5.5.4_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.7.0/node_modules/@eslint/js/src/configs/eslint-all.js
|
|
44
44
|
var require_eslint_all = __commonJS({
|
|
45
|
-
"node_modules/.pnpm/@eslint+js@9.
|
|
45
|
+
"node_modules/.pnpm/@eslint+js@9.7.0/node_modules/@eslint/js/src/configs/eslint-all.js"(exports2, module2) {
|
|
46
46
|
"use strict";
|
|
47
47
|
init_cjs_shims();
|
|
48
48
|
module2.exports = Object.freeze({
|
|
@@ -249,9 +249,9 @@ var require_eslint_all = __commonJS({
|
|
|
249
249
|
}
|
|
250
250
|
});
|
|
251
251
|
|
|
252
|
-
// node_modules/.pnpm/@eslint+js@9.
|
|
252
|
+
// node_modules/.pnpm/@eslint+js@9.7.0/node_modules/@eslint/js/src/configs/eslint-recommended.js
|
|
253
253
|
var require_eslint_recommended = __commonJS({
|
|
254
|
-
"node_modules/.pnpm/@eslint+js@9.
|
|
254
|
+
"node_modules/.pnpm/@eslint+js@9.7.0/node_modules/@eslint/js/src/configs/eslint-recommended.js"(exports2, module2) {
|
|
255
255
|
"use strict";
|
|
256
256
|
init_cjs_shims();
|
|
257
257
|
module2.exports = Object.freeze({
|
|
@@ -322,9 +322,9 @@ var require_eslint_recommended = __commonJS({
|
|
|
322
322
|
}
|
|
323
323
|
});
|
|
324
324
|
|
|
325
|
-
// node_modules/.pnpm/@eslint+js@9.
|
|
325
|
+
// node_modules/.pnpm/@eslint+js@9.7.0/node_modules/@eslint/js/src/index.js
|
|
326
326
|
var require_src = __commonJS({
|
|
327
|
-
"node_modules/.pnpm/@eslint+js@9.
|
|
327
|
+
"node_modules/.pnpm/@eslint+js@9.7.0/node_modules/@eslint/js/src/index.js"(exports2, module2) {
|
|
328
328
|
"use strict";
|
|
329
329
|
init_cjs_shims();
|
|
330
330
|
module2.exports = {
|
|
@@ -343,7 +343,9 @@ __export(src_exports, {
|
|
|
343
343
|
});
|
|
344
344
|
module.exports = __toCommonJS(src_exports);
|
|
345
345
|
init_cjs_shims();
|
|
346
|
+
var import_node_fs = __toESM(require("fs"), 1);
|
|
346
347
|
var import_eslint_plugin = __toESM(require("@stylistic/eslint-plugin"), 1);
|
|
348
|
+
var import_eslint_config_flat_gitignore = __toESM(require("eslint-config-flat-gitignore"), 1);
|
|
347
349
|
var import_eslint_config_prettier = __toESM(require("eslint-config-prettier"), 1);
|
|
348
350
|
var import_eslint_plugin_disable_autofix = __toESM(require("eslint-plugin-disable-autofix"), 1);
|
|
349
351
|
var import_eslint_plugin_unicorn2 = __toESM(require("eslint-plugin-unicorn"), 1);
|
|
@@ -451,7 +453,9 @@ var importEslintConfig = (options = {}, internalOptions = {}) => {
|
|
|
451
453
|
"import/no-unresolved": [
|
|
452
454
|
ERROR,
|
|
453
455
|
{
|
|
454
|
-
...noUnresolvedIgnores.length > 0 && {
|
|
456
|
+
...noUnresolvedIgnores.length > 0 && {
|
|
457
|
+
ignore: noUnresolvedIgnores
|
|
458
|
+
}
|
|
455
459
|
}
|
|
456
460
|
],
|
|
457
461
|
// 'import/no-unused-modules': OFF,
|
|
@@ -609,13 +613,11 @@ var jsEslintConfig = (options = {}, internalOptions = {}) => {
|
|
|
609
613
|
"no-unreachable-loop": ERROR,
|
|
610
614
|
"no-use-before-define": [ERROR, RULE_NO_USE_BEFORE_DEFINE_OPTIONS],
|
|
611
615
|
"no-useless-assignment": ERROR,
|
|
612
|
-
// @ts-expect-error no options typings
|
|
613
616
|
"require-atomic-updates": [ERROR, { allowProperties: true }],
|
|
614
617
|
// 🔵 Not in recommended - Suggestions
|
|
615
618
|
"accessor-pairs": ERROR,
|
|
616
619
|
// 'arrow-body-style': OFF,
|
|
617
620
|
"block-scoped-var": ERROR,
|
|
618
|
-
// @ts-expect-error incorrect typings
|
|
619
621
|
camelcase: [ERROR, RULE_CAMELCASE_OPTIONS],
|
|
620
622
|
// 'capitalized-comments': OFF,
|
|
621
623
|
"class-methods-use-this": ERROR,
|
|
@@ -642,7 +644,6 @@ var jsEslintConfig = (options = {}, internalOptions = {}) => {
|
|
|
642
644
|
// 'id-match': OFF,
|
|
643
645
|
// 'init-declarations': OFF,
|
|
644
646
|
"logical-assignment-operators": [ERROR, "always", { enforceForIfStatements: true }],
|
|
645
|
-
// @ts-expect-error incorrect typings
|
|
646
647
|
"max-classes-per-file": [ERROR, { ignoreExpressions: true, max: 2 }],
|
|
647
648
|
// 'max-depth': OFF,
|
|
648
649
|
// 'max-lines': OFF,
|
|
@@ -727,7 +728,6 @@ var jsEslintConfig = (options = {}, internalOptions = {}) => {
|
|
|
727
728
|
"no-useless-rename": ERROR,
|
|
728
729
|
"no-useless-return": ERROR,
|
|
729
730
|
"no-var": ERROR,
|
|
730
|
-
// @ts-expect-error incorrect typings
|
|
731
731
|
"no-void": [ERROR, { allowAsStatement: true }],
|
|
732
732
|
// 'no-warning-comments': OFF,
|
|
733
733
|
"object-shorthand": ERROR,
|
|
@@ -740,7 +740,7 @@ var jsEslintConfig = (options = {}, internalOptions = {}) => {
|
|
|
740
740
|
allowUnboundThis: true
|
|
741
741
|
}
|
|
742
742
|
],
|
|
743
|
-
"prefer-const": [ERROR, { ignoreReadBeforeAssign: true }],
|
|
743
|
+
"prefer-const": [ERROR, { destructuring: "all", ignoreReadBeforeAssign: true }],
|
|
744
744
|
"prefer-destructuring": [ERROR, RULE_PREFER_DESTRUCTURING_OPTIONS],
|
|
745
745
|
"prefer-exponentiation-operator": ERROR,
|
|
746
746
|
// 'prefer-named-capture-group': OFF,
|
|
@@ -1181,10 +1181,26 @@ var import_typescript_eslint = require("typescript-eslint");
|
|
|
1181
1181
|
var overrideBaseRule2 = genRuleOverrideFn("@typescript-eslint");
|
|
1182
1182
|
var tsEslintConfig = (options = {}, internalOptions = {}) => {
|
|
1183
1183
|
const onlyTsFiles = [GLOB_TS, GLOB_TSX];
|
|
1184
|
-
const
|
|
1185
|
-
const
|
|
1186
|
-
const
|
|
1187
|
-
|
|
1184
|
+
const extraFiles = [];
|
|
1185
|
+
const extraFilesToIgnore = [];
|
|
1186
|
+
const { vueOptions } = internalOptions;
|
|
1187
|
+
if (vueOptions) {
|
|
1188
|
+
const { enforceTypescriptInScriptSection } = vueOptions;
|
|
1189
|
+
const vueFilesWithTs = typeof enforceTypescriptInScriptSection === "object" ? enforceTypescriptInScriptSection.files || [] : enforceTypescriptInScriptSection ? vueOptions.files || [GLOB_VUE] : [];
|
|
1190
|
+
const vueFilesWithoutTs = typeof enforceTypescriptInScriptSection === "object" ? enforceTypescriptInScriptSection.ignores || [] : [];
|
|
1191
|
+
extraFiles.push(...vueFilesWithTs);
|
|
1192
|
+
extraFilesToIgnore.push(...vueFilesWithoutTs);
|
|
1193
|
+
}
|
|
1194
|
+
const filesNonTypeAware = [...options.files || onlyTsFiles, ...extraFiles];
|
|
1195
|
+
const ignoresNonTypeAware = [...options.ignores || [], ...extraFilesToIgnore];
|
|
1196
|
+
const filesTypeAware = [
|
|
1197
|
+
...options.filesTypeAware === true || options.filesTypeAware == null ? onlyTsFiles : options.filesTypeAware || [],
|
|
1198
|
+
...extraFiles
|
|
1199
|
+
];
|
|
1200
|
+
const ignoresTypeAware = [
|
|
1201
|
+
...options.ignoresTypeAware === true ? options.ignores || [] : options.ignoresTypeAware || [],
|
|
1202
|
+
...extraFilesToIgnore
|
|
1203
|
+
];
|
|
1188
1204
|
const filesAll = [...onlyTsFiles, ...filesTypeAware];
|
|
1189
1205
|
const tsVersion = options.typescriptVersion ? Number.parseFloat(options.typescriptVersion) : void 0;
|
|
1190
1206
|
const generateBaseOptions = (isTypeAware) => ({
|
|
@@ -1411,16 +1427,14 @@ var tsEslintConfig = (options = {}, internalOptions = {}) => {
|
|
|
1411
1427
|
{
|
|
1412
1428
|
...generateBaseOptions(false),
|
|
1413
1429
|
files: filesNonTypeAware,
|
|
1414
|
-
...
|
|
1430
|
+
...ignoresNonTypeAware.length > 0 && { ignores: ignoresNonTypeAware },
|
|
1415
1431
|
rules: typescriptRulesRegular,
|
|
1416
1432
|
name: genFlatConfigEntryName("ts/regular-rules")
|
|
1417
1433
|
},
|
|
1418
1434
|
filesTypeAware.length > 0 && {
|
|
1419
1435
|
...generateBaseOptions(true),
|
|
1420
1436
|
files: filesTypeAware,
|
|
1421
|
-
...
|
|
1422
|
-
ignores: options.ignoresTypeAware === true ? options.ignores || [] : options.ignoresTypeAware
|
|
1423
|
-
},
|
|
1437
|
+
...ignoresTypeAware.length > 0 && { ignores: ignoresTypeAware },
|
|
1424
1438
|
rules: typescriptRulesTypeAware,
|
|
1425
1439
|
name: genFlatConfigEntryName("ts/type-aware-rules")
|
|
1426
1440
|
},
|
|
@@ -1687,6 +1701,7 @@ var vueEslintConfig = (options, internalOptions = {}) => {
|
|
|
1687
1701
|
const isLess2_5 = isVue2 && vueMajorAndMinorVersion < 2.5;
|
|
1688
1702
|
const isLess2_6 = isVue2 && vueMajorAndMinorVersion < 2.6;
|
|
1689
1703
|
const isLess3_1 = vueMajorAndMinorVersion < 3.1;
|
|
1704
|
+
const isNuxtEnabled = Boolean(options.nuxtMajorVersion);
|
|
1690
1705
|
const recommendedRules = (
|
|
1691
1706
|
// TODO report to Prettier?
|
|
1692
1707
|
// prettier-ignore
|
|
@@ -1845,7 +1860,7 @@ var vueEslintConfig = (options, internalOptions = {}) => {
|
|
|
1845
1860
|
{
|
|
1846
1861
|
script: {
|
|
1847
1862
|
lang: "ts",
|
|
1848
|
-
|
|
1863
|
+
...enforceTypescriptInScriptSection !== true && { allowNoLang: true }
|
|
1849
1864
|
}
|
|
1850
1865
|
}
|
|
1851
1866
|
],
|
|
@@ -1915,8 +1930,7 @@ var vueEslintConfig = (options, internalOptions = {}) => {
|
|
|
1915
1930
|
// 'vue/new-line-between-multi-line-property': OFF,
|
|
1916
1931
|
// 'vue/next-tick-style': OFF,
|
|
1917
1932
|
// 'vue/no-bare-strings-in-template': OFF,
|
|
1918
|
-
//
|
|
1919
|
-
"vue/no-boolean-default": [ERROR, "default-false"],
|
|
1933
|
+
// 'vue/no-boolean-default': OFF,
|
|
1920
1934
|
...isVue3 && { "vue/no-deprecated-model-definition": ERROR },
|
|
1921
1935
|
"vue/no-duplicate-attr-inheritance": ERROR,
|
|
1922
1936
|
"vue/no-empty-component-block": ERROR,
|
|
@@ -1943,10 +1957,15 @@ var vueEslintConfig = (options, internalOptions = {}) => {
|
|
|
1943
1957
|
"vue/no-undef-components": [
|
|
1944
1958
|
ERROR,
|
|
1945
1959
|
{
|
|
1946
|
-
ignorePatterns: [
|
|
1960
|
+
ignorePatterns: [
|
|
1961
|
+
"router-link",
|
|
1962
|
+
"router-view",
|
|
1963
|
+
isNuxtEnabled && /^(lazy-)?(nuxt-|client-only$)/,
|
|
1964
|
+
...options.knownComponentNames || []
|
|
1965
|
+
].flat().filter((v) => v !== false)
|
|
1947
1966
|
}
|
|
1948
1967
|
],
|
|
1949
|
-
// TODO enable if script setup is enforced?
|
|
1968
|
+
// TODO enable if script setup is enforced and only in JS?
|
|
1950
1969
|
// 'vue/no-undef-properties': OFF,
|
|
1951
1970
|
"vue/no-unsupported-features": [ERROR, { version: `^${options.fullVersion || majorVersion}` }],
|
|
1952
1971
|
"vue/no-unused-emit-declarations": ERROR,
|
|
@@ -2052,7 +2071,6 @@ var vueEslintConfig = (options, internalOptions = {}) => {
|
|
|
2052
2071
|
// False positives in script setup
|
|
2053
2072
|
...options.overrides
|
|
2054
2073
|
};
|
|
2055
|
-
const isNuxtEnabled = Boolean(options.nuxtMajorVersion);
|
|
2056
2074
|
const nuxtLayoutsFiles = `${options.nuxtOrVueProjectDir}layouts/**/*.vue`;
|
|
2057
2075
|
return [
|
|
2058
2076
|
{
|
|
@@ -2166,7 +2184,8 @@ var vueEslintConfig = (options, internalOptions = {}) => {
|
|
|
2166
2184
|
"pinia/prefer-use-store-naming-convention": [
|
|
2167
2185
|
ERROR,
|
|
2168
2186
|
{
|
|
2169
|
-
checkStoreNameMismatch: true
|
|
2187
|
+
checkStoreNameMismatch: true,
|
|
2188
|
+
storeSuffix: typeof options.pinia === "object" ? options.pinia.storesNameSuffix : "Store"
|
|
2170
2189
|
}
|
|
2171
2190
|
],
|
|
2172
2191
|
// 'pinia/require-setup-store-properties-export': ERROR,
|
|
@@ -2184,6 +2203,7 @@ var eslintConfig = (options = {}) => {
|
|
|
2184
2203
|
const isVueEnabled = configsOptions.vue !== false && (Boolean(configsOptions.vue) || (0, import_local_pkg.isPackageExists)("vue"));
|
|
2185
2204
|
const typescriptPackageInfo = (0, import_local_pkg.getPackageInfoSync)("typescript");
|
|
2186
2205
|
const isTypescriptEnabled = configsOptions.ts !== false && Boolean(configsOptions.ts || typescriptPackageInfo);
|
|
2206
|
+
const gitignoreConfig = typeof options.gitignore === "object" ? (0, import_eslint_config_flat_gitignore.default)(options.gitignore) : import_node_fs.default.existsSync(".gitignore") ? (0, import_eslint_config_flat_gitignore.default)() : null;
|
|
2187
2207
|
const jsOptions = {
|
|
2188
2208
|
...assignOptions(configsOptions, "js")
|
|
2189
2209
|
};
|
|
@@ -2248,7 +2268,11 @@ var eslintConfig = (options = {}) => {
|
|
|
2248
2268
|
// According to ESLint docs: "If `ignores` is used without any other keys in the configuration object, then the patterns act as global ignores <...> Patterns are added after the default patterns, which are ["**/node_modules/", ".git/"]." - https://eslint.org/docs/latest/use/configure/configuration-files#globally-ignoring-files-with-ignores
|
|
2249
2269
|
{
|
|
2250
2270
|
ignores: options.ignores || ["**/dist"],
|
|
2251
|
-
name: genFlatConfigEntryName("global
|
|
2271
|
+
name: genFlatConfigEntryName("ignores-global")
|
|
2272
|
+
},
|
|
2273
|
+
{
|
|
2274
|
+
...gitignoreConfig,
|
|
2275
|
+
name: genFlatConfigEntryName("ignores-gitignore")
|
|
2252
2276
|
},
|
|
2253
2277
|
{
|
|
2254
2278
|
plugins: {
|