@ntnyq/eslint-config 2.0.0-beta.2 → 2.0.0-beta.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/index.js +2 -0
- package/lib/astro.js +1 -2
- package/lib/js.js +0 -3
- package/lib/jsonc.js +1 -2
- package/lib/markdown.js +6 -3
- package/lib/presets.js +40 -4
- package/lib/prettier.js +1 -4
- package/lib/shared.js +13 -12
- package/lib/ts.js +10 -3
- package/lib/vue.js +44 -3
- package/lib/yml.js +1 -2
- package/package.json +20 -19
package/index.js
CHANGED
package/lib/astro.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import astroPlugin, { configs } from 'eslint-plugin-astro'
|
|
2
2
|
import astroParser from 'astro-eslint-parser'
|
|
3
|
-
import {
|
|
3
|
+
import { GLOB_ASTRO } from './shared.js'
|
|
4
4
|
|
|
5
5
|
/** @type {import('eslint-define-config').FlatESLintConfig[]} */
|
|
6
6
|
export const astro = [
|
|
7
7
|
{
|
|
8
8
|
files: [GLOB_ASTRO],
|
|
9
|
-
ignores: GLOB_EXCLUDE,
|
|
10
9
|
plugins: {
|
|
11
10
|
astro: astroPlugin,
|
|
12
11
|
},
|
package/lib/js.js
CHANGED
|
@@ -2,7 +2,6 @@ import globals from 'globals'
|
|
|
2
2
|
import jsConfig from '@eslint/js'
|
|
3
3
|
import importPlugin from 'eslint-plugin-import'
|
|
4
4
|
import unicornPlugin from 'eslint-plugin-unicorn'
|
|
5
|
-
import { GLOB_EXCLUDE } from './shared.js'
|
|
6
5
|
|
|
7
6
|
/** @type {import('eslint-define-config').FlatESLintConfig[]} */
|
|
8
7
|
export const js = [
|
|
@@ -21,7 +20,6 @@ export const js = [
|
|
|
21
20
|
|
|
22
21
|
{
|
|
23
22
|
files: ['**/scripts/*', '**/cli.*'],
|
|
24
|
-
ignores: GLOB_EXCLUDE,
|
|
25
23
|
rules: {
|
|
26
24
|
'no-console': 'off',
|
|
27
25
|
},
|
|
@@ -40,7 +38,6 @@ export const js = [
|
|
|
40
38
|
export const jsx = [
|
|
41
39
|
{
|
|
42
40
|
files: ['**/*.jsx'],
|
|
43
|
-
ignores: GLOB_EXCLUDE,
|
|
44
41
|
languageOptions: {
|
|
45
42
|
parserOptions: {
|
|
46
43
|
ecmaFeatures: {
|
package/lib/jsonc.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import jsoncPlugin, { configs } from 'eslint-plugin-jsonc'
|
|
2
2
|
import jsoncParser from 'jsonc-eslint-parser'
|
|
3
|
-
import {
|
|
3
|
+
import { GLOB_JSON, GLOB_JSON5, GLOB_JSONC } from './shared.js'
|
|
4
4
|
|
|
5
5
|
/** @type {import('eslint-define-config').FlatESLintConfig[]} */
|
|
6
6
|
export const jsonc = [
|
|
7
7
|
{
|
|
8
8
|
files: [GLOB_JSON, GLOB_JSON5, GLOB_JSONC, '**/*rc'],
|
|
9
|
-
ignores: GLOB_EXCLUDE,
|
|
10
9
|
plugins: {
|
|
11
10
|
jsonc: jsoncPlugin,
|
|
12
11
|
},
|
package/lib/markdown.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import markdownPlugin from 'eslint-plugin-markdown'
|
|
2
|
-
import
|
|
2
|
+
import tsPlugin from '@typescript-eslint/eslint-plugin'
|
|
3
|
+
import { GLOB_MARKDOWN, GLOB_SRC, GLOB_VUE } from './shared.js'
|
|
3
4
|
|
|
4
5
|
/** @type {import('eslint-define-config').FlatESLintConfig[]} */
|
|
5
6
|
export const markdown = [
|
|
6
7
|
{
|
|
7
8
|
files: [GLOB_MARKDOWN],
|
|
8
|
-
ignores: GLOB_EXCLUDE,
|
|
9
9
|
plugins: {
|
|
10
10
|
markdown: markdownPlugin,
|
|
11
11
|
},
|
|
12
12
|
processor: 'markdown/markdown',
|
|
13
13
|
},
|
|
14
14
|
{
|
|
15
|
-
files: [
|
|
15
|
+
files: [`**/*.md/${GLOB_SRC}`, `**/*.md/${GLOB_VUE}`],
|
|
16
16
|
languageOptions: {
|
|
17
17
|
parserOptions: {
|
|
18
18
|
ecmaFeatures: {
|
|
@@ -20,6 +20,9 @@ export const markdown = [
|
|
|
20
20
|
},
|
|
21
21
|
},
|
|
22
22
|
},
|
|
23
|
+
plugins: {
|
|
24
|
+
'@typescript-eslint': tsPlugin,
|
|
25
|
+
},
|
|
23
26
|
rules: {
|
|
24
27
|
...markdownPlugin.configs.recommended.overrides[1].rules,
|
|
25
28
|
'no-undef': 'off',
|
package/lib/presets.js
CHANGED
|
@@ -1,15 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
2
3
|
import { ts } from './ts.js'
|
|
3
4
|
import { yml } from './yml.js'
|
|
4
5
|
import { vue } from './vue.js'
|
|
6
|
+
import { astro } from './astro.js'
|
|
7
|
+
import { prettier } from './prettier.js'
|
|
5
8
|
import { markdown } from './markdown.js'
|
|
6
9
|
import { jsonc, pkgOrder } from './jsonc.js'
|
|
7
10
|
import { imports, js, jsx, unicorn } from './js.js'
|
|
8
11
|
import { eslintComments } from './eslint-comments.js'
|
|
12
|
+
import { GLOB_EXCLUDE } from './shared.js'
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @typedef { import('eslint-define-config').FlatESLintConfig } FlatESLintConfig
|
|
16
|
+
*/
|
|
9
17
|
|
|
10
|
-
/** @type {
|
|
11
|
-
export const
|
|
12
|
-
|
|
18
|
+
/** @type {FlatESLintConfig[]} */
|
|
19
|
+
export const basic = [
|
|
20
|
+
{ ignores: GLOB_EXCLUDE },
|
|
13
21
|
...js,
|
|
14
22
|
...jsx,
|
|
15
23
|
...ts,
|
|
@@ -22,3 +30,31 @@ export const presetBasic = [
|
|
|
22
30
|
...markdown,
|
|
23
31
|
...eslintComments,
|
|
24
32
|
]
|
|
33
|
+
|
|
34
|
+
/** @type {FlatESLintConfig[]} */
|
|
35
|
+
export const all = [...vue, ...astro, ...basic, ...prettier]
|
|
36
|
+
|
|
37
|
+
/** @type {(config?: FlatESLintConfig | FlatESLintConfig[], enables?: Partial<{
|
|
38
|
+
* vue: boolean
|
|
39
|
+
* prettier: boolean
|
|
40
|
+
* markdown: boolean
|
|
41
|
+
* }>) => FlatESLintConfig[]} */
|
|
42
|
+
export function ntnyq(
|
|
43
|
+
config = [],
|
|
44
|
+
{ vue: enableVue = true, prettier: enablePrettier = true, markdown: enableMarkdown = true } = {},
|
|
45
|
+
) {
|
|
46
|
+
const configs = [...basic]
|
|
47
|
+
if (enableVue !== false) {
|
|
48
|
+
configs.push(...vue)
|
|
49
|
+
}
|
|
50
|
+
if (enableMarkdown !== false) {
|
|
51
|
+
configs.push(...markdown)
|
|
52
|
+
}
|
|
53
|
+
if (enablePrettier !== false) {
|
|
54
|
+
configs.push(...prettier)
|
|
55
|
+
}
|
|
56
|
+
if (Object.keys(config).length > 0) {
|
|
57
|
+
configs.push(...(Array.isArray(config) ? config : [config]))
|
|
58
|
+
}
|
|
59
|
+
return configs
|
|
60
|
+
}
|
package/lib/prettier.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import prettierPlugin from 'eslint-plugin-prettier'
|
|
2
2
|
import prettierConfig from 'eslint-config-prettier'
|
|
3
3
|
|
|
4
|
-
const prettierConflictRules = { ...prettierConfig.rules }
|
|
5
|
-
delete prettierConflictRules['vue/html-self-closing']
|
|
6
|
-
|
|
7
4
|
/** @type {import('eslint-define-config').FlatESLintConfigItem[]} */
|
|
8
5
|
export const prettier = [
|
|
9
6
|
{
|
|
@@ -11,7 +8,7 @@ export const prettier = [
|
|
|
11
8
|
prettier: prettierPlugin,
|
|
12
9
|
},
|
|
13
10
|
rules: {
|
|
14
|
-
...
|
|
11
|
+
...prettierConfig.rules,
|
|
15
12
|
...prettierPlugin.configs.recommended.rules,
|
|
16
13
|
'prettier/prettier': 'warn',
|
|
17
14
|
},
|
package/lib/shared.js
CHANGED
|
@@ -24,7 +24,7 @@ export const GLOB_MARKDOWN = '**/*.md'
|
|
|
24
24
|
export const GLOB_YAML = '**/*.y?(a)ml'
|
|
25
25
|
export const GLOB_HTML = '**/*.htm?(l)'
|
|
26
26
|
|
|
27
|
-
export const GLOB_ALL_SRC =
|
|
27
|
+
export const GLOB_ALL_SRC = [
|
|
28
28
|
GLOB_SRC,
|
|
29
29
|
GLOB_STYLE,
|
|
30
30
|
GLOB_JSON,
|
|
@@ -33,16 +33,12 @@ export const GLOB_ALL_SRC = /** @type {const} */ ([
|
|
|
33
33
|
GLOB_VUE,
|
|
34
34
|
GLOB_YAML,
|
|
35
35
|
GLOB_HTML,
|
|
36
|
-
]
|
|
37
|
-
|
|
38
|
-
export const GLOB_NODE_MODULES =
|
|
39
|
-
export const GLOB_DIST =
|
|
40
|
-
export const GLOB_LOCKFILE =
|
|
41
|
-
|
|
42
|
-
'**/yarn.lock',
|
|
43
|
-
'**/pnpm-lock.yaml',
|
|
44
|
-
])
|
|
45
|
-
export const GLOB_EXCLUDE = /** @type {const} */ ([
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
export const GLOB_NODE_MODULES = '**/node_modules/**'
|
|
39
|
+
export const GLOB_DIST = '**/dist/**'
|
|
40
|
+
export const GLOB_LOCKFILE = ['**/package-lock.json', '**/yarn.lock', '**/pnpm-lock.yaml']
|
|
41
|
+
export const GLOB_EXCLUDE = [
|
|
46
42
|
GLOB_NODE_MODULES,
|
|
47
43
|
GLOB_DIST,
|
|
48
44
|
...GLOB_LOCKFILE,
|
|
@@ -52,10 +48,15 @@ export const GLOB_EXCLUDE = /** @type {const} */ ([
|
|
|
52
48
|
'**/output',
|
|
53
49
|
'**/coverage',
|
|
54
50
|
'**/temp',
|
|
51
|
+
'**/cache',
|
|
55
52
|
'**/fixtures',
|
|
53
|
+
'**/.vitepress/cache',
|
|
54
|
+
'**/.nuxt',
|
|
55
|
+
'**/.vercel',
|
|
56
|
+
'**/.changeset',
|
|
56
57
|
'**/__snapshots__',
|
|
57
58
|
'**/auto-import.d.ts',
|
|
58
59
|
'**/components.d.ts',
|
|
59
60
|
'**/.npmrc',
|
|
60
61
|
'**/.yarnrc',
|
|
61
|
-
]
|
|
62
|
+
]
|
package/lib/ts.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import tsParser from '@typescript-eslint/parser'
|
|
2
2
|
import tsPlugin from '@typescript-eslint/eslint-plugin'
|
|
3
|
-
import {
|
|
3
|
+
import { GLOB_TS, GLOB_TSX } from './shared.js'
|
|
4
|
+
|
|
5
|
+
export { tsParser, tsPlugin }
|
|
4
6
|
|
|
5
7
|
/** @type {import('eslint-define-config').FlatESLintConfig[]} */
|
|
6
8
|
export const ts = [
|
|
7
9
|
{
|
|
8
10
|
files: [GLOB_TS, GLOB_TSX],
|
|
9
|
-
ignores: GLOB_EXCLUDE,
|
|
10
11
|
languageOptions: {
|
|
11
12
|
parser: tsParser,
|
|
12
13
|
parserOptions: {
|
|
@@ -53,7 +54,6 @@ export const ts = [
|
|
|
53
54
|
|
|
54
55
|
{
|
|
55
56
|
files: ['**/*.d.ts'],
|
|
56
|
-
ignores: GLOB_EXCLUDE,
|
|
57
57
|
rules: {
|
|
58
58
|
'import/no-duplicates': 'off',
|
|
59
59
|
'import/newline-after-import': 'off',
|
|
@@ -67,4 +67,11 @@ export const ts = [
|
|
|
67
67
|
'max-lines-per-function': 'off',
|
|
68
68
|
},
|
|
69
69
|
},
|
|
70
|
+
|
|
71
|
+
{
|
|
72
|
+
files: ['**/*.js', '**/*.cjs'],
|
|
73
|
+
rules: {
|
|
74
|
+
'@typescript-eslint/no-var-requires': 'off',
|
|
75
|
+
},
|
|
76
|
+
},
|
|
70
77
|
]
|
package/lib/vue.js
CHANGED
|
@@ -1,23 +1,64 @@
|
|
|
1
|
+
import { getPackageInfoSync } from 'local-pkg'
|
|
1
2
|
import vuePlugin from 'eslint-plugin-vue'
|
|
2
3
|
import vueParser from 'vue-eslint-parser'
|
|
3
|
-
import
|
|
4
|
+
import tsPlugin from '@typescript-eslint/eslint-plugin'
|
|
5
|
+
import { ts } from './ts.js'
|
|
6
|
+
import { GLOB_VUE } from './shared.js'
|
|
7
|
+
|
|
8
|
+
export { vueParser, vuePlugin }
|
|
9
|
+
|
|
10
|
+
export function getVueVersion() {
|
|
11
|
+
const pkg = getPackageInfoSync('vue', { paths: [process.cwd()] })
|
|
12
|
+
if (pkg && typeof pkg.version === 'string' && !Number.isNaN(+pkg.version[0])) {
|
|
13
|
+
return +pkg.version[0]
|
|
14
|
+
}
|
|
15
|
+
return 3
|
|
16
|
+
}
|
|
17
|
+
const isVue3 = getVueVersion() === 3
|
|
18
|
+
|
|
19
|
+
/** @type {import('eslint-define-config').Rules} */
|
|
20
|
+
const vueBaseRules = {}
|
|
21
|
+
|
|
22
|
+
/** @type {import('eslint-define-config').Rules} */
|
|
23
|
+
const vue2Rules = {
|
|
24
|
+
...vueBaseRules,
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** @type {import('eslint-define-config').Rules} */
|
|
28
|
+
const vue3Rules = {
|
|
29
|
+
...vueBaseRules,
|
|
30
|
+
}
|
|
4
31
|
|
|
5
32
|
/** @type {import('eslint-define-config').FlatESLintConfig[]} */
|
|
6
33
|
export const vue = [
|
|
7
34
|
{
|
|
8
35
|
files: [GLOB_VUE],
|
|
9
|
-
ignores: GLOB_EXCLUDE,
|
|
10
36
|
plugins: {
|
|
11
37
|
vue: vuePlugin,
|
|
38
|
+
'@typescript-eslint': tsPlugin,
|
|
12
39
|
},
|
|
13
40
|
languageOptions: {
|
|
14
41
|
parser: vueParser,
|
|
15
42
|
parserOptions: {
|
|
16
43
|
parser: '@typescript-eslint/parser',
|
|
44
|
+
sourceType: 'module',
|
|
45
|
+
extraFileExtensions: ['.vue'],
|
|
46
|
+
ecmaFeatures: {
|
|
47
|
+
jsx: true,
|
|
48
|
+
},
|
|
17
49
|
},
|
|
18
50
|
},
|
|
51
|
+
processor: vuePlugin.processors['.vue'],
|
|
52
|
+
rules: {
|
|
53
|
+
...ts[0].rules,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
plugins: {
|
|
58
|
+
vue: vuePlugin,
|
|
59
|
+
},
|
|
19
60
|
rules: {
|
|
20
|
-
...
|
|
61
|
+
...(isVue3 ? vue3Rules : vue2Rules),
|
|
21
62
|
},
|
|
22
63
|
},
|
|
23
64
|
]
|
package/lib/yml.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import ymlPlugin, { configs } from 'eslint-plugin-yml'
|
|
2
2
|
import ymlParser from 'yaml-eslint-parser'
|
|
3
|
-
import {
|
|
3
|
+
import { GLOB_YAML } from './shared.js'
|
|
4
4
|
|
|
5
5
|
/** @type {import('eslint-define-config').FlatESLintConfig[]} */
|
|
6
6
|
export const yml = [
|
|
7
7
|
{
|
|
8
8
|
files: [GLOB_YAML],
|
|
9
|
-
ignores: GLOB_EXCLUDE,
|
|
10
9
|
languageOptions: {
|
|
11
10
|
parser: ymlParser,
|
|
12
11
|
},
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ntnyq/eslint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
5
|
-
"packageManager": "pnpm@
|
|
4
|
+
"version": "2.0.0-beta.3",
|
|
5
|
+
"packageManager": "pnpm@8.1.0",
|
|
6
6
|
"description": "",
|
|
7
7
|
"keywords": [],
|
|
8
8
|
"license": "MIT",
|
|
@@ -29,38 +29,39 @@
|
|
|
29
29
|
"eslint": "^8.30.0"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@eslint/js": "^8.
|
|
33
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
34
|
-
"@typescript-eslint/parser": "^5.
|
|
35
|
-
"astro-eslint-parser": "^0.
|
|
36
|
-
"eslint-config-prettier": "^8.
|
|
37
|
-
"eslint-plugin-astro": "^0.
|
|
32
|
+
"@eslint/js": "^8.37.0",
|
|
33
|
+
"@typescript-eslint/eslint-plugin": "^5.57.0",
|
|
34
|
+
"@typescript-eslint/parser": "^5.57.0",
|
|
35
|
+
"astro-eslint-parser": "^0.13.2",
|
|
36
|
+
"eslint-config-prettier": "^8.8.0",
|
|
37
|
+
"eslint-plugin-astro": "^0.26.1",
|
|
38
38
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
39
39
|
"eslint-plugin-import": "^2.27.5",
|
|
40
|
-
"eslint-plugin-jsonc": "^2.
|
|
40
|
+
"eslint-plugin-jsonc": "^2.7.0",
|
|
41
41
|
"eslint-plugin-markdown": "^3.0.0",
|
|
42
42
|
"eslint-plugin-prettier": "^4.2.1",
|
|
43
43
|
"eslint-plugin-unicorn": "^46.0.0",
|
|
44
|
-
"eslint-plugin-vue": "^9.
|
|
44
|
+
"eslint-plugin-vue": "^9.10.0",
|
|
45
45
|
"eslint-plugin-yml": "^1.5.0",
|
|
46
46
|
"globals": "^13.20.0",
|
|
47
47
|
"jsonc-eslint-parser": "^2.2.0",
|
|
48
|
-
"
|
|
49
|
-
"
|
|
48
|
+
"local-pkg": "^0.4.3",
|
|
49
|
+
"prettier": "^2.8.7",
|
|
50
|
+
"vue-eslint-parser": "^9.1.1",
|
|
50
51
|
"yaml-eslint-parser": "^1.2.0"
|
|
51
52
|
},
|
|
52
53
|
"devDependencies": {
|
|
53
|
-
"@ntnyq/prettier-config": "^1.
|
|
54
|
-
"@types/node": "^18.15.
|
|
55
|
-
"bumpp": "^9.
|
|
56
|
-
"eslint": "^8.
|
|
57
|
-
"eslint-define-config": "^1.
|
|
54
|
+
"@ntnyq/prettier-config": "^1.6.1",
|
|
55
|
+
"@types/node": "^18.15.11",
|
|
56
|
+
"bumpp": "^9.1.0",
|
|
57
|
+
"eslint": "^8.37.0",
|
|
58
|
+
"eslint-define-config": "^1.17.0",
|
|
58
59
|
"husky": "^8.0.3",
|
|
59
60
|
"nano-staged": "^0.8.0",
|
|
60
|
-
"typescript": "5.0.
|
|
61
|
+
"typescript": "5.0.3"
|
|
61
62
|
},
|
|
62
63
|
"engines": {
|
|
63
|
-
"node": ">=14.
|
|
64
|
+
"node": ">=16.14.0"
|
|
64
65
|
},
|
|
65
66
|
"prettier": "@ntnyq/prettier-config",
|
|
66
67
|
"scripts": {
|