@ntnyq/eslint-config 3.0.0-beta.10 → 3.0.0-beta.12
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 +105 -6
- package/dist/index.cjs +16 -11
- package/dist/index.d.cts +6204 -2981
- package/dist/index.d.ts +6204 -2981
- package/dist/index.js +20 -15
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ pnpm add eslint prettier typescript @ntnyq/eslint-config @ntnyq/prettier-config
|
|
|
14
14
|
|
|
15
15
|
## Usage
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
Highly recommended for using `eslint.config.mjs` as the config file :
|
|
18
18
|
|
|
19
19
|
```js
|
|
20
20
|
import { ntnyq } from '@ntnyq/eslint-config'
|
|
@@ -22,12 +22,15 @@ import { ntnyq } from '@ntnyq/eslint-config'
|
|
|
22
22
|
export default ntnyq()
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
Add scripts `lint` in `package.json`:
|
|
26
26
|
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
```json
|
|
28
|
+
{
|
|
29
|
+
"scripts": {
|
|
30
|
+
"lint": "eslint .",
|
|
31
|
+
"lint:fix": "eslint . --fix"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
31
34
|
```
|
|
32
35
|
|
|
33
36
|
## VSCode Config
|
|
@@ -57,6 +60,102 @@ module.exports = ntnyq()
|
|
|
57
60
|
}
|
|
58
61
|
```
|
|
59
62
|
|
|
63
|
+
## Lint changed files only
|
|
64
|
+
|
|
65
|
+
### 1. Add dependencies
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
pnpm add husky nano-staged -D
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### 2. Config `package.json`
|
|
72
|
+
|
|
73
|
+
```json
|
|
74
|
+
{
|
|
75
|
+
"scripts": {
|
|
76
|
+
"prepare": "husky"
|
|
77
|
+
},
|
|
78
|
+
"nano-staged": {
|
|
79
|
+
"*.{js,ts,cjs,mjs,vue,md,yml,yaml,json,html}": "eslint --fix"
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### 3. Add a hook
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
echo "nano-staged" > .husky/pre-commit
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Advanced config
|
|
91
|
+
|
|
92
|
+
Check for detail in:
|
|
93
|
+
|
|
94
|
+
- [./src/types/config.ts](https://github.com/ntnyq/eslint-config/blob/main/src/types/config.ts)
|
|
95
|
+
- [./src/core.ts](https://github.com/ntnyq/eslint-config/blob/main/src/core.ts)
|
|
96
|
+
|
|
97
|
+
### Config interface
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
export interface ConfigOptions {
|
|
101
|
+
sortTsConfig?: boolean
|
|
102
|
+
|
|
103
|
+
sortI18nLocale?: boolean
|
|
104
|
+
|
|
105
|
+
sortPackageJson?: boolean
|
|
106
|
+
|
|
107
|
+
ignores?: ConfigIgnoresOptions
|
|
108
|
+
|
|
109
|
+
command?: boolean | ConfigCommandOptions
|
|
110
|
+
|
|
111
|
+
gitignore?: boolean | ConfigGitIgnoreOptions
|
|
112
|
+
|
|
113
|
+
imports?: ConfigImportsOptions
|
|
114
|
+
|
|
115
|
+
node?: ConfigNodeOptions
|
|
116
|
+
|
|
117
|
+
javascript?: ConfigJavaScriptOptions
|
|
118
|
+
|
|
119
|
+
typescript?: boolean | ConfigTypeScriptOptions
|
|
120
|
+
|
|
121
|
+
unicorn?: boolean | ConfigUnicornOptions
|
|
122
|
+
|
|
123
|
+
prettier?: boolean | ConfigPrettierOptions
|
|
124
|
+
|
|
125
|
+
perfectionist?: boolean | ConfigPerfectionistOptions
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* @internal
|
|
129
|
+
*/
|
|
130
|
+
unusedImports?: boolean | ConfigUnusedImportsOptions
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* @internal
|
|
134
|
+
*/
|
|
135
|
+
antfu?: boolean | ConfigAntfuOptions
|
|
136
|
+
|
|
137
|
+
comments?: boolean | ConfigCommentsOptions
|
|
138
|
+
|
|
139
|
+
jsdoc?: boolean | ConfigJsdocOptions
|
|
140
|
+
|
|
141
|
+
unocss?: boolean | ConfigUnoCSSOptions
|
|
142
|
+
|
|
143
|
+
regexp?: boolean | ConfigRegexpOptions
|
|
144
|
+
|
|
145
|
+
jsonc?: boolean | ConfigJsoncOptions
|
|
146
|
+
|
|
147
|
+
yml?: boolean | ConfigYmlOptions
|
|
148
|
+
|
|
149
|
+
markdown?: boolean | ConfigMarkdownOptions
|
|
150
|
+
|
|
151
|
+
toml?: boolean | ConfigTomlOptions
|
|
152
|
+
|
|
153
|
+
vue?: boolean | ConfigVueOptions
|
|
154
|
+
|
|
155
|
+
vitest?: boolean | ConfigVitestOptions
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
60
159
|
## Credits
|
|
61
160
|
|
|
62
161
|
- [@sxzz/eslint-config](https://github.com/sxzz/eslint-config)
|
package/dist/index.cjs
CHANGED
|
@@ -317,7 +317,7 @@ var typescript = (options = {}) => [
|
|
|
317
317
|
...typescriptCore(options),
|
|
318
318
|
{
|
|
319
319
|
name: "ntnyq/ts/dts",
|
|
320
|
-
files: [GLOB_DTS],
|
|
320
|
+
files: [GLOB_DTS, "**/types/**/*.ts"],
|
|
321
321
|
rules: {
|
|
322
322
|
"no-use-before-define": "off",
|
|
323
323
|
"no-restricted-syntax": "off",
|
|
@@ -1622,8 +1622,8 @@ var perfectionist = (options = {}) => [
|
|
|
1622
1622
|
*/
|
|
1623
1623
|
"unknown"
|
|
1624
1624
|
],
|
|
1625
|
-
order: "asc",
|
|
1626
|
-
type: "natural",
|
|
1625
|
+
order: options.imports?.order || "asc",
|
|
1626
|
+
type: options.imports?.type || "natural",
|
|
1627
1627
|
ignoreCase: true,
|
|
1628
1628
|
internalPattern: ["~/**", "@/**", "#**"],
|
|
1629
1629
|
newlinesBetween: "ignore"
|
|
@@ -1632,15 +1632,15 @@ var perfectionist = (options = {}) => [
|
|
|
1632
1632
|
"perfectionist/sort-exports": [
|
|
1633
1633
|
"error",
|
|
1634
1634
|
{
|
|
1635
|
-
order: "asc",
|
|
1636
|
-
type: "line-length"
|
|
1635
|
+
order: options.exports?.order || "asc",
|
|
1636
|
+
type: options.exports?.type || "line-length"
|
|
1637
1637
|
}
|
|
1638
1638
|
],
|
|
1639
1639
|
"perfectionist/sort-named-exports": [
|
|
1640
1640
|
"error",
|
|
1641
1641
|
{
|
|
1642
|
-
type: "alphabetical",
|
|
1643
|
-
order: "asc",
|
|
1642
|
+
type: options.namedExports?.type || "alphabetical",
|
|
1643
|
+
order: options.namedExports?.order || "asc",
|
|
1644
1644
|
ignoreCase: true,
|
|
1645
1645
|
groupKind: "values-first"
|
|
1646
1646
|
}
|
|
@@ -1648,8 +1648,8 @@ var perfectionist = (options = {}) => [
|
|
|
1648
1648
|
"perfectionist/sort-named-imports": [
|
|
1649
1649
|
"error",
|
|
1650
1650
|
{
|
|
1651
|
-
type: "alphabetical",
|
|
1652
|
-
order: "asc",
|
|
1651
|
+
type: options.namedImports?.type || "alphabetical",
|
|
1652
|
+
order: options.namedImports?.order || "asc",
|
|
1653
1653
|
ignoreCase: true,
|
|
1654
1654
|
ignoreAlias: false,
|
|
1655
1655
|
groupKind: "values-first"
|
|
@@ -1672,12 +1672,16 @@ var unusedImports = (options = {}) => [
|
|
|
1672
1672
|
"@typescript-eslint/no-unused-vars": "off",
|
|
1673
1673
|
"unused-imports/no-unused-imports": "error",
|
|
1674
1674
|
"unused-imports/no-unused-vars": [
|
|
1675
|
-
"
|
|
1675
|
+
"error",
|
|
1676
1676
|
{
|
|
1677
1677
|
vars: "all",
|
|
1678
1678
|
varsIgnorePattern: "^_",
|
|
1679
1679
|
args: "after-used",
|
|
1680
|
-
argsIgnorePattern: "^_"
|
|
1680
|
+
argsIgnorePattern: "^_",
|
|
1681
|
+
ignoreRestSiblings: true,
|
|
1682
|
+
destructuredArrayIgnorePattern: "^_",
|
|
1683
|
+
caughtErrors: "all",
|
|
1684
|
+
caughtErrorsIgnorePattern: "^_"
|
|
1681
1685
|
}
|
|
1682
1686
|
],
|
|
1683
1687
|
// Overrides built-in rules
|
|
@@ -1756,6 +1760,7 @@ function ntnyq(options = {}, userConfigs = []) {
|
|
|
1756
1760
|
if (options.perfectionist ?? true) {
|
|
1757
1761
|
configs.push(
|
|
1758
1762
|
...perfectionist({
|
|
1763
|
+
...resolveSubOptions(options, "perfectionist"),
|
|
1759
1764
|
overrides: getOverrides(options, "perfectionist")
|
|
1760
1765
|
})
|
|
1761
1766
|
);
|