@ntnyq/eslint-config 3.10.1 → 3.10.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 +42 -5
- package/dist/index.cjs +64 -35
- package/dist/index.d.cts +14 -3
- package/dist/index.d.ts +14 -3
- package/dist/index.js +61 -35
- package/package.json +6 -5
package/README.md
CHANGED
|
@@ -9,11 +9,12 @@
|
|
|
9
9
|
|
|
10
10
|
## Features
|
|
11
11
|
|
|
12
|
-
- Opinionable: single quotes, no semi, trailing comma, etc
|
|
12
|
+
- Opinionable: single quotes, no semi, trailing comma, etc
|
|
13
13
|
- Designed to work alongside with [Prettier](https://prettier.io)
|
|
14
14
|
- Respect `.gitignore` via [eslint-config-flat-gitignore](https://github.com/antfu/eslint-config-flat-gitignore)
|
|
15
|
-
- Out-of-box support for TypeScript, Vue, JSON, Markdown, YAML, TOML etc
|
|
15
|
+
- Out-of-box support for TypeScript, Vue, JSON, Markdown, YAML, TOML, SVG and etc
|
|
16
16
|
- Strict but provides useful rules to guard your codebase
|
|
17
|
+
- Custom ESLint commands for [eslint-plugin-command](https://github.com/antfu/eslint-plugin-command)
|
|
17
18
|
- [ESLint flat config](https://eslint.org/docs/latest/use/configure/configuration-files) for ESLint v9.5.0+
|
|
18
19
|
|
|
19
20
|
## Install
|
|
@@ -27,23 +28,57 @@ pnpm add eslint prettier typescript @ntnyq/eslint-config @ntnyq/prettier-config
|
|
|
27
28
|
Highly recommended using **`eslint.config.mjs`** as the config file :
|
|
28
29
|
|
|
29
30
|
```js
|
|
31
|
+
// @ts-check
|
|
32
|
+
|
|
30
33
|
import { defineESLintConfig } from '@ntnyq/eslint-config'
|
|
31
34
|
|
|
32
35
|
export default defineESLintConfig()
|
|
33
36
|
```
|
|
34
37
|
|
|
35
|
-
Add scripts `lint` in `package.json
|
|
38
|
+
Add scripts `lint` in `package.json`:
|
|
36
39
|
|
|
37
40
|
```json
|
|
38
41
|
{
|
|
39
42
|
"scripts": {
|
|
40
43
|
"lint": "eslint .",
|
|
41
44
|
"lint:fix": "eslint . --fix"
|
|
42
|
-
}
|
|
43
|
-
"prettier": "@ntnyq/prettier-config"
|
|
45
|
+
}
|
|
44
46
|
}
|
|
45
47
|
```
|
|
46
48
|
|
|
49
|
+
<details>
|
|
50
|
+
<summary>💼 Intergrated with Prettier, VSCode, husky and nano-staged</summary>
|
|
51
|
+
|
|
52
|
+
<br>
|
|
53
|
+
|
|
54
|
+
## Prettier config
|
|
55
|
+
|
|
56
|
+
```js
|
|
57
|
+
// @ts-check
|
|
58
|
+
|
|
59
|
+
import { config, defineConfig } from '@ntnyq/prettier-config'
|
|
60
|
+
|
|
61
|
+
export default defineConfig({
|
|
62
|
+
...config,
|
|
63
|
+
|
|
64
|
+
// overrides if needed
|
|
65
|
+
overrides: [
|
|
66
|
+
{
|
|
67
|
+
files: ['**/*.html'],
|
|
68
|
+
options: {
|
|
69
|
+
singleAttributePerLine: false,
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
files: ['**/*.{css,scss,less}'],
|
|
74
|
+
options: {
|
|
75
|
+
singleQuote: false,
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
],
|
|
79
|
+
})
|
|
80
|
+
```
|
|
81
|
+
|
|
47
82
|
## VSCode Config
|
|
48
83
|
|
|
49
84
|
```json
|
|
@@ -99,6 +134,8 @@ pnpm add husky nano-staged -D
|
|
|
99
134
|
echo "nano-staged" > .husky/pre-commit
|
|
100
135
|
```
|
|
101
136
|
|
|
137
|
+
</details>
|
|
138
|
+
|
|
102
139
|
## Advanced config
|
|
103
140
|
|
|
104
141
|
Check for detail in:
|
package/dist/index.cjs
CHANGED
|
@@ -59,6 +59,7 @@ __export(index_exports, {
|
|
|
59
59
|
GLOB_SRC_EXT: () => GLOB_SRC_EXT,
|
|
60
60
|
GLOB_STYLE: () => GLOB_STYLE,
|
|
61
61
|
GLOB_SVELTE: () => GLOB_SVELTE,
|
|
62
|
+
GLOB_SVG: () => GLOB_SVG,
|
|
62
63
|
GLOB_TEST: () => GLOB_TEST,
|
|
63
64
|
GLOB_TOML: () => GLOB_TOML,
|
|
64
65
|
GLOB_TS: () => GLOB_TS,
|
|
@@ -69,6 +70,8 @@ __export(index_exports, {
|
|
|
69
70
|
antfu: () => antfu,
|
|
70
71
|
command: () => command,
|
|
71
72
|
comments: () => comments,
|
|
73
|
+
createNodeResolver: () => createNodeResolver,
|
|
74
|
+
createTypeScriptImportResolver: () => import_eslint_import_resolver_typescript.createTypeScriptImportResolver,
|
|
72
75
|
defineESLintConfig: () => defineESLintConfig,
|
|
73
76
|
depend: () => depend,
|
|
74
77
|
esX: () => esX,
|
|
@@ -216,6 +219,10 @@ var import_eslint_plugin_eslint_comments = __toESM(require("@eslint-community/es
|
|
|
216
219
|
// src/eslint/configs.ts
|
|
217
220
|
var import_typescript_eslint3 = require("typescript-eslint");
|
|
218
221
|
|
|
222
|
+
// src/eslint/resolvers.ts
|
|
223
|
+
var import_eslint_import_resolver_typescript = require("eslint-import-resolver-typescript");
|
|
224
|
+
var createNodeResolver = import_eslint_plugin_import_x.default.createNodeResolver;
|
|
225
|
+
|
|
219
226
|
// src/eslint/processors.ts
|
|
220
227
|
var import_eslint_merge_processors = require("eslint-merge-processors");
|
|
221
228
|
var import_eslint_merge_processors2 = require("eslint-merge-processors");
|
|
@@ -245,6 +252,7 @@ var GLOB_JSON = "**/*.json";
|
|
|
245
252
|
var GLOB_JSON5 = "**/*.json5";
|
|
246
253
|
var GLOB_JSONC = "**/*.jsonc";
|
|
247
254
|
var GLOB_PACKAGE_JSON = "**/package.json";
|
|
255
|
+
var GLOB_SVG = "**/*.svg";
|
|
248
256
|
var GLOB_VUE = "**/*.vue";
|
|
249
257
|
var GLOB_YAML = "**/*.y?(a)ml";
|
|
250
258
|
var GLOB_TOML = "**/*.toml";
|
|
@@ -1783,7 +1791,7 @@ var import_config = __toESM(require("eslint-plugin-command/config"), 1);
|
|
|
1783
1791
|
var import_commands = require("eslint-plugin-command/commands");
|
|
1784
1792
|
var regexper = (0, import_commands.defineCommand)({
|
|
1785
1793
|
name: "regexper",
|
|
1786
|
-
// @regexper https://regexper.com
|
|
1794
|
+
// @regexper https://regexper.com/#%2F(%5Cb%7C%5Cs%7C%5E)(%40regexper)(%5Cs%5CS%2B)%3F(%5Cb%7C%5Cs%7C%24)%2F
|
|
1787
1795
|
match: /(\b|\s|^)(@regexper)(\s\S+)?(\b|\s|$)/,
|
|
1788
1796
|
action(ctx) {
|
|
1789
1797
|
const literal = ctx.findNodeBelow((node2) => {
|
|
@@ -1792,8 +1800,16 @@ var regexper = (0, import_commands.defineCommand)({
|
|
|
1792
1800
|
if (!literal) {
|
|
1793
1801
|
return ctx.reportError("Unable to find a regexp literal to generate");
|
|
1794
1802
|
}
|
|
1795
|
-
const [
|
|
1796
|
-
|
|
1803
|
+
const [
|
|
1804
|
+
// non-use
|
|
1805
|
+
_fullStr = "",
|
|
1806
|
+
spaceBefore = "",
|
|
1807
|
+
commandStr = "",
|
|
1808
|
+
existingUrl = "",
|
|
1809
|
+
// non-use
|
|
1810
|
+
_spaceAfter = ""
|
|
1811
|
+
] = ctx.matches;
|
|
1812
|
+
const url = `https://regexper.com/#${encodeURIComponent(literal.raw)}`;
|
|
1797
1813
|
if (existingUrl.trim() === url.trim()) {
|
|
1798
1814
|
return;
|
|
1799
1815
|
}
|
|
@@ -1847,38 +1863,46 @@ var ignores = (customIgnores = []) => [
|
|
|
1847
1863
|
];
|
|
1848
1864
|
|
|
1849
1865
|
// src/configs/importX.ts
|
|
1850
|
-
var
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
"import-x
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1866
|
+
var importX = (options = {}) => {
|
|
1867
|
+
const {
|
|
1868
|
+
typescript: enableTypeScript,
|
|
1869
|
+
// use typescript resolve if possible
|
|
1870
|
+
preferTypeScriptResolver = true
|
|
1871
|
+
} = options;
|
|
1872
|
+
return [
|
|
1873
|
+
{
|
|
1874
|
+
name: "ntnyq/import-x",
|
|
1875
|
+
plugins: {
|
|
1876
|
+
"import-x": import_eslint_plugin_import_x.default
|
|
1877
|
+
},
|
|
1878
|
+
settings: {
|
|
1879
|
+
"import-x/resolver-next": [
|
|
1880
|
+
enableTypeScript && preferTypeScriptResolver ? (0, import_eslint_import_resolver_typescript.createTypeScriptImportResolver)({
|
|
1881
|
+
extensions: [".ts", ".tsx", ".d.ts", ".js", ".jsx", ".json", ".node"]
|
|
1882
|
+
}) : createNodeResolver({
|
|
1883
|
+
extensions: [".js", ".mjs", ".ts", ".mts", ".d.ts", ".json"]
|
|
1884
|
+
})
|
|
1885
|
+
]
|
|
1886
|
+
},
|
|
1887
|
+
rules: {
|
|
1888
|
+
"import-x/no-unresolved": "off",
|
|
1889
|
+
"import-x/no-absolute-path": "off",
|
|
1890
|
+
"import-x/no-named-as-default-member": "off",
|
|
1891
|
+
"import-x/no-named-default": "off",
|
|
1892
|
+
// disabled in favor or `perfectionist/sort-imports`
|
|
1893
|
+
"import-x/order": "off",
|
|
1894
|
+
"import-x/first": "error",
|
|
1895
|
+
"import-x/export": "error",
|
|
1896
|
+
"import-x/no-self-import": "error",
|
|
1897
|
+
"import-x/no-duplicates": "error",
|
|
1898
|
+
"import-x/no-mutable-exports": "error",
|
|
1899
|
+
"import-x/newline-after-import": "error",
|
|
1900
|
+
// Overrides rules
|
|
1901
|
+
...options.overrides
|
|
1902
|
+
}
|
|
1879
1903
|
}
|
|
1880
|
-
|
|
1881
|
-
|
|
1904
|
+
];
|
|
1905
|
+
};
|
|
1882
1906
|
|
|
1883
1907
|
// src/configs/unicorn.ts
|
|
1884
1908
|
var disabledRules2 = {
|
|
@@ -2128,7 +2152,7 @@ var markdown = (options = {}) => {
|
|
|
2128
2152
|
// src/configs/prettier.ts
|
|
2129
2153
|
var prettier = (options = {}) => {
|
|
2130
2154
|
const {
|
|
2131
|
-
disabledFiles = [GLOB_TOML, GLOB_ASTRO, GLOB_SVELTE],
|
|
2155
|
+
disabledFiles = [GLOB_SVG, GLOB_TOML, GLOB_ASTRO, GLOB_SVELTE],
|
|
2132
2156
|
// User defined disabled files
|
|
2133
2157
|
userDisabledFiles = []
|
|
2134
2158
|
} = options;
|
|
@@ -3073,6 +3097,8 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
3073
3097
|
...resolveSubOptions(options, "command")
|
|
3074
3098
|
}),
|
|
3075
3099
|
...importX({
|
|
3100
|
+
...resolveSubOptions(options, "importX"),
|
|
3101
|
+
typescript: !!enableTypeScript,
|
|
3076
3102
|
overrides: getOverrides(options, "importX")
|
|
3077
3103
|
}),
|
|
3078
3104
|
...jsdoc({
|
|
@@ -3271,6 +3297,7 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
3271
3297
|
GLOB_SRC_EXT,
|
|
3272
3298
|
GLOB_STYLE,
|
|
3273
3299
|
GLOB_SVELTE,
|
|
3300
|
+
GLOB_SVG,
|
|
3274
3301
|
GLOB_TEST,
|
|
3275
3302
|
GLOB_TOML,
|
|
3276
3303
|
GLOB_TS,
|
|
@@ -3281,6 +3308,8 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
3281
3308
|
antfu,
|
|
3282
3309
|
command,
|
|
3283
3310
|
comments,
|
|
3311
|
+
createNodeResolver,
|
|
3312
|
+
createTypeScriptImportResolver,
|
|
3284
3313
|
defineESLintConfig,
|
|
3285
3314
|
depend,
|
|
3286
3315
|
esX,
|
package/dist/index.d.cts
CHANGED
|
@@ -37,6 +37,7 @@ export { default as pluginStylistic } from '@stylistic/eslint-plugin';
|
|
|
37
37
|
export { default as pluginPerfectionist } from 'eslint-plugin-perfectionist';
|
|
38
38
|
export { default as pluginUnusedImports } from 'eslint-plugin-unused-imports';
|
|
39
39
|
export { default as pluginComments } from '@eslint-community/eslint-plugin-eslint-comments';
|
|
40
|
+
import * as eslint_plugin_import_x_node_resolver_js from 'eslint-plugin-import-x/node-resolver.js';
|
|
40
41
|
export { mergeProcessors, processorPassThrough } from 'eslint-merge-processors';
|
|
41
42
|
import * as vueEslintParser from 'vue-eslint-parser';
|
|
42
43
|
export { vueEslintParser as parserVue };
|
|
@@ -46,6 +47,7 @@ import * as yamlEslintParser from 'yaml-eslint-parser';
|
|
|
46
47
|
export { yamlEslintParser as parserYaml };
|
|
47
48
|
import * as jsoncEslintParser from 'jsonc-eslint-parser';
|
|
48
49
|
export { jsoncEslintParser as parserJsonc };
|
|
50
|
+
export { createTypeScriptImportResolver } from 'eslint-import-resolver-typescript';
|
|
49
51
|
|
|
50
52
|
/**
|
|
51
53
|
* @file Type Utils
|
|
@@ -9798,7 +9800,7 @@ type TypescriptEslintConsistentTypeAssertions = [] | [
|
|
|
9798
9800
|
({
|
|
9799
9801
|
assertionStyle: "never";
|
|
9800
9802
|
} | {
|
|
9801
|
-
assertionStyle
|
|
9803
|
+
assertionStyle?: ("as" | "angle-bracket");
|
|
9802
9804
|
objectLiteralTypeAssertions?: ("allow" | "allow-as-parameter" | "never");
|
|
9803
9805
|
})
|
|
9804
9806
|
];
|
|
@@ -17697,7 +17699,13 @@ type ConfigGitIgnoreOptions = Omit<FlatGitignoreOptions, 'strict'> & {
|
|
|
17697
17699
|
strict?: boolean;
|
|
17698
17700
|
};
|
|
17699
17701
|
type ConfigIgnoresOptions = string[];
|
|
17700
|
-
interface ConfigImportXOptions extends OptionsOverrides {
|
|
17702
|
+
interface ConfigImportXOptions extends OptionsFeatures, OptionsOverrides {
|
|
17703
|
+
/**
|
|
17704
|
+
* Use typescriptResolver if `typescript` is installed
|
|
17705
|
+
*
|
|
17706
|
+
* @default true
|
|
17707
|
+
*/
|
|
17708
|
+
preferTypeScriptResolver?: boolean;
|
|
17701
17709
|
}
|
|
17702
17710
|
interface ConfigJavaScriptOptions extends OptionsOverrides {
|
|
17703
17711
|
/**
|
|
@@ -18004,6 +18012,7 @@ declare const GLOB_JSON = "**/*.json";
|
|
|
18004
18012
|
declare const GLOB_JSON5 = "**/*.json5";
|
|
18005
18013
|
declare const GLOB_JSONC = "**/*.jsonc";
|
|
18006
18014
|
declare const GLOB_PACKAGE_JSON = "**/package.json";
|
|
18015
|
+
declare const GLOB_SVG = "**/*.svg";
|
|
18007
18016
|
declare const GLOB_VUE = "**/*.vue";
|
|
18008
18017
|
declare const GLOB_YAML = "**/*.y?(a)ml";
|
|
18009
18018
|
declare const GLOB_TOML = "**/*.toml";
|
|
@@ -18067,6 +18076,8 @@ declare const parserTypeScript: {
|
|
|
18067
18076
|
*/
|
|
18068
18077
|
declare const parserPlain: ESLintParser;
|
|
18069
18078
|
|
|
18079
|
+
declare const createNodeResolver: typeof eslint_plugin_import_x_node_resolver_js.createNodeResolver;
|
|
18080
|
+
|
|
18070
18081
|
declare const vue: (options?: ConfigVueOptions) => TypedConfigItem[];
|
|
18071
18082
|
|
|
18072
18083
|
declare const yml: (options?: ConfigYmlOptions) => TypedConfigItem[];
|
|
@@ -18152,4 +18163,4 @@ declare const unusedImports: (options?: ConfigUnusedImportsOptions) => TypedConf
|
|
|
18152
18163
|
*/
|
|
18153
18164
|
declare const DEFAULT_PRETTIER_OPTIONS: PrettierOptions;
|
|
18154
18165
|
|
|
18155
|
-
export { type Arrayable, type Awaitable, type ConfigAntfuOptions, type ConfigCommandOptions, type ConfigCommentsOptions, type ConfigDependOptions, type ConfigEsXOptions, type ConfigFormatOptions, type ConfigGitHubActionOptions, type ConfigGitIgnoreOptions, type ConfigIgnoresOptions, type ConfigImportXOptions, type ConfigJavaScriptOptions, type ConfigJsdocOptions, type ConfigJsoncOptions, type ConfigMarkdownOptions, type ConfigNames, type ConfigNodeOptions, type ConfigNtnyqOptions, type ConfigOptions, type ConfigPerfectionistOptions, type ConfigPiniaOptions, type ConfigPrettierOptions, type ConfigRegexpOptions, type ConfigSVGOOptions, type ConfigSortOptions, type ConfigSpecialsOptions, type ConfigStylisticOptions, type ConfigTestOptions, type ConfigTomlOptions, type ConfigTypeScriptOptions, type ConfigUnicornOptions, type ConfigUnoCSSOptions, type ConfigUnusedImportsOptions, type ConfigVueOptions, type ConfigYmlOptions, DEFAULT_PRETTIER_OPTIONS, type ESLintConfig, type ESLintParser, type ESLintParserOptions, type ESLintProcessor, type ESLintRuleSeverity, type ESLintRulesRecord, GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_DIST, GLOB_DTS, GLOB_EXCLUDE, GLOB_GITHUB_ACTION, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_LOCKFILE, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_NESTED, GLOB_NODE_MODULES, GLOB_PACKAGE_JSON, GLOB_PINIA_STORE, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_SVELTE, GLOB_TEST, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_TYPES, GLOB_VUE, GLOB_YAML, type InteropModuleDefault, type OptionsExtensions, type OptionsFeatures, type OptionsFiles, type OptionsOverrides, type PrettierOptions, type Pretty, type ResolvedOptions, type RuleOptions, type TSESLintParserOptions, type TypedConfigItem, antfu, command, comments, defineESLintConfig, depend, esX, format, getOverrides, githubAction, gitignore, hasPinia, hasTypeScript, hasUnoCSS, hasVitest, hasVue, ignores, importX, interopDefault, javascript, jsdoc, jsonc, jsx, loadPlugin, markdown, mergePrettierOptions, node, ntnyq, parserPlain, parserTypeScript, perfectionist, pinia, prettier, regexp, resolveSubOptions, sort, specials, stylistic, svgo, test, toArray, toml, typescript, unicorn, unocss, unusedImports, vitest, vue, yml };
|
|
18166
|
+
export { type Arrayable, type Awaitable, type ConfigAntfuOptions, type ConfigCommandOptions, type ConfigCommentsOptions, type ConfigDependOptions, type ConfigEsXOptions, type ConfigFormatOptions, type ConfigGitHubActionOptions, type ConfigGitIgnoreOptions, type ConfigIgnoresOptions, type ConfigImportXOptions, type ConfigJavaScriptOptions, type ConfigJsdocOptions, type ConfigJsoncOptions, type ConfigMarkdownOptions, type ConfigNames, type ConfigNodeOptions, type ConfigNtnyqOptions, type ConfigOptions, type ConfigPerfectionistOptions, type ConfigPiniaOptions, type ConfigPrettierOptions, type ConfigRegexpOptions, type ConfigSVGOOptions, type ConfigSortOptions, type ConfigSpecialsOptions, type ConfigStylisticOptions, type ConfigTestOptions, type ConfigTomlOptions, type ConfigTypeScriptOptions, type ConfigUnicornOptions, type ConfigUnoCSSOptions, type ConfigUnusedImportsOptions, type ConfigVueOptions, type ConfigYmlOptions, DEFAULT_PRETTIER_OPTIONS, type ESLintConfig, type ESLintParser, type ESLintParserOptions, type ESLintProcessor, type ESLintRuleSeverity, type ESLintRulesRecord, GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_DIST, GLOB_DTS, GLOB_EXCLUDE, GLOB_GITHUB_ACTION, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_LOCKFILE, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_NESTED, GLOB_NODE_MODULES, GLOB_PACKAGE_JSON, GLOB_PINIA_STORE, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_SVELTE, GLOB_SVG, GLOB_TEST, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_TYPES, GLOB_VUE, GLOB_YAML, type InteropModuleDefault, type OptionsExtensions, type OptionsFeatures, type OptionsFiles, type OptionsOverrides, type PrettierOptions, type Pretty, type ResolvedOptions, type RuleOptions, type TSESLintParserOptions, type TypedConfigItem, antfu, command, comments, createNodeResolver, defineESLintConfig, depend, esX, format, getOverrides, githubAction, gitignore, hasPinia, hasTypeScript, hasUnoCSS, hasVitest, hasVue, ignores, importX, interopDefault, javascript, jsdoc, jsonc, jsx, loadPlugin, markdown, mergePrettierOptions, node, ntnyq, parserPlain, parserTypeScript, perfectionist, pinia, prettier, regexp, resolveSubOptions, sort, specials, stylistic, svgo, test, toArray, toml, typescript, unicorn, unocss, unusedImports, vitest, vue, yml };
|
package/dist/index.d.ts
CHANGED
|
@@ -37,6 +37,7 @@ export { default as pluginStylistic } from '@stylistic/eslint-plugin';
|
|
|
37
37
|
export { default as pluginPerfectionist } from 'eslint-plugin-perfectionist';
|
|
38
38
|
export { default as pluginUnusedImports } from 'eslint-plugin-unused-imports';
|
|
39
39
|
export { default as pluginComments } from '@eslint-community/eslint-plugin-eslint-comments';
|
|
40
|
+
import * as eslint_plugin_import_x_node_resolver_js from 'eslint-plugin-import-x/node-resolver.js';
|
|
40
41
|
export { mergeProcessors, processorPassThrough } from 'eslint-merge-processors';
|
|
41
42
|
import * as vueEslintParser from 'vue-eslint-parser';
|
|
42
43
|
export { vueEslintParser as parserVue };
|
|
@@ -46,6 +47,7 @@ import * as yamlEslintParser from 'yaml-eslint-parser';
|
|
|
46
47
|
export { yamlEslintParser as parserYaml };
|
|
47
48
|
import * as jsoncEslintParser from 'jsonc-eslint-parser';
|
|
48
49
|
export { jsoncEslintParser as parserJsonc };
|
|
50
|
+
export { createTypeScriptImportResolver } from 'eslint-import-resolver-typescript';
|
|
49
51
|
|
|
50
52
|
/**
|
|
51
53
|
* @file Type Utils
|
|
@@ -9798,7 +9800,7 @@ type TypescriptEslintConsistentTypeAssertions = [] | [
|
|
|
9798
9800
|
({
|
|
9799
9801
|
assertionStyle: "never";
|
|
9800
9802
|
} | {
|
|
9801
|
-
assertionStyle
|
|
9803
|
+
assertionStyle?: ("as" | "angle-bracket");
|
|
9802
9804
|
objectLiteralTypeAssertions?: ("allow" | "allow-as-parameter" | "never");
|
|
9803
9805
|
})
|
|
9804
9806
|
];
|
|
@@ -17697,7 +17699,13 @@ type ConfigGitIgnoreOptions = Omit<FlatGitignoreOptions, 'strict'> & {
|
|
|
17697
17699
|
strict?: boolean;
|
|
17698
17700
|
};
|
|
17699
17701
|
type ConfigIgnoresOptions = string[];
|
|
17700
|
-
interface ConfigImportXOptions extends OptionsOverrides {
|
|
17702
|
+
interface ConfigImportXOptions extends OptionsFeatures, OptionsOverrides {
|
|
17703
|
+
/**
|
|
17704
|
+
* Use typescriptResolver if `typescript` is installed
|
|
17705
|
+
*
|
|
17706
|
+
* @default true
|
|
17707
|
+
*/
|
|
17708
|
+
preferTypeScriptResolver?: boolean;
|
|
17701
17709
|
}
|
|
17702
17710
|
interface ConfigJavaScriptOptions extends OptionsOverrides {
|
|
17703
17711
|
/**
|
|
@@ -18004,6 +18012,7 @@ declare const GLOB_JSON = "**/*.json";
|
|
|
18004
18012
|
declare const GLOB_JSON5 = "**/*.json5";
|
|
18005
18013
|
declare const GLOB_JSONC = "**/*.jsonc";
|
|
18006
18014
|
declare const GLOB_PACKAGE_JSON = "**/package.json";
|
|
18015
|
+
declare const GLOB_SVG = "**/*.svg";
|
|
18007
18016
|
declare const GLOB_VUE = "**/*.vue";
|
|
18008
18017
|
declare const GLOB_YAML = "**/*.y?(a)ml";
|
|
18009
18018
|
declare const GLOB_TOML = "**/*.toml";
|
|
@@ -18067,6 +18076,8 @@ declare const parserTypeScript: {
|
|
|
18067
18076
|
*/
|
|
18068
18077
|
declare const parserPlain: ESLintParser;
|
|
18069
18078
|
|
|
18079
|
+
declare const createNodeResolver: typeof eslint_plugin_import_x_node_resolver_js.createNodeResolver;
|
|
18080
|
+
|
|
18070
18081
|
declare const vue: (options?: ConfigVueOptions) => TypedConfigItem[];
|
|
18071
18082
|
|
|
18072
18083
|
declare const yml: (options?: ConfigYmlOptions) => TypedConfigItem[];
|
|
@@ -18152,4 +18163,4 @@ declare const unusedImports: (options?: ConfigUnusedImportsOptions) => TypedConf
|
|
|
18152
18163
|
*/
|
|
18153
18164
|
declare const DEFAULT_PRETTIER_OPTIONS: PrettierOptions;
|
|
18154
18165
|
|
|
18155
|
-
export { type Arrayable, type Awaitable, type ConfigAntfuOptions, type ConfigCommandOptions, type ConfigCommentsOptions, type ConfigDependOptions, type ConfigEsXOptions, type ConfigFormatOptions, type ConfigGitHubActionOptions, type ConfigGitIgnoreOptions, type ConfigIgnoresOptions, type ConfigImportXOptions, type ConfigJavaScriptOptions, type ConfigJsdocOptions, type ConfigJsoncOptions, type ConfigMarkdownOptions, type ConfigNames, type ConfigNodeOptions, type ConfigNtnyqOptions, type ConfigOptions, type ConfigPerfectionistOptions, type ConfigPiniaOptions, type ConfigPrettierOptions, type ConfigRegexpOptions, type ConfigSVGOOptions, type ConfigSortOptions, type ConfigSpecialsOptions, type ConfigStylisticOptions, type ConfigTestOptions, type ConfigTomlOptions, type ConfigTypeScriptOptions, type ConfigUnicornOptions, type ConfigUnoCSSOptions, type ConfigUnusedImportsOptions, type ConfigVueOptions, type ConfigYmlOptions, DEFAULT_PRETTIER_OPTIONS, type ESLintConfig, type ESLintParser, type ESLintParserOptions, type ESLintProcessor, type ESLintRuleSeverity, type ESLintRulesRecord, GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_DIST, GLOB_DTS, GLOB_EXCLUDE, GLOB_GITHUB_ACTION, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_LOCKFILE, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_NESTED, GLOB_NODE_MODULES, GLOB_PACKAGE_JSON, GLOB_PINIA_STORE, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_SVELTE, GLOB_TEST, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_TYPES, GLOB_VUE, GLOB_YAML, type InteropModuleDefault, type OptionsExtensions, type OptionsFeatures, type OptionsFiles, type OptionsOverrides, type PrettierOptions, type Pretty, type ResolvedOptions, type RuleOptions, type TSESLintParserOptions, type TypedConfigItem, antfu, command, comments, defineESLintConfig, depend, esX, format, getOverrides, githubAction, gitignore, hasPinia, hasTypeScript, hasUnoCSS, hasVitest, hasVue, ignores, importX, interopDefault, javascript, jsdoc, jsonc, jsx, loadPlugin, markdown, mergePrettierOptions, node, ntnyq, parserPlain, parserTypeScript, perfectionist, pinia, prettier, regexp, resolveSubOptions, sort, specials, stylistic, svgo, test, toArray, toml, typescript, unicorn, unocss, unusedImports, vitest, vue, yml };
|
|
18166
|
+
export { type Arrayable, type Awaitable, type ConfigAntfuOptions, type ConfigCommandOptions, type ConfigCommentsOptions, type ConfigDependOptions, type ConfigEsXOptions, type ConfigFormatOptions, type ConfigGitHubActionOptions, type ConfigGitIgnoreOptions, type ConfigIgnoresOptions, type ConfigImportXOptions, type ConfigJavaScriptOptions, type ConfigJsdocOptions, type ConfigJsoncOptions, type ConfigMarkdownOptions, type ConfigNames, type ConfigNodeOptions, type ConfigNtnyqOptions, type ConfigOptions, type ConfigPerfectionistOptions, type ConfigPiniaOptions, type ConfigPrettierOptions, type ConfigRegexpOptions, type ConfigSVGOOptions, type ConfigSortOptions, type ConfigSpecialsOptions, type ConfigStylisticOptions, type ConfigTestOptions, type ConfigTomlOptions, type ConfigTypeScriptOptions, type ConfigUnicornOptions, type ConfigUnoCSSOptions, type ConfigUnusedImportsOptions, type ConfigVueOptions, type ConfigYmlOptions, DEFAULT_PRETTIER_OPTIONS, type ESLintConfig, type ESLintParser, type ESLintParserOptions, type ESLintProcessor, type ESLintRuleSeverity, type ESLintRulesRecord, GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_DIST, GLOB_DTS, GLOB_EXCLUDE, GLOB_GITHUB_ACTION, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_LOCKFILE, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_NESTED, GLOB_NODE_MODULES, GLOB_PACKAGE_JSON, GLOB_PINIA_STORE, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_SVELTE, GLOB_SVG, GLOB_TEST, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_TYPES, GLOB_VUE, GLOB_YAML, type InteropModuleDefault, type OptionsExtensions, type OptionsFeatures, type OptionsFiles, type OptionsOverrides, type PrettierOptions, type Pretty, type ResolvedOptions, type RuleOptions, type TSESLintParserOptions, type TypedConfigItem, antfu, command, comments, createNodeResolver, defineESLintConfig, depend, esX, format, getOverrides, githubAction, gitignore, hasPinia, hasTypeScript, hasUnoCSS, hasVitest, hasVue, ignores, importX, interopDefault, javascript, jsdoc, jsonc, jsx, loadPlugin, markdown, mergePrettierOptions, node, ntnyq, parserPlain, parserTypeScript, perfectionist, pinia, prettier, regexp, resolveSubOptions, sort, specials, stylistic, svgo, test, toArray, toml, typescript, unicorn, unocss, unusedImports, vitest, vue, yml };
|
package/dist/index.js
CHANGED
|
@@ -63,6 +63,10 @@ import { default as default24 } from "@eslint-community/eslint-plugin-eslint-com
|
|
|
63
63
|
// src/eslint/configs.ts
|
|
64
64
|
import { configs } from "typescript-eslint";
|
|
65
65
|
|
|
66
|
+
// src/eslint/resolvers.ts
|
|
67
|
+
import { createTypeScriptImportResolver } from "eslint-import-resolver-typescript";
|
|
68
|
+
var createNodeResolver = default18.createNodeResolver;
|
|
69
|
+
|
|
66
70
|
// src/eslint/processors.ts
|
|
67
71
|
import { mergeProcessors } from "eslint-merge-processors";
|
|
68
72
|
import { processorPassThrough } from "eslint-merge-processors";
|
|
@@ -92,6 +96,7 @@ var GLOB_JSON = "**/*.json";
|
|
|
92
96
|
var GLOB_JSON5 = "**/*.json5";
|
|
93
97
|
var GLOB_JSONC = "**/*.jsonc";
|
|
94
98
|
var GLOB_PACKAGE_JSON = "**/package.json";
|
|
99
|
+
var GLOB_SVG = "**/*.svg";
|
|
95
100
|
var GLOB_VUE = "**/*.vue";
|
|
96
101
|
var GLOB_YAML = "**/*.y?(a)ml";
|
|
97
102
|
var GLOB_TOML = "**/*.toml";
|
|
@@ -1630,7 +1635,7 @@ import createCommandConfig from "eslint-plugin-command/config";
|
|
|
1630
1635
|
import { defineCommand } from "eslint-plugin-command/commands";
|
|
1631
1636
|
var regexper = defineCommand({
|
|
1632
1637
|
name: "regexper",
|
|
1633
|
-
// @regexper https://regexper.com
|
|
1638
|
+
// @regexper https://regexper.com/#%2F(%5Cb%7C%5Cs%7C%5E)(%40regexper)(%5Cs%5CS%2B)%3F(%5Cb%7C%5Cs%7C%24)%2F
|
|
1634
1639
|
match: /(\b|\s|^)(@regexper)(\s\S+)?(\b|\s|$)/,
|
|
1635
1640
|
action(ctx) {
|
|
1636
1641
|
const literal = ctx.findNodeBelow((node2) => {
|
|
@@ -1639,8 +1644,16 @@ var regexper = defineCommand({
|
|
|
1639
1644
|
if (!literal) {
|
|
1640
1645
|
return ctx.reportError("Unable to find a regexp literal to generate");
|
|
1641
1646
|
}
|
|
1642
|
-
const [
|
|
1643
|
-
|
|
1647
|
+
const [
|
|
1648
|
+
// non-use
|
|
1649
|
+
_fullStr = "",
|
|
1650
|
+
spaceBefore = "",
|
|
1651
|
+
commandStr = "",
|
|
1652
|
+
existingUrl = "",
|
|
1653
|
+
// non-use
|
|
1654
|
+
_spaceAfter = ""
|
|
1655
|
+
] = ctx.matches;
|
|
1656
|
+
const url = `https://regexper.com/#${encodeURIComponent(literal.raw)}`;
|
|
1644
1657
|
if (existingUrl.trim() === url.trim()) {
|
|
1645
1658
|
return;
|
|
1646
1659
|
}
|
|
@@ -1694,38 +1707,46 @@ var ignores = (customIgnores = []) => [
|
|
|
1694
1707
|
];
|
|
1695
1708
|
|
|
1696
1709
|
// src/configs/importX.ts
|
|
1697
|
-
var
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
"import-x
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1710
|
+
var importX = (options = {}) => {
|
|
1711
|
+
const {
|
|
1712
|
+
typescript: enableTypeScript,
|
|
1713
|
+
// use typescript resolve if possible
|
|
1714
|
+
preferTypeScriptResolver = true
|
|
1715
|
+
} = options;
|
|
1716
|
+
return [
|
|
1717
|
+
{
|
|
1718
|
+
name: "ntnyq/import-x",
|
|
1719
|
+
plugins: {
|
|
1720
|
+
"import-x": default18
|
|
1721
|
+
},
|
|
1722
|
+
settings: {
|
|
1723
|
+
"import-x/resolver-next": [
|
|
1724
|
+
enableTypeScript && preferTypeScriptResolver ? createTypeScriptImportResolver({
|
|
1725
|
+
extensions: [".ts", ".tsx", ".d.ts", ".js", ".jsx", ".json", ".node"]
|
|
1726
|
+
}) : createNodeResolver({
|
|
1727
|
+
extensions: [".js", ".mjs", ".ts", ".mts", ".d.ts", ".json"]
|
|
1728
|
+
})
|
|
1729
|
+
]
|
|
1730
|
+
},
|
|
1731
|
+
rules: {
|
|
1732
|
+
"import-x/no-unresolved": "off",
|
|
1733
|
+
"import-x/no-absolute-path": "off",
|
|
1734
|
+
"import-x/no-named-as-default-member": "off",
|
|
1735
|
+
"import-x/no-named-default": "off",
|
|
1736
|
+
// disabled in favor or `perfectionist/sort-imports`
|
|
1737
|
+
"import-x/order": "off",
|
|
1738
|
+
"import-x/first": "error",
|
|
1739
|
+
"import-x/export": "error",
|
|
1740
|
+
"import-x/no-self-import": "error",
|
|
1741
|
+
"import-x/no-duplicates": "error",
|
|
1742
|
+
"import-x/no-mutable-exports": "error",
|
|
1743
|
+
"import-x/newline-after-import": "error",
|
|
1744
|
+
// Overrides rules
|
|
1745
|
+
...options.overrides
|
|
1746
|
+
}
|
|
1726
1747
|
}
|
|
1727
|
-
|
|
1728
|
-
|
|
1748
|
+
];
|
|
1749
|
+
};
|
|
1729
1750
|
|
|
1730
1751
|
// src/configs/unicorn.ts
|
|
1731
1752
|
var disabledRules2 = {
|
|
@@ -1975,7 +1996,7 @@ var markdown = (options = {}) => {
|
|
|
1975
1996
|
// src/configs/prettier.ts
|
|
1976
1997
|
var prettier = (options = {}) => {
|
|
1977
1998
|
const {
|
|
1978
|
-
disabledFiles = [GLOB_TOML, GLOB_ASTRO, GLOB_SVELTE],
|
|
1999
|
+
disabledFiles = [GLOB_SVG, GLOB_TOML, GLOB_ASTRO, GLOB_SVELTE],
|
|
1979
2000
|
// User defined disabled files
|
|
1980
2001
|
userDisabledFiles = []
|
|
1981
2002
|
} = options;
|
|
@@ -2920,6 +2941,8 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
2920
2941
|
...resolveSubOptions(options, "command")
|
|
2921
2942
|
}),
|
|
2922
2943
|
...importX({
|
|
2944
|
+
...resolveSubOptions(options, "importX"),
|
|
2945
|
+
typescript: !!enableTypeScript,
|
|
2923
2946
|
overrides: getOverrides(options, "importX")
|
|
2924
2947
|
}),
|
|
2925
2948
|
...jsdoc({
|
|
@@ -3117,6 +3140,7 @@ export {
|
|
|
3117
3140
|
GLOB_SRC_EXT,
|
|
3118
3141
|
GLOB_STYLE,
|
|
3119
3142
|
GLOB_SVELTE,
|
|
3143
|
+
GLOB_SVG,
|
|
3120
3144
|
GLOB_TEST,
|
|
3121
3145
|
GLOB_TOML,
|
|
3122
3146
|
GLOB_TS,
|
|
@@ -3127,6 +3151,8 @@ export {
|
|
|
3127
3151
|
antfu,
|
|
3128
3152
|
command,
|
|
3129
3153
|
comments,
|
|
3154
|
+
createNodeResolver,
|
|
3155
|
+
createTypeScriptImportResolver,
|
|
3130
3156
|
defineESLintConfig,
|
|
3131
3157
|
depend,
|
|
3132
3158
|
esX,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ntnyq/eslint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.10.
|
|
4
|
+
"version": "3.10.3",
|
|
5
5
|
"packageManager": "pnpm@9.15.1",
|
|
6
6
|
"description": "An opinionated ESLint config preset of ntnyq",
|
|
7
7
|
"keywords": [
|
|
@@ -59,10 +59,11 @@
|
|
|
59
59
|
"@eslint/js": "^9.17.0",
|
|
60
60
|
"@eslint/markdown": "^6.2.1",
|
|
61
61
|
"@stylistic/eslint-plugin": "^2.12.1",
|
|
62
|
-
"@unocss/eslint-plugin": "^0.65.
|
|
62
|
+
"@unocss/eslint-plugin": "^0.65.3",
|
|
63
63
|
"@vitest/eslint-plugin": "^1.1.20",
|
|
64
64
|
"eslint-config-flat-gitignore": "^0.3.0",
|
|
65
65
|
"eslint-flat-config-utils": "^0.4.0",
|
|
66
|
+
"eslint-import-resolver-typescript": "^3.7.0",
|
|
66
67
|
"eslint-merge-processors": "^0.1.0",
|
|
67
68
|
"eslint-plugin-antfu": "^2.7.0",
|
|
68
69
|
"eslint-plugin-command": "^0.2.7",
|
|
@@ -79,7 +80,7 @@
|
|
|
79
80
|
"eslint-plugin-pinia": "^0.4.1",
|
|
80
81
|
"eslint-plugin-prettier": "^5.2.1",
|
|
81
82
|
"eslint-plugin-regexp": "^2.7.0",
|
|
82
|
-
"eslint-plugin-svgo": "^0.
|
|
83
|
+
"eslint-plugin-svgo": "^0.3.1",
|
|
83
84
|
"eslint-plugin-toml": "^0.12.0",
|
|
84
85
|
"eslint-plugin-unicorn": "^56.0.1",
|
|
85
86
|
"eslint-plugin-unused-imports": "^4.1.4",
|
|
@@ -91,7 +92,7 @@
|
|
|
91
92
|
"local-pkg": "^0.5.1",
|
|
92
93
|
"prettier": "^3.4.2",
|
|
93
94
|
"toml-eslint-parser": "^0.10.0",
|
|
94
|
-
"typescript-eslint": "^8.18.
|
|
95
|
+
"typescript-eslint": "^8.18.2",
|
|
95
96
|
"vue-eslint-parser": "^9.4.3",
|
|
96
97
|
"yaml-eslint-parser": "^1.2.3"
|
|
97
98
|
},
|
|
@@ -109,7 +110,7 @@
|
|
|
109
110
|
"tsx": "^4.19.2",
|
|
110
111
|
"typescript": "^5.7.2",
|
|
111
112
|
"vitest": "^3.0.0-beta.3",
|
|
112
|
-
"zx": "^8.
|
|
113
|
+
"zx": "^8.3.0"
|
|
113
114
|
},
|
|
114
115
|
"engines": {
|
|
115
116
|
"node": ">=18.18.0"
|