eslint-config-un 0.0.2 → 0.0.3
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 +43 -17
- package/dist/index.d.cts +18 -3
- package/dist/index.d.ts +18 -3
- package/dist/index.js +43 -17
- package/package.json +8 -7
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# eslint-config-un
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/esling-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
|
@@ -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);
|
|
@@ -740,7 +742,7 @@ var jsEslintConfig = (options = {}, internalOptions = {}) => {
|
|
|
740
742
|
allowUnboundThis: true
|
|
741
743
|
}
|
|
742
744
|
],
|
|
743
|
-
"prefer-const": [ERROR, { ignoreReadBeforeAssign: true }],
|
|
745
|
+
"prefer-const": [ERROR, { destructuring: "all", ignoreReadBeforeAssign: true }],
|
|
744
746
|
"prefer-destructuring": [ERROR, RULE_PREFER_DESTRUCTURING_OPTIONS],
|
|
745
747
|
"prefer-exponentiation-operator": ERROR,
|
|
746
748
|
// 'prefer-named-capture-group': OFF,
|
|
@@ -1181,10 +1183,26 @@ var import_typescript_eslint = require("typescript-eslint");
|
|
|
1181
1183
|
var overrideBaseRule2 = genRuleOverrideFn("@typescript-eslint");
|
|
1182
1184
|
var tsEslintConfig = (options = {}, internalOptions = {}) => {
|
|
1183
1185
|
const onlyTsFiles = [GLOB_TS, GLOB_TSX];
|
|
1184
|
-
const
|
|
1185
|
-
const
|
|
1186
|
-
const
|
|
1187
|
-
|
|
1186
|
+
const extraFiles = [];
|
|
1187
|
+
const extraFilesToIgnore = [];
|
|
1188
|
+
const { vueOptions } = internalOptions;
|
|
1189
|
+
if (vueOptions) {
|
|
1190
|
+
const { enforceTypescriptInScriptSection } = vueOptions;
|
|
1191
|
+
const vueFilesWithTs = typeof enforceTypescriptInScriptSection === "object" ? enforceTypescriptInScriptSection.files || [] : enforceTypescriptInScriptSection ? vueOptions.files || [GLOB_VUE] : [];
|
|
1192
|
+
const vueFilesWithoutTs = typeof enforceTypescriptInScriptSection === "object" ? enforceTypescriptInScriptSection.ignores || [] : [];
|
|
1193
|
+
extraFiles.push(...vueFilesWithTs);
|
|
1194
|
+
extraFilesToIgnore.push(...vueFilesWithoutTs);
|
|
1195
|
+
}
|
|
1196
|
+
const filesNonTypeAware = [...options.files || onlyTsFiles, ...extraFiles];
|
|
1197
|
+
const ignoresNonTypeAware = [...options.ignores || [], ...extraFilesToIgnore];
|
|
1198
|
+
const filesTypeAware = [
|
|
1199
|
+
...options.filesTypeAware === true || options.filesTypeAware == null ? onlyTsFiles : options.filesTypeAware || [],
|
|
1200
|
+
...extraFiles
|
|
1201
|
+
];
|
|
1202
|
+
const ignoresTypeAware = [
|
|
1203
|
+
...options.ignoresTypeAware === true ? options.ignores || [] : options.ignoresTypeAware || [],
|
|
1204
|
+
...extraFilesToIgnore
|
|
1205
|
+
];
|
|
1188
1206
|
const filesAll = [...onlyTsFiles, ...filesTypeAware];
|
|
1189
1207
|
const tsVersion = options.typescriptVersion ? Number.parseFloat(options.typescriptVersion) : void 0;
|
|
1190
1208
|
const generateBaseOptions = (isTypeAware) => ({
|
|
@@ -1411,16 +1429,14 @@ var tsEslintConfig = (options = {}, internalOptions = {}) => {
|
|
|
1411
1429
|
{
|
|
1412
1430
|
...generateBaseOptions(false),
|
|
1413
1431
|
files: filesNonTypeAware,
|
|
1414
|
-
...
|
|
1432
|
+
...ignoresNonTypeAware.length > 0 && { ignores: ignoresNonTypeAware },
|
|
1415
1433
|
rules: typescriptRulesRegular,
|
|
1416
1434
|
name: genFlatConfigEntryName("ts/regular-rules")
|
|
1417
1435
|
},
|
|
1418
1436
|
filesTypeAware.length > 0 && {
|
|
1419
1437
|
...generateBaseOptions(true),
|
|
1420
1438
|
files: filesTypeAware,
|
|
1421
|
-
...
|
|
1422
|
-
ignores: options.ignoresTypeAware === true ? options.ignores || [] : options.ignoresTypeAware
|
|
1423
|
-
},
|
|
1439
|
+
...ignoresTypeAware.length > 0 && { ignores: ignoresTypeAware },
|
|
1424
1440
|
rules: typescriptRulesTypeAware,
|
|
1425
1441
|
name: genFlatConfigEntryName("ts/type-aware-rules")
|
|
1426
1442
|
},
|
|
@@ -1687,6 +1703,7 @@ var vueEslintConfig = (options, internalOptions = {}) => {
|
|
|
1687
1703
|
const isLess2_5 = isVue2 && vueMajorAndMinorVersion < 2.5;
|
|
1688
1704
|
const isLess2_6 = isVue2 && vueMajorAndMinorVersion < 2.6;
|
|
1689
1705
|
const isLess3_1 = vueMajorAndMinorVersion < 3.1;
|
|
1706
|
+
const isNuxtEnabled = Boolean(options.nuxtMajorVersion);
|
|
1690
1707
|
const recommendedRules = (
|
|
1691
1708
|
// TODO report to Prettier?
|
|
1692
1709
|
// prettier-ignore
|
|
@@ -1845,7 +1862,7 @@ var vueEslintConfig = (options, internalOptions = {}) => {
|
|
|
1845
1862
|
{
|
|
1846
1863
|
script: {
|
|
1847
1864
|
lang: "ts",
|
|
1848
|
-
|
|
1865
|
+
...enforceTypescriptInScriptSection !== true && { allowNoLang: true }
|
|
1849
1866
|
}
|
|
1850
1867
|
}
|
|
1851
1868
|
],
|
|
@@ -1915,8 +1932,7 @@ var vueEslintConfig = (options, internalOptions = {}) => {
|
|
|
1915
1932
|
// 'vue/new-line-between-multi-line-property': OFF,
|
|
1916
1933
|
// 'vue/next-tick-style': OFF,
|
|
1917
1934
|
// 'vue/no-bare-strings-in-template': OFF,
|
|
1918
|
-
//
|
|
1919
|
-
"vue/no-boolean-default": [ERROR, "default-false"],
|
|
1935
|
+
// 'vue/no-boolean-default': OFF,
|
|
1920
1936
|
...isVue3 && { "vue/no-deprecated-model-definition": ERROR },
|
|
1921
1937
|
"vue/no-duplicate-attr-inheritance": ERROR,
|
|
1922
1938
|
"vue/no-empty-component-block": ERROR,
|
|
@@ -1943,10 +1959,15 @@ var vueEslintConfig = (options, internalOptions = {}) => {
|
|
|
1943
1959
|
"vue/no-undef-components": [
|
|
1944
1960
|
ERROR,
|
|
1945
1961
|
{
|
|
1946
|
-
ignorePatterns: [
|
|
1962
|
+
ignorePatterns: [
|
|
1963
|
+
"router-link",
|
|
1964
|
+
"router-view",
|
|
1965
|
+
isNuxtEnabled && /^(lazy-)?(nuxt-|client-only$)/,
|
|
1966
|
+
...options.knownComponentNames || []
|
|
1967
|
+
].flat().filter((v) => v !== false)
|
|
1947
1968
|
}
|
|
1948
1969
|
],
|
|
1949
|
-
// TODO enable if script setup is enforced?
|
|
1970
|
+
// TODO enable if script setup is enforced and only in JS?
|
|
1950
1971
|
// 'vue/no-undef-properties': OFF,
|
|
1951
1972
|
"vue/no-unsupported-features": [ERROR, { version: `^${options.fullVersion || majorVersion}` }],
|
|
1952
1973
|
"vue/no-unused-emit-declarations": ERROR,
|
|
@@ -2052,7 +2073,6 @@ var vueEslintConfig = (options, internalOptions = {}) => {
|
|
|
2052
2073
|
// False positives in script setup
|
|
2053
2074
|
...options.overrides
|
|
2054
2075
|
};
|
|
2055
|
-
const isNuxtEnabled = Boolean(options.nuxtMajorVersion);
|
|
2056
2076
|
const nuxtLayoutsFiles = `${options.nuxtOrVueProjectDir}layouts/**/*.vue`;
|
|
2057
2077
|
return [
|
|
2058
2078
|
{
|
|
@@ -2166,7 +2186,8 @@ var vueEslintConfig = (options, internalOptions = {}) => {
|
|
|
2166
2186
|
"pinia/prefer-use-store-naming-convention": [
|
|
2167
2187
|
ERROR,
|
|
2168
2188
|
{
|
|
2169
|
-
checkStoreNameMismatch: true
|
|
2189
|
+
checkStoreNameMismatch: true,
|
|
2190
|
+
storeSuffix: typeof options.pinia === "object" ? options.pinia.storesNameSuffix : "Store"
|
|
2170
2191
|
}
|
|
2171
2192
|
],
|
|
2172
2193
|
// 'pinia/require-setup-store-properties-export': ERROR,
|
|
@@ -2184,6 +2205,7 @@ var eslintConfig = (options = {}) => {
|
|
|
2184
2205
|
const isVueEnabled = configsOptions.vue !== false && (Boolean(configsOptions.vue) || (0, import_local_pkg.isPackageExists)("vue"));
|
|
2185
2206
|
const typescriptPackageInfo = (0, import_local_pkg.getPackageInfoSync)("typescript");
|
|
2186
2207
|
const isTypescriptEnabled = configsOptions.ts !== false && Boolean(configsOptions.ts || typescriptPackageInfo);
|
|
2208
|
+
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
2209
|
const jsOptions = {
|
|
2188
2210
|
...assignOptions(configsOptions, "js")
|
|
2189
2211
|
};
|
|
@@ -2248,7 +2270,11 @@ var eslintConfig = (options = {}) => {
|
|
|
2248
2270
|
// 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
2271
|
{
|
|
2250
2272
|
ignores: options.ignores || ["**/dist"],
|
|
2251
|
-
name: genFlatConfigEntryName("global
|
|
2273
|
+
name: genFlatConfigEntryName("ignores-global")
|
|
2274
|
+
},
|
|
2275
|
+
{
|
|
2276
|
+
...gitignoreConfig,
|
|
2277
|
+
name: genFlatConfigEntryName("ignores-gitignore")
|
|
2252
2278
|
},
|
|
2253
2279
|
{
|
|
2254
2280
|
plugins: {
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import Eslint from 'eslint';
|
|
2
|
+
import { FlatGitignoreOptions } from 'eslint-config-flat-gitignore';
|
|
2
3
|
import { ParserOptions } from '@typescript-eslint/parser';
|
|
3
4
|
import { ESLintRules } from 'eslint/rules';
|
|
4
5
|
|
|
@@ -70,10 +71,12 @@ interface VueEslintConfigOptions extends ConfigSharedOptions<`vue/${string}`> {
|
|
|
70
71
|
fullVersion?: string;
|
|
71
72
|
/**
|
|
72
73
|
* This being true turns on TypeScript type-aware rules for .Vue files. They are disabled by default because it applies them to plain JS <script> sections which causes tons on false positives.
|
|
73
|
-
* TODO possible to fix that behavior?
|
|
74
74
|
* @default true if typescript config is enabled
|
|
75
75
|
*/
|
|
76
|
-
enforceTypescriptInScriptSection?: boolean
|
|
76
|
+
enforceTypescriptInScriptSection?: boolean | Pick<FlatConfigEntry, 'files' | 'ignores'>;
|
|
77
|
+
/**
|
|
78
|
+
* Will be merged with `['router-link', 'router-view']` and Nuxt-specific ones if Nuxt is enabled
|
|
79
|
+
*/
|
|
77
80
|
knownComponentNames?: (string | RegExp)[];
|
|
78
81
|
enforceApiStyle?: 'setup' | 'options';
|
|
79
82
|
/**
|
|
@@ -104,8 +107,15 @@ interface VueEslintConfigOptions extends ConfigSharedOptions<`vue/${string}`> {
|
|
|
104
107
|
nuxtOrVueProjectDir?: string;
|
|
105
108
|
/**
|
|
106
109
|
* Enabled automatically by checking if `pinia` package is installed (at any level). Pass a false value to disable pinia-specific rules.
|
|
110
|
+
* @default true if `pinia` package is installed
|
|
107
111
|
*/
|
|
108
|
-
pinia?: boolean
|
|
112
|
+
pinia?: boolean | {
|
|
113
|
+
/**
|
|
114
|
+
* @default `Store`
|
|
115
|
+
* @see https://github.com/lisilinhart/eslint-plugin-pinia/blob/main/docs/rules/prefer-use-store-naming-convention.md#options
|
|
116
|
+
*/
|
|
117
|
+
storesNameSuffix?: string;
|
|
118
|
+
};
|
|
109
119
|
overridesPinia?: RuleOverrides<`pinia/${string}`>;
|
|
110
120
|
}
|
|
111
121
|
|
|
@@ -120,6 +130,11 @@ interface EslintConfigOptions {
|
|
|
120
130
|
* **Global** ignore patterns
|
|
121
131
|
*/
|
|
122
132
|
ignores?: FlatConfigEntry['ignores'];
|
|
133
|
+
/**
|
|
134
|
+
* Automatically add gitignore'd files to `ignores` array.
|
|
135
|
+
* @default true if `.gitignore` exists
|
|
136
|
+
*/
|
|
137
|
+
gitignore?: boolean | FlatGitignoreOptions;
|
|
123
138
|
/**
|
|
124
139
|
* Enables `eslint-config-prettier` at the end of the ruleset.
|
|
125
140
|
* @see https://github.com/prettier/eslint-config-prettier
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import Eslint from 'eslint';
|
|
2
|
+
import { FlatGitignoreOptions } from 'eslint-config-flat-gitignore';
|
|
2
3
|
import { ParserOptions } from '@typescript-eslint/parser';
|
|
3
4
|
import { ESLintRules } from 'eslint/rules';
|
|
4
5
|
|
|
@@ -70,10 +71,12 @@ interface VueEslintConfigOptions extends ConfigSharedOptions<`vue/${string}`> {
|
|
|
70
71
|
fullVersion?: string;
|
|
71
72
|
/**
|
|
72
73
|
* This being true turns on TypeScript type-aware rules for .Vue files. They are disabled by default because it applies them to plain JS <script> sections which causes tons on false positives.
|
|
73
|
-
* TODO possible to fix that behavior?
|
|
74
74
|
* @default true if typescript config is enabled
|
|
75
75
|
*/
|
|
76
|
-
enforceTypescriptInScriptSection?: boolean
|
|
76
|
+
enforceTypescriptInScriptSection?: boolean | Pick<FlatConfigEntry, 'files' | 'ignores'>;
|
|
77
|
+
/**
|
|
78
|
+
* Will be merged with `['router-link', 'router-view']` and Nuxt-specific ones if Nuxt is enabled
|
|
79
|
+
*/
|
|
77
80
|
knownComponentNames?: (string | RegExp)[];
|
|
78
81
|
enforceApiStyle?: 'setup' | 'options';
|
|
79
82
|
/**
|
|
@@ -104,8 +107,15 @@ interface VueEslintConfigOptions extends ConfigSharedOptions<`vue/${string}`> {
|
|
|
104
107
|
nuxtOrVueProjectDir?: string;
|
|
105
108
|
/**
|
|
106
109
|
* Enabled automatically by checking if `pinia` package is installed (at any level). Pass a false value to disable pinia-specific rules.
|
|
110
|
+
* @default true if `pinia` package is installed
|
|
107
111
|
*/
|
|
108
|
-
pinia?: boolean
|
|
112
|
+
pinia?: boolean | {
|
|
113
|
+
/**
|
|
114
|
+
* @default `Store`
|
|
115
|
+
* @see https://github.com/lisilinhart/eslint-plugin-pinia/blob/main/docs/rules/prefer-use-store-naming-convention.md#options
|
|
116
|
+
*/
|
|
117
|
+
storesNameSuffix?: string;
|
|
118
|
+
};
|
|
109
119
|
overridesPinia?: RuleOverrides<`pinia/${string}`>;
|
|
110
120
|
}
|
|
111
121
|
|
|
@@ -120,6 +130,11 @@ interface EslintConfigOptions {
|
|
|
120
130
|
* **Global** ignore patterns
|
|
121
131
|
*/
|
|
122
132
|
ignores?: FlatConfigEntry['ignores'];
|
|
133
|
+
/**
|
|
134
|
+
* Automatically add gitignore'd files to `ignores` array.
|
|
135
|
+
* @default true if `.gitignore` exists
|
|
136
|
+
*/
|
|
137
|
+
gitignore?: boolean | FlatGitignoreOptions;
|
|
123
138
|
/**
|
|
124
139
|
* Enables `eslint-config-prettier` at the end of the ruleset.
|
|
125
140
|
* @see https://github.com/prettier/eslint-config-prettier
|
package/dist/index.js
CHANGED
|
@@ -332,7 +332,9 @@ var require_src = __commonJS({
|
|
|
332
332
|
|
|
333
333
|
// src/index.ts
|
|
334
334
|
init_esm_shims();
|
|
335
|
+
import fs from "fs";
|
|
335
336
|
import eslintPluginStylistic from "@stylistic/eslint-plugin";
|
|
337
|
+
import eslintGitignore from "eslint-config-flat-gitignore";
|
|
336
338
|
import eslintConfigPrettier from "eslint-config-prettier";
|
|
337
339
|
import pluginDisableAutofix from "eslint-plugin-disable-autofix";
|
|
338
340
|
import eslintPluginUnicorn2 from "eslint-plugin-unicorn";
|
|
@@ -729,7 +731,7 @@ var jsEslintConfig = (options = {}, internalOptions = {}) => {
|
|
|
729
731
|
allowUnboundThis: true
|
|
730
732
|
}
|
|
731
733
|
],
|
|
732
|
-
"prefer-const": [ERROR, { ignoreReadBeforeAssign: true }],
|
|
734
|
+
"prefer-const": [ERROR, { destructuring: "all", ignoreReadBeforeAssign: true }],
|
|
733
735
|
"prefer-destructuring": [ERROR, RULE_PREFER_DESTRUCTURING_OPTIONS],
|
|
734
736
|
"prefer-exponentiation-operator": ERROR,
|
|
735
737
|
// 'prefer-named-capture-group': OFF,
|
|
@@ -1170,10 +1172,26 @@ import { parser as parserTs, plugin as pluginTs } from "typescript-eslint";
|
|
|
1170
1172
|
var overrideBaseRule2 = genRuleOverrideFn("@typescript-eslint");
|
|
1171
1173
|
var tsEslintConfig = (options = {}, internalOptions = {}) => {
|
|
1172
1174
|
const onlyTsFiles = [GLOB_TS, GLOB_TSX];
|
|
1173
|
-
const
|
|
1174
|
-
const
|
|
1175
|
-
const
|
|
1176
|
-
|
|
1175
|
+
const extraFiles = [];
|
|
1176
|
+
const extraFilesToIgnore = [];
|
|
1177
|
+
const { vueOptions } = internalOptions;
|
|
1178
|
+
if (vueOptions) {
|
|
1179
|
+
const { enforceTypescriptInScriptSection } = vueOptions;
|
|
1180
|
+
const vueFilesWithTs = typeof enforceTypescriptInScriptSection === "object" ? enforceTypescriptInScriptSection.files || [] : enforceTypescriptInScriptSection ? vueOptions.files || [GLOB_VUE] : [];
|
|
1181
|
+
const vueFilesWithoutTs = typeof enforceTypescriptInScriptSection === "object" ? enforceTypescriptInScriptSection.ignores || [] : [];
|
|
1182
|
+
extraFiles.push(...vueFilesWithTs);
|
|
1183
|
+
extraFilesToIgnore.push(...vueFilesWithoutTs);
|
|
1184
|
+
}
|
|
1185
|
+
const filesNonTypeAware = [...options.files || onlyTsFiles, ...extraFiles];
|
|
1186
|
+
const ignoresNonTypeAware = [...options.ignores || [], ...extraFilesToIgnore];
|
|
1187
|
+
const filesTypeAware = [
|
|
1188
|
+
...options.filesTypeAware === true || options.filesTypeAware == null ? onlyTsFiles : options.filesTypeAware || [],
|
|
1189
|
+
...extraFiles
|
|
1190
|
+
];
|
|
1191
|
+
const ignoresTypeAware = [
|
|
1192
|
+
...options.ignoresTypeAware === true ? options.ignores || [] : options.ignoresTypeAware || [],
|
|
1193
|
+
...extraFilesToIgnore
|
|
1194
|
+
];
|
|
1177
1195
|
const filesAll = [...onlyTsFiles, ...filesTypeAware];
|
|
1178
1196
|
const tsVersion = options.typescriptVersion ? Number.parseFloat(options.typescriptVersion) : void 0;
|
|
1179
1197
|
const generateBaseOptions = (isTypeAware) => ({
|
|
@@ -1400,16 +1418,14 @@ var tsEslintConfig = (options = {}, internalOptions = {}) => {
|
|
|
1400
1418
|
{
|
|
1401
1419
|
...generateBaseOptions(false),
|
|
1402
1420
|
files: filesNonTypeAware,
|
|
1403
|
-
...
|
|
1421
|
+
...ignoresNonTypeAware.length > 0 && { ignores: ignoresNonTypeAware },
|
|
1404
1422
|
rules: typescriptRulesRegular,
|
|
1405
1423
|
name: genFlatConfigEntryName("ts/regular-rules")
|
|
1406
1424
|
},
|
|
1407
1425
|
filesTypeAware.length > 0 && {
|
|
1408
1426
|
...generateBaseOptions(true),
|
|
1409
1427
|
files: filesTypeAware,
|
|
1410
|
-
...
|
|
1411
|
-
ignores: options.ignoresTypeAware === true ? options.ignores || [] : options.ignoresTypeAware
|
|
1412
|
-
},
|
|
1428
|
+
...ignoresTypeAware.length > 0 && { ignores: ignoresTypeAware },
|
|
1413
1429
|
rules: typescriptRulesTypeAware,
|
|
1414
1430
|
name: genFlatConfigEntryName("ts/type-aware-rules")
|
|
1415
1431
|
},
|
|
@@ -1676,6 +1692,7 @@ var vueEslintConfig = (options, internalOptions = {}) => {
|
|
|
1676
1692
|
const isLess2_5 = isVue2 && vueMajorAndMinorVersion < 2.5;
|
|
1677
1693
|
const isLess2_6 = isVue2 && vueMajorAndMinorVersion < 2.6;
|
|
1678
1694
|
const isLess3_1 = vueMajorAndMinorVersion < 3.1;
|
|
1695
|
+
const isNuxtEnabled = Boolean(options.nuxtMajorVersion);
|
|
1679
1696
|
const recommendedRules = (
|
|
1680
1697
|
// TODO report to Prettier?
|
|
1681
1698
|
// prettier-ignore
|
|
@@ -1834,7 +1851,7 @@ var vueEslintConfig = (options, internalOptions = {}) => {
|
|
|
1834
1851
|
{
|
|
1835
1852
|
script: {
|
|
1836
1853
|
lang: "ts",
|
|
1837
|
-
|
|
1854
|
+
...enforceTypescriptInScriptSection !== true && { allowNoLang: true }
|
|
1838
1855
|
}
|
|
1839
1856
|
}
|
|
1840
1857
|
],
|
|
@@ -1904,8 +1921,7 @@ var vueEslintConfig = (options, internalOptions = {}) => {
|
|
|
1904
1921
|
// 'vue/new-line-between-multi-line-property': OFF,
|
|
1905
1922
|
// 'vue/next-tick-style': OFF,
|
|
1906
1923
|
// 'vue/no-bare-strings-in-template': OFF,
|
|
1907
|
-
//
|
|
1908
|
-
"vue/no-boolean-default": [ERROR, "default-false"],
|
|
1924
|
+
// 'vue/no-boolean-default': OFF,
|
|
1909
1925
|
...isVue3 && { "vue/no-deprecated-model-definition": ERROR },
|
|
1910
1926
|
"vue/no-duplicate-attr-inheritance": ERROR,
|
|
1911
1927
|
"vue/no-empty-component-block": ERROR,
|
|
@@ -1932,10 +1948,15 @@ var vueEslintConfig = (options, internalOptions = {}) => {
|
|
|
1932
1948
|
"vue/no-undef-components": [
|
|
1933
1949
|
ERROR,
|
|
1934
1950
|
{
|
|
1935
|
-
ignorePatterns: [
|
|
1951
|
+
ignorePatterns: [
|
|
1952
|
+
"router-link",
|
|
1953
|
+
"router-view",
|
|
1954
|
+
isNuxtEnabled && /^(lazy-)?(nuxt-|client-only$)/,
|
|
1955
|
+
...options.knownComponentNames || []
|
|
1956
|
+
].flat().filter((v) => v !== false)
|
|
1936
1957
|
}
|
|
1937
1958
|
],
|
|
1938
|
-
// TODO enable if script setup is enforced?
|
|
1959
|
+
// TODO enable if script setup is enforced and only in JS?
|
|
1939
1960
|
// 'vue/no-undef-properties': OFF,
|
|
1940
1961
|
"vue/no-unsupported-features": [ERROR, { version: `^${options.fullVersion || majorVersion}` }],
|
|
1941
1962
|
"vue/no-unused-emit-declarations": ERROR,
|
|
@@ -2041,7 +2062,6 @@ var vueEslintConfig = (options, internalOptions = {}) => {
|
|
|
2041
2062
|
// False positives in script setup
|
|
2042
2063
|
...options.overrides
|
|
2043
2064
|
};
|
|
2044
|
-
const isNuxtEnabled = Boolean(options.nuxtMajorVersion);
|
|
2045
2065
|
const nuxtLayoutsFiles = `${options.nuxtOrVueProjectDir}layouts/**/*.vue`;
|
|
2046
2066
|
return [
|
|
2047
2067
|
{
|
|
@@ -2155,7 +2175,8 @@ var vueEslintConfig = (options, internalOptions = {}) => {
|
|
|
2155
2175
|
"pinia/prefer-use-store-naming-convention": [
|
|
2156
2176
|
ERROR,
|
|
2157
2177
|
{
|
|
2158
|
-
checkStoreNameMismatch: true
|
|
2178
|
+
checkStoreNameMismatch: true,
|
|
2179
|
+
storeSuffix: typeof options.pinia === "object" ? options.pinia.storesNameSuffix : "Store"
|
|
2159
2180
|
}
|
|
2160
2181
|
],
|
|
2161
2182
|
// 'pinia/require-setup-store-properties-export': ERROR,
|
|
@@ -2173,6 +2194,7 @@ var eslintConfig = (options = {}) => {
|
|
|
2173
2194
|
const isVueEnabled = configsOptions.vue !== false && (Boolean(configsOptions.vue) || isPackageExists("vue"));
|
|
2174
2195
|
const typescriptPackageInfo = getPackageInfoSync("typescript");
|
|
2175
2196
|
const isTypescriptEnabled = configsOptions.ts !== false && Boolean(configsOptions.ts || typescriptPackageInfo);
|
|
2197
|
+
const gitignoreConfig = typeof options.gitignore === "object" ? eslintGitignore(options.gitignore) : fs.existsSync(".gitignore") ? eslintGitignore() : null;
|
|
2176
2198
|
const jsOptions = {
|
|
2177
2199
|
...assignOptions(configsOptions, "js")
|
|
2178
2200
|
};
|
|
@@ -2237,7 +2259,11 @@ var eslintConfig = (options = {}) => {
|
|
|
2237
2259
|
// 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
|
|
2238
2260
|
{
|
|
2239
2261
|
ignores: options.ignores || ["**/dist"],
|
|
2240
|
-
name: genFlatConfigEntryName("global
|
|
2262
|
+
name: genFlatConfigEntryName("ignores-global")
|
|
2263
|
+
},
|
|
2264
|
+
{
|
|
2265
|
+
...gitignoreConfig,
|
|
2266
|
+
name: genFlatConfigEntryName("ignores-gitignore")
|
|
2241
2267
|
},
|
|
2242
2268
|
{
|
|
2243
2269
|
plugins: {
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.0.
|
|
2
|
+
"version": "0.0.3",
|
|
3
3
|
"name": "eslint-config-un",
|
|
4
4
|
"description": "A universal-ish ESLint config aiming to be reasonably strict and easily configurable.",
|
|
5
5
|
"scripts": {
|
|
@@ -52,24 +52,25 @@
|
|
|
52
52
|
"@types/eslint-plugin-security": "3.0.0",
|
|
53
53
|
"@types/eslint__js": "8.42.3",
|
|
54
54
|
"@types/lodash-es": "4.17.12",
|
|
55
|
-
"@types/node": "^18.19.
|
|
55
|
+
"@types/node": "^18.19.40",
|
|
56
56
|
"cross-env": "7.0.3",
|
|
57
57
|
"eslint": "npm:eslint-ts-patch@9.5.0-0",
|
|
58
58
|
"eslint-ts-patch": "9.5.0-0",
|
|
59
|
-
"prettier": "3.3.
|
|
60
|
-
"release-it": "17.
|
|
59
|
+
"prettier": "3.3.3",
|
|
60
|
+
"release-it": "17.6.0",
|
|
61
61
|
"shx": "0.3.4",
|
|
62
62
|
"tsup": "8.1.0",
|
|
63
63
|
"typescript": "5.5.3"
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
66
|
"@stylistic/eslint-plugin": "2.3.0",
|
|
67
|
-
"@typescript-eslint/parser": "7.16.
|
|
67
|
+
"@typescript-eslint/parser": "7.16.1",
|
|
68
|
+
"eslint-config-flat-gitignore": "0.1.8",
|
|
68
69
|
"eslint-config-prettier": "9.1.0",
|
|
69
70
|
"eslint-import-resolver-typescript": "3.6.1",
|
|
70
71
|
"eslint-plugin-disable-autofix": "5.0.1",
|
|
71
72
|
"eslint-plugin-import": "2.29.1",
|
|
72
|
-
"eslint-plugin-import-x": "0.
|
|
73
|
+
"eslint-plugin-import-x": "3.0.1",
|
|
73
74
|
"eslint-plugin-n": "17.9.0",
|
|
74
75
|
"eslint-plugin-no-type-assertion": "1.3.0",
|
|
75
76
|
"eslint-plugin-pinia": "0.2.0",
|
|
@@ -83,7 +84,7 @@
|
|
|
83
84
|
"eslint-plugin-vuejs-accessibility": "2.3.1",
|
|
84
85
|
"globals": "15.8.0",
|
|
85
86
|
"local-pkg": "0.5.0",
|
|
86
|
-
"typescript-eslint": "7.16.
|
|
87
|
+
"typescript-eslint": "7.16.1",
|
|
87
88
|
"vue-eslint-parser": "9.4.3"
|
|
88
89
|
},
|
|
89
90
|
"pnpm": {
|