@sxzz/eslint-config 2.4.6 → 3.0.0-beta.0

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
- MIT License
1
+ The MIT License (MIT)
2
2
 
3
- Copyright (c) 2021-PRESENT 三咲智子 <https://github.com/sxzz>
3
+ Copyright © 2021-PRESENT 三咲智子 (https://github.com/sxzz)
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md ADDED
@@ -0,0 +1,23 @@
1
+ # @sxzz/eslint-config [![npm](https://img.shields.io/npm/v/@sxzz/eslint-config.svg)](https://npmjs.com/package/@sxzz/eslint-config)
2
+
3
+ Flat ESLint config for JavaScript, TypeScript, Vue 2, Vue 3, Prettier.
4
+
5
+ [Legacy Version](https://github.com/sxzz/eslint-config-legacy)
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm i @sxzz/eslint-config
11
+ ```
12
+
13
+ ## Sponsors
14
+
15
+ <p align="center">
16
+ <a href="https://cdn.jsdelivr.net/gh/sxzz/sponsors/sponsors.svg">
17
+ <img src='https://cdn.jsdelivr.net/gh/sxzz/sponsors/sponsors.svg'/>
18
+ </a>
19
+ </p>
20
+
21
+ ## License
22
+
23
+ [MIT](./LICENSE) License © 2021-PRESENT [三咲智子](https://github.com/sxzz)
package/index.js CHANGED
@@ -1,3 +1,9 @@
1
- module.exports = {
2
- extends: ['@sxzz/eslint-config-vue', '@sxzz/eslint-config-prettier'],
3
- }
1
+ export * from './src/eslint-comments.js'
2
+ export * from './src/js.js'
3
+ export * from './src/jsonc.js'
4
+ export * from './src/markdown.js'
5
+ export * from './src/presets.js'
6
+ export * from './src/prettier.js'
7
+ export * from './src/typescript.js'
8
+ export * from './src/vue.js'
9
+ export * from './src/yml.js'
package/package.json CHANGED
@@ -1,13 +1,9 @@
1
1
  {
2
2
  "name": "@sxzz/eslint-config",
3
- "version": "2.4.6",
4
- "description": "三咲智子's ESLint config",
5
- "keywords": [
6
- "eslint",
7
- "config",
8
- "preset",
9
- "sxzz"
10
- ],
3
+ "version": "3.0.0-beta.0",
4
+ "packageManager": "pnpm@7.27.0",
5
+ "description": "ESLint config for @sxzz.",
6
+ "type": "module",
11
7
  "license": "MIT",
12
8
  "homepage": "https://github.com/sxzz/eslint-config#readme",
13
9
  "bugs": {
@@ -17,22 +13,57 @@
17
13
  "type": "git",
18
14
  "url": "git+https://github.com/sxzz/eslint-config.git"
19
15
  },
20
- "author": "三咲智子 <sxzz@sxzz.moe> (https://github.com/sxzz/)",
21
16
  "files": [
22
- "index.js"
17
+ "index.js",
18
+ "src"
23
19
  ],
24
- "main": "index.js",
20
+ "main": "./index.js",
21
+ "module": "./index.js",
22
+ "types": "./index.d.ts",
23
+ "exports": {
24
+ "types": "./index.d.ts",
25
+ "require": "./index.js",
26
+ "import": "./index.js"
27
+ },
25
28
  "publishConfig": {
26
29
  "access": "public"
27
30
  },
28
31
  "peerDependencies": {
29
- "eslint": ">=8.0.0"
32
+ "eslint": "^8.0.0"
30
33
  },
31
34
  "dependencies": {
32
- "@sxzz/eslint-config-prettier": "2.4.6",
33
- "@sxzz/eslint-config-vue": "2.4.6"
35
+ "@eslint/js": "^8.36.0",
36
+ "@typescript-eslint/eslint-plugin": "^5.56.0",
37
+ "@typescript-eslint/parser": "^5.56.0",
38
+ "eslint-config-prettier": "^8.8.0",
39
+ "eslint-plugin-eslint-comments": "^3.2.0",
40
+ "eslint-plugin-import": "^2.27.5",
41
+ "eslint-plugin-jsonc": "^2.7.0",
42
+ "eslint-plugin-markdown": "^3.0.0",
43
+ "eslint-plugin-prettier": "^4.2.1",
44
+ "eslint-plugin-unicorn": "^46.0.0",
45
+ "eslint-plugin-vue": "^9.9.0",
46
+ "eslint-plugin-yml": "^1.5.0",
47
+ "globals": "^13.20.0",
48
+ "jsonc-eslint-parser": "^2.2.0",
49
+ "local-pkg": "^0.4.3",
50
+ "prettier": "^2.8.6",
51
+ "vue-eslint-parser": "^9.1.0",
52
+ "yaml-eslint-parser": "^1.2.0"
34
53
  },
35
54
  "devDependencies": {
36
- "eslint": "^8.36.0"
55
+ "@types/node": "^18.15.5",
56
+ "bumpp": "^9.0.0",
57
+ "eslint": "^8.36.0",
58
+ "eslint-define-config": "^1.17.0",
59
+ "typescript": "^5.0.2"
60
+ },
61
+ "engines": {
62
+ "node": ">=14.19.0"
63
+ },
64
+ "scripts": {
65
+ "lint": "eslint .",
66
+ "lint:fix": "pnpm run lint --fix",
67
+ "release": "bumpp && pnpm publish"
37
68
  }
38
69
  }
@@ -0,0 +1,17 @@
1
+ import commentsPlugin from 'eslint-plugin-eslint-comments'
2
+
3
+ /** @type {import('eslint-define-config').FlatESLintConfig[]} */
4
+ export const eslintComments = [
5
+ {
6
+ plugins: {
7
+ 'eslint-comments': commentsPlugin,
8
+ },
9
+ rules: {
10
+ ...commentsPlugin.configs.recommended.rules,
11
+ 'eslint-comments/disable-enable-pair': [
12
+ 'error',
13
+ { allowWholeFile: true },
14
+ ],
15
+ },
16
+ },
17
+ ]
package/src/js.js ADDED
@@ -0,0 +1,205 @@
1
+ import globals from 'globals'
2
+ import jsConfig from '@eslint/js'
3
+ import importPlugin from 'eslint-plugin-import'
4
+ import unicornPlugin from 'eslint-plugin-unicorn'
5
+ import { GLOB_EXCLUDE } from './shared.js'
6
+
7
+ /** @type {import('eslint-define-config').FlatESLintConfig[]} */
8
+ export const js = [
9
+ jsConfig.configs.recommended,
10
+ {
11
+ languageOptions: {
12
+ globals: {
13
+ ...globals.browser,
14
+ ...globals.es2021,
15
+ ...globals.node,
16
+ },
17
+ sourceType: 'module',
18
+ },
19
+ rules: {
20
+ 'no-unused-vars': ['error', { args: 'none', ignoreRestSiblings: true }],
21
+ 'no-constant-condition': 'warn',
22
+ 'no-debugger': 'warn',
23
+ 'no-console': ['warn', { allow: ['warn', 'error'] }],
24
+ 'no-restricted-syntax': [
25
+ 'error',
26
+ 'ForInStatement',
27
+ 'LabeledStatement',
28
+ 'WithStatement',
29
+ ],
30
+ 'no-return-await': 'warn',
31
+ 'no-empty': ['error', { allowEmptyCatch: true }],
32
+ 'sort-imports': [
33
+ 'error',
34
+ {
35
+ ignoreCase: false,
36
+ ignoreDeclarationSort: true,
37
+ ignoreMemberSort: false,
38
+ memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
39
+ allowSeparatedGroups: false,
40
+ },
41
+ ],
42
+
43
+ 'no-var': 'error',
44
+ 'prefer-const': [
45
+ 'warn',
46
+ { destructuring: 'all', ignoreReadBeforeAssign: true },
47
+ ],
48
+ 'prefer-arrow-callback': [
49
+ 'error',
50
+ { allowNamedFunctions: false, allowUnboundThis: true },
51
+ ],
52
+ 'object-shorthand': [
53
+ 'error',
54
+ 'always',
55
+ { ignoreConstructors: false, avoidQuotes: true },
56
+ ],
57
+ 'prefer-rest-params': 'error',
58
+ 'prefer-spread': 'error',
59
+ 'prefer-template': 'error',
60
+ 'require-await': 'error',
61
+
62
+ 'array-callback-return': 'error',
63
+ 'block-scoped-var': 'error',
64
+ eqeqeq: ['error', 'smart'],
65
+ 'no-alert': 'warn',
66
+ 'no-case-declarations': 'error',
67
+ 'no-fallthrough': ['warn', { commentPattern: 'break[\\s\\w]*omitted' }],
68
+ 'no-multi-str': 'error',
69
+ 'no-with': 'error',
70
+ 'no-void': 'error',
71
+
72
+ 'no-unused-expressions': [
73
+ 'error',
74
+ {
75
+ allowShortCircuit: true,
76
+ allowTernary: true,
77
+ allowTaggedTemplates: true,
78
+ },
79
+ ],
80
+ 'no-lonely-if': 'error',
81
+ 'prefer-exponentiation-operator': 'error',
82
+ },
83
+ },
84
+ {
85
+ files: ['**/scripts/*', '**/cli.*'],
86
+ ignores: GLOB_EXCLUDE,
87
+ rules: {
88
+ 'no-console': 'off',
89
+ },
90
+ },
91
+ {
92
+ files: ['**/*.{test,spec}.js?(x)'],
93
+ rules: {
94
+ 'no-unused-expressions': 'off',
95
+ },
96
+ },
97
+ ]
98
+
99
+ /** @type {import('eslint-define-config').FlatESLintConfig[]} */
100
+ export const jsx = [
101
+ {
102
+ files: ['**/*.jsx'],
103
+ ignores: GLOB_EXCLUDE,
104
+ languageOptions: {
105
+ parserOptions: {
106
+ ecmaFeatures: {
107
+ jsx: true,
108
+ },
109
+ },
110
+ },
111
+ },
112
+ ]
113
+
114
+ /** @type {import('eslint-define-config').FlatESLintConfig[]} */
115
+ export const imports = [
116
+ {
117
+ plugins: {
118
+ import: importPlugin,
119
+ },
120
+ settings: {
121
+ 'import/resolver': {
122
+ node: { extensions: ['.js', '.mjs', '.ts', '.mts', '.d.ts'] },
123
+ },
124
+ },
125
+ rules: {
126
+ 'import/first': 'error',
127
+ 'import/no-mutable-exports': 'error',
128
+ 'import/no-duplicates': 'error',
129
+ 'import/order': [
130
+ 'error',
131
+ {
132
+ groups: [
133
+ 'builtin',
134
+ 'external',
135
+ 'internal',
136
+ 'parent',
137
+ 'sibling',
138
+ 'index',
139
+ 'object',
140
+ 'type',
141
+ ],
142
+ pathGroups: [{ pattern: '@/**', group: 'internal' }],
143
+ pathGroupsExcludedImportTypes: ['type'],
144
+ },
145
+ ],
146
+ },
147
+ },
148
+ ]
149
+
150
+ /** @type {import('eslint-define-config').FlatESLintConfig[]} */
151
+ export const unicorn = [
152
+ {
153
+ plugins: {
154
+ unicorn: unicornPlugin,
155
+ },
156
+ rules: {
157
+ 'unicorn/better-regex': 'error',
158
+ 'unicorn/custom-error-definition': 'error',
159
+ 'unicorn/error-message': 'error',
160
+ 'unicorn/escape-case': 'error',
161
+ 'unicorn/explicit-length-check': 'error',
162
+ 'unicorn/import-index': 'error',
163
+ 'unicorn/new-for-builtins': 'error',
164
+ 'unicorn/no-array-callback-reference': 'error',
165
+ 'unicorn/no-array-method-this-argument': 'error',
166
+ 'unicorn/no-array-push-push': 'error',
167
+ 'unicorn/no-console-spaces': 'error',
168
+ 'unicorn/no-for-loop': 'error',
169
+ 'unicorn/no-hex-escape': 'error',
170
+ 'unicorn/no-instanceof-array': 'error',
171
+ 'unicorn/no-invalid-remove-event-listener': 'error',
172
+ 'unicorn/no-lonely-if': 'error',
173
+ 'unicorn/no-new-array': 'error',
174
+ 'unicorn/no-new-buffer': 'error',
175
+ 'unicorn/no-unsafe-regex': 'off',
176
+ 'unicorn/number-literal-case': 'error',
177
+ 'unicorn/prefer-add-event-listener': 'error',
178
+ 'unicorn/prefer-array-find': 'error',
179
+ 'unicorn/prefer-array-flat-map': 'error',
180
+ 'unicorn/prefer-array-index-of': 'error',
181
+ 'unicorn/prefer-array-some': 'error',
182
+ 'unicorn/prefer-date-now': 'error',
183
+ 'unicorn/prefer-dom-node-append': 'error',
184
+ 'unicorn/prefer-dom-node-dataset': 'error',
185
+ 'unicorn/prefer-dom-node-remove': 'error',
186
+ 'unicorn/prefer-dom-node-text-content': 'error',
187
+ 'unicorn/prefer-includes': 'error',
188
+ 'unicorn/prefer-keyboard-event-key': 'error',
189
+ 'unicorn/prefer-math-trunc': 'error',
190
+ 'unicorn/prefer-modern-dom-apis': 'error',
191
+ 'unicorn/prefer-negative-index': 'error',
192
+ 'unicorn/prefer-node-protocol': 'error',
193
+ 'unicorn/prefer-number-properties': 'error',
194
+ 'unicorn/prefer-optional-catch-binding': 'error',
195
+ 'unicorn/prefer-prototype-methods': 'error',
196
+ 'unicorn/prefer-query-selector': 'error',
197
+ 'unicorn/prefer-reflect-apply': 'error',
198
+ 'unicorn/prefer-string-slice': 'error',
199
+ 'unicorn/prefer-string-starts-ends-with': 'error',
200
+ 'unicorn/prefer-string-trim-start-end': 'error',
201
+ 'unicorn/prefer-type-error': 'error',
202
+ 'unicorn/throw-new-error': 'error',
203
+ },
204
+ },
205
+ ]
package/src/jsonc.js ADDED
@@ -0,0 +1,83 @@
1
+ import jsoncPlugin, { configs } from 'eslint-plugin-jsonc'
2
+ import jsoncParser from 'jsonc-eslint-parser'
3
+ import { GLOB_EXCLUDE, GLOB_JSON, GLOB_JSON5, GLOB_JSONC } from './shared.js'
4
+
5
+ /** @type {import('eslint-define-config').FlatESLintConfig[]} */
6
+ export const jsonc = [
7
+ {
8
+ files: [GLOB_JSON, GLOB_JSON5, GLOB_JSONC, '**/*rc'],
9
+ ignores: GLOB_EXCLUDE,
10
+ plugins: {
11
+ jsonc: jsoncPlugin,
12
+ },
13
+ languageOptions: {
14
+ parser: jsoncParser,
15
+ },
16
+ rules: {
17
+ ...configs['recommended-with-jsonc'].rules,
18
+ 'jsonc/quote-props': 'off',
19
+ 'jsonc/quotes': 'off',
20
+ },
21
+ },
22
+ ]
23
+
24
+ /** @type {import('eslint-define-config').FlatESLintConfig[]} */
25
+ export const pkgOrder = [
26
+ {
27
+ files: ['**/package.json'],
28
+ rules: {
29
+ 'jsonc/sort-keys': [
30
+ 'error',
31
+ {
32
+ pathPattern: '^$',
33
+ order: [
34
+ 'name',
35
+ 'version',
36
+ 'private',
37
+ 'packageManager',
38
+ 'description',
39
+ 'type',
40
+ 'keywords',
41
+ 'license',
42
+ 'homepage',
43
+ 'bugs',
44
+ 'repository',
45
+ 'author',
46
+ 'contributors',
47
+ 'funding',
48
+ 'files',
49
+ 'main',
50
+ 'module',
51
+ 'types',
52
+ 'exports',
53
+ 'typesVersions',
54
+ 'unpkg',
55
+ 'jsdelivr',
56
+ 'browser',
57
+ 'bin',
58
+ 'man',
59
+ 'directories',
60
+ 'publishConfig',
61
+ 'scripts',
62
+ 'peerDependencies',
63
+ 'peerDependenciesMeta',
64
+ 'optionalDependencies',
65
+ 'dependencies',
66
+ 'devDependencies',
67
+ 'engines',
68
+ 'config',
69
+ 'overrides',
70
+ 'pnpm',
71
+ 'husky',
72
+ 'lint-staged',
73
+ 'eslintConfig',
74
+ ],
75
+ },
76
+ {
77
+ pathPattern: '^(?:dev|peer|optional|bundled)?[Dd]ependencies$',
78
+ order: { type: 'asc' },
79
+ },
80
+ ],
81
+ },
82
+ },
83
+ ]
@@ -0,0 +1,38 @@
1
+ import markdownPlugin from 'eslint-plugin-markdown'
2
+ import { GLOB_EXCLUDE, GLOB_MARKDOWN } from './shared.js'
3
+
4
+ /** @type {import('eslint-define-config').FlatESLintConfig[]} */
5
+ export const markdown = [
6
+ {
7
+ files: [GLOB_MARKDOWN],
8
+ ignores: GLOB_EXCLUDE,
9
+ plugins: {
10
+ markdown: markdownPlugin,
11
+ },
12
+ processor: 'markdown/markdown',
13
+ },
14
+ {
15
+ files: ['**/*.md/*'],
16
+ languageOptions: {
17
+ parserOptions: {
18
+ ecmaFeatures: {
19
+ impliedStrict: true,
20
+ },
21
+ },
22
+ },
23
+ rules: {
24
+ ...markdownPlugin.configs.recommended.overrides[1].rules,
25
+
26
+ '@typescript-eslint/no-redeclare': 'off',
27
+ '@typescript-eslint/no-unused-vars': 'off',
28
+ '@typescript-eslint/no-use-before-define': 'off',
29
+ '@typescript-eslint/no-var-requires': 'off',
30
+ 'no-alert': 'off',
31
+ 'no-console': 'off',
32
+ 'no-restricted-imports': 'off',
33
+ 'no-undef': 'off',
34
+ 'no-unused-expressions': 'off',
35
+ 'no-unused-vars': 'off',
36
+ },
37
+ },
38
+ ]
package/src/presets.js ADDED
@@ -0,0 +1,25 @@
1
+ import { eslintComments } from './eslint-comments.js'
2
+ import { imports, js, jsx, unicorn } from './js.js'
3
+ import { jsonc, pkgOrder } from './jsonc.js'
4
+ import { markdown } from './markdown.js'
5
+ import { prettier } from './prettier.js'
6
+ import { typescript } from './typescript.js'
7
+ import { vue } from './vue.js'
8
+ import { yml } from './yml.js'
9
+
10
+ /** @type {import('eslint-define-config').FlatESLintConfig[]} */
11
+ export const basic = [
12
+ ...js,
13
+ ...jsx,
14
+ ...typescript,
15
+ ...imports,
16
+ ...unicorn,
17
+ ...jsonc,
18
+ ...pkgOrder,
19
+ ...yml,
20
+ ...markdown,
21
+ ...eslintComments,
22
+ ]
23
+
24
+ /** @type {import('eslint-define-config').FlatESLintConfig[]} */
25
+ export const all = [...basic, ...vue, ...prettier]
@@ -0,0 +1,19 @@
1
+ import prettierPlugin from 'eslint-plugin-prettier'
2
+ import prettierConfig from 'eslint-config-prettier'
3
+
4
+ const prettierConflictRules = { ...prettierConfig.rules }
5
+ delete prettierConflictRules['vue/html-self-closing']
6
+
7
+ /** @type {import('eslint-define-config').FlatESLintConfigItem[]} */
8
+ export const prettier = [
9
+ {
10
+ plugins: {
11
+ prettier: prettierPlugin,
12
+ },
13
+ rules: {
14
+ ...prettierConflictRules,
15
+ ...prettierPlugin.configs.recommended.rules,
16
+ 'prettier/prettier': 'warn',
17
+ },
18
+ },
19
+ ]
package/src/shared.js ADDED
@@ -0,0 +1,57 @@
1
+ // @ts-check
2
+
3
+ export const GLOB_SRC = '**/*.?([mt])[jt]s?(x)'
4
+
5
+ export const GLOB_JS = '**/*.?([mt])js'
6
+ export const GLOB_JSX = '**/*.?([mt])jsx'
7
+
8
+ export const GLOB_TS = '**/*.?([mt])ts'
9
+ export const GLOB_TSX = '**/*.?([mt])tsx'
10
+
11
+ export const GLOB_STYLE = '**/*.{c,le,sc}ss'
12
+ export const GLOB_CSS = '**/*.css'
13
+ export const GLOB_LESS = '**/*.less'
14
+ export const GLOB_SCSS = '**/*.scss'
15
+
16
+ export const GLOB_JSON = '**/*.json'
17
+ export const GLOB_JSON5 = '**/*.json5'
18
+ export const GLOB_JSONC = '**/*.jsonc'
19
+
20
+ export const GLOB_MARKDOWN = '**/*.md'
21
+ export const GLOB_VUE = '**/*.vue'
22
+ export const GLOB_YAML = '**/*.y?(a)ml'
23
+ export const GLOB_HTML = '**/*.htm?(l)'
24
+
25
+ export const GLOB_ALL_SRC = /** @type {const} */ ([
26
+ GLOB_SRC,
27
+ GLOB_STYLE,
28
+ GLOB_JSON,
29
+ GLOB_JSON5,
30
+ GLOB_MARKDOWN,
31
+ GLOB_VUE,
32
+ GLOB_YAML,
33
+ GLOB_HTML,
34
+ ])
35
+
36
+ export const GLOB_NODE_MODULES = /** @type {const} */ ('**/node_modules/**')
37
+ export const GLOB_DIST = /** @type {const} */ ('**/dist/**')
38
+ export const GLOB_LOCKFILE = /** @type {const} */ ([
39
+ '**/package-lock.json',
40
+ '**/yarn.lock',
41
+ '**/pnpm-lock.yaml',
42
+ ])
43
+ export const GLOB_EXCLUDE = /** @type {const} */ ([
44
+ GLOB_NODE_MODULES,
45
+ GLOB_DIST,
46
+ ...GLOB_LOCKFILE,
47
+ '**/CHANGELOG*.md',
48
+ '**/*.min.*',
49
+ '**/LICENSE*',
50
+ '**/output',
51
+ '**/coverage',
52
+ '**/temp',
53
+ '**/fixtures',
54
+ '**/__snapshots__',
55
+ '**/auto-import.d.ts',
56
+ '**/components.d.ts',
57
+ ])
@@ -0,0 +1,59 @@
1
+ import tsParser from '@typescript-eslint/parser'
2
+ import tsPlugin from '@typescript-eslint/eslint-plugin'
3
+ import { GLOB_EXCLUDE, GLOB_TS, GLOB_TSX } from './shared.js'
4
+
5
+ /** @type {import('eslint-define-config').FlatESLintConfig[]} */
6
+ export const typescript = [
7
+ {
8
+ files: [GLOB_TS, GLOB_TSX],
9
+ ignores: GLOB_EXCLUDE,
10
+ languageOptions: {
11
+ parser: tsParser,
12
+ parserOptions: {
13
+ sourceType: 'module',
14
+ },
15
+ },
16
+ plugins: {
17
+ '@typescript-eslint': tsPlugin,
18
+ },
19
+ rules: {
20
+ ...tsPlugin.configs['eslint-recommended'].overrides[0].rules,
21
+ ...tsPlugin.configs['recommended'].rules,
22
+
23
+ '@typescript-eslint/no-unused-vars': 'error',
24
+ '@typescript-eslint/no-redeclare': 'error',
25
+
26
+ '@typescript-eslint/ban-ts-comment': 'off',
27
+ '@typescript-eslint/ban-types': 'off',
28
+ '@typescript-eslint/consistent-type-imports': [
29
+ 'error',
30
+ { fixStyle: 'separate-type-imports', disallowTypeAnnotations: false },
31
+ ],
32
+ '@typescript-eslint/explicit-module-boundary-types': 'off',
33
+ '@typescript-eslint/no-explicit-any': 'off',
34
+ '@typescript-eslint/no-non-null-assertion': 'off',
35
+ '@typescript-eslint/prefer-as-const': 'warn',
36
+ },
37
+ },
38
+ {
39
+ files: ['**/*.d.ts'],
40
+ ignores: GLOB_EXCLUDE,
41
+ rules: {
42
+ 'import/no-duplicates': 'off',
43
+ },
44
+ },
45
+ {
46
+ files: ['**/*.{test,spec}.ts?(x)'],
47
+ ignores: GLOB_EXCLUDE,
48
+ rules: {
49
+ 'no-unused-expressions': 'off',
50
+ },
51
+ },
52
+ {
53
+ files: ['**/*.js', '**/*.cjs'],
54
+ ignores: GLOB_EXCLUDE,
55
+ rules: {
56
+ '@typescript-eslint/no-var-requires': 'off',
57
+ },
58
+ },
59
+ ]
package/src/vue.js ADDED
@@ -0,0 +1,103 @@
1
+ import { getPackageInfoSync } from 'local-pkg'
2
+ import vueParser from 'vue-eslint-parser'
3
+ import vuePlugin from 'eslint-plugin-vue'
4
+ import { GLOB_EXCLUDE } from './shared.js'
5
+ import { typescript } from './typescript.js'
6
+
7
+ export function getVueVersion() {
8
+ const pkg = getPackageInfoSync('vue', { paths: [process.cwd()] })
9
+ if (
10
+ pkg &&
11
+ typeof pkg.version === 'string' &&
12
+ !Number.isNaN(+pkg.version[0])
13
+ ) {
14
+ return +pkg.version[0]
15
+ }
16
+ return 3
17
+ }
18
+
19
+ /** @type {import('eslint-define-config').FlatESLintConfig[]} */
20
+ export const reactivityTransform = [
21
+ {
22
+ languageOptions: {
23
+ globals: {
24
+ $: 'readonly',
25
+ $$: 'readonly',
26
+ $ref: 'readonly',
27
+ $computed: 'readonly',
28
+ $shallowRef: 'readonly',
29
+ $toRef: 'readonly',
30
+ $customRef: 'readonly',
31
+ },
32
+ },
33
+ rules: {
34
+ 'vue/no-setup-props-destructure': 'off',
35
+ },
36
+ },
37
+ ]
38
+
39
+ /** @type {import('eslint-define-config').Rules} */
40
+ const vueBaseRules = {
41
+ 'vue/max-attributes-per-line': 'off',
42
+ 'vue/no-v-html': 'off',
43
+ 'vue/multi-word-component-names': 'off',
44
+ 'vue/html-self-closing': [
45
+ 'error',
46
+ {
47
+ html: {
48
+ void: 'always',
49
+ normal: 'always',
50
+ component: 'always',
51
+ },
52
+ svg: 'always',
53
+ math: 'always',
54
+ },
55
+ ],
56
+ }
57
+
58
+ /** @type {import('eslint-define-config').Rules} */
59
+ const vue3Rules = {
60
+ ...vuePlugin.configs['base'].rules,
61
+ ...vuePlugin.configs['vue3-essential'].rules,
62
+ ...vuePlugin.configs['vue3-strongly-recommended'].rules,
63
+ ...vuePlugin.configs['vue3-recommended'].rules,
64
+ ...vueBaseRules,
65
+ }
66
+
67
+ /** @type {import('eslint-define-config').Rules} */
68
+ const vue2Rules = {
69
+ ...vuePlugin.configs['base'].rules,
70
+ ...vuePlugin.configs['essential'].rules,
71
+ ...vuePlugin.configs['strongly-recommended'].rules,
72
+ ...vuePlugin.configs['recommended'].rules,
73
+ ...vueBaseRules,
74
+ }
75
+
76
+ /** @type {import('eslint-define-config').FlatESLintConfig[]} */
77
+ export const vue = [
78
+ {
79
+ files: ['**/*.vue'],
80
+ ignores: GLOB_EXCLUDE,
81
+ plugins: {
82
+ vue: vuePlugin,
83
+ ...typescript[0].plugins,
84
+ },
85
+ languageOptions: {
86
+ parser: vueParser,
87
+ parserOptions: {
88
+ parser: '@typescript-eslint/parser',
89
+ sourceType: 'module',
90
+ extraFileExtensions: ['.vue'],
91
+ ecmaFeatures: {
92
+ jsx: true,
93
+ },
94
+ },
95
+ },
96
+ processor: vuePlugin.processors['.vue'],
97
+ rules: {
98
+ ...(getVueVersion() === 3 ? vue3Rules : vue2Rules),
99
+ ...typescript[0].rules,
100
+ },
101
+ },
102
+ ...reactivityTransform,
103
+ ]
package/src/yml.js ADDED
@@ -0,0 +1,22 @@
1
+ import ymlPlugin, { configs } from 'eslint-plugin-yml'
2
+ import ymlParser from 'yaml-eslint-parser'
3
+ import { GLOB_EXCLUDE, GLOB_YAML } from './shared.js'
4
+
5
+ /** @type {import('eslint-define-config').FlatESLintConfig[]} */
6
+ export const yml = [
7
+ {
8
+ files: [GLOB_YAML],
9
+ ignores: GLOB_EXCLUDE,
10
+ plugins: {
11
+ yml: ymlPlugin,
12
+ },
13
+ languageOptions: {
14
+ parser: ymlParser,
15
+ },
16
+ rules: {
17
+ ...configs.standard.rules,
18
+ ...configs.prettier.rules,
19
+ 'yml/no-empty-mapping-value': 'off',
20
+ },
21
+ },
22
+ ]