@kazupon/eslint-config 0.1.0 → 0.2.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/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # @kazupon/eslint-config
2
2
 
3
- [![CI](https://github.com/kazupon/eslint-config/actions/workflows/ci.yml/badge.svg)](https://github.com/kazupon/eslint-config/actions/workflows/ci.yml)
4
- [![CI](https://github.com/kazupon/eslint-config/actions/workflows/ci.yml/badge.svg)](https://github.com/kazupon/eslint-config/actions/workflows/ci.yml)
3
+ [![npm version][npm-version-src]][npm-version-href]
4
+ [![CI][ci-src]][ci-href]
5
5
 
6
6
  ESLint config for @kazupon
7
7
 
@@ -12,6 +12,7 @@ ESLint config for @kazupon
12
12
  - `javascript`
13
13
  - `typescript`
14
14
  - `prettier`
15
+ - `vue`
15
16
  - Support primitive eslint flat configuration
16
17
  - Support overrides for built-in configurations
17
18
  - `rules`
@@ -79,7 +80,7 @@ Add the following settings to your `.vscode/settings.json`:
79
80
  "source.fixAll.eslint": "explicit"
80
81
  },
81
82
  // Enable eslint for supported languages
82
- "eslint.validate": ["javascript", "typescript"],
83
+ "eslint.validate": ["javascript", "typescript", "vue"],
83
84
  // Enable flat configuration
84
85
  "eslint.experimental.useFlatConfig": true
85
86
  }
@@ -94,6 +95,7 @@ The following built-in configurations are supported:
94
95
  | `javascript` | [`@eslint/js`](https://www.npmjs.com/package/@eslint/js) | no (built-in) |
95
96
  | `typescript` | [`typescript-eslint`](https://www.npmjs.com/package/typescript-eslint) | yes |
96
97
  | `prettier` | [`eslint-config-prettier`](https://www.npmjs.com/package/eslint-config-prettier) | yes |
98
+ | `vue` | [`eslint-plugin-vue`](https://www.npmjs.com/package/eslint-plugin-vue) | yes |
97
99
 
98
100
  You can use `import` syntax:
99
101
 
@@ -107,7 +109,7 @@ export default defineConfig(
107
109
  )
108
110
  ```
109
111
 
110
- ## ⚖️ Comparing to [`@antfu/eslint-config`](https://github.com/antfu/eslint-config) an others
112
+ ## ⚖️ Comparing to [`@antfu/eslint-config`](https://github.com/antfu/eslint-config) and others
111
113
 
112
114
  - Respect the recommended config by the eslint plugin in built-in configurations
113
115
  - Customization is overriding it only
@@ -124,3 +126,12 @@ Thank you! ❤️
124
126
  ## ©️ License
125
127
 
126
128
  [MIT](http://opensource.org/licenses/MIT)
129
+
130
+ <!-- Badges -->
131
+
132
+ [npm-version-src]: https://img.shields.io/npm/v/@kazupon/eslint-config?style=flat
133
+ [npm-version-href]: https://npmjs.com/package/@kazupon/eslint-config
134
+ [npm-downloads-src]: https://img.shields.io/npm/dm/@kazupon/eslint-config?style=flat
135
+ [npm-downloads-href]: https://npmjs.com/package/@kazupon/eslint-config
136
+ [ci-src]: https://github.com/kazupon/eslint-config/actions/workflows/ci.yml/badge.svg
137
+ [ci-href]: https://github.com/kazupon/eslint-config/actions/workflows/ci.yml
@@ -1,3 +1,4 @@
1
1
  export * from './javascript';
2
2
  export * from './typescript';
3
3
  export * from './prettier';
4
+ export * from './vue';
@@ -1,3 +1,4 @@
1
1
  export * from './javascript';
2
2
  export * from './typescript';
3
3
  export * from './prettier';
4
+ export * from './vue';
@@ -0,0 +1,7 @@
1
+ import type { Linter } from 'eslint';
2
+ import type { OverridesOptions } from '../types';
3
+ import type { TypeScriptOptions } from './typescript';
4
+ export interface VueScriptOptions {
5
+ typescript?: boolean;
6
+ }
7
+ export declare function vue(options?: ((VueScriptOptions) & (TypeScriptOptions) & (OverridesOptions))): Promise<(Linter.FlatConfig)[]>;
@@ -0,0 +1,7 @@
1
+ import type { Linter } from 'eslint';
2
+ import type { OverridesOptions } from '../types';
3
+ import type { TypeScriptOptions } from './typescript';
4
+ export interface VueScriptOptions {
5
+ typescript?: boolean;
6
+ }
7
+ export declare function vue(options?: ((VueScriptOptions) & (TypeScriptOptions) & (OverridesOptions))): Promise<(Linter.FlatConfig)[]>;
package/dist/globs.d.cts CHANGED
@@ -2,3 +2,4 @@ export declare const GLOB_JS = '**/*.?([cm])js';
2
2
  export declare const GLOB_JSX = '**/*.?([cm])jsx';
3
3
  export declare const GLOB_TS = '**/*.?([cm])ts';
4
4
  export declare const GLOB_TSX = '**/*.?([cm])tsx';
5
+ export declare const GLOB_VUE = '**/*.vue';
package/dist/globs.d.ts CHANGED
@@ -2,3 +2,4 @@ export declare const GLOB_JS = '**/*.?([cm])js';
2
2
  export declare const GLOB_JSX = '**/*.?([cm])jsx';
3
3
  export declare const GLOB_TS = '**/*.?([cm])ts';
4
4
  export declare const GLOB_TSX = '**/*.?([cm])tsx';
5
+ export declare const GLOB_VUE = '**/*.vue';
package/dist/index.cjs CHANGED
@@ -92,13 +92,14 @@ const GLOB_JS = '**/*.?([cm])js';
92
92
  const GLOB_JSX = '**/*.?([cm])jsx';
93
93
  const GLOB_TS = '**/*.?([cm])ts';
94
94
  const GLOB_TSX = '**/*.?([cm])tsx';
95
+ const GLOB_VUE = '**/*.vue';
95
96
 
96
97
  //#endregion
97
98
  //#region src/configs/typescript.ts
98
99
  async function typescript(options = {}) {
99
100
  const { rules: overrideRules = {}, extraFileExtensions = [], parserOptions = {project: true} } = options;
100
101
  const ts = await loadPlugin('typescript-eslint');
101
- const files = options.files ?? [GLOB_TS, GLOB_TSX, ...extraFileExtensions.map((ext) => `**/*.${ext}`)];
102
+ const files = options.files ?? [GLOB_TS, GLOB_TSX, ...extraFileExtensions.map((ext) => `**/*${ext}`)];
102
103
  return [...ts.configs.recommendedTypeChecked, {
103
104
  files: [GLOB_JS, GLOB_JSX],
104
105
  ...ts.configs.disableTypeChecked
@@ -108,7 +109,7 @@ async function typescript(options = {}) {
108
109
  languageOptions: {
109
110
  parser: ts.parser,
110
111
  parserOptions: {
111
- extraFileExtensions: extraFileExtensions.map((ext) => `.${ext}`),
112
+ extraFileExtensions: extraFileExtensions.map((ext) => `${ext}`),
112
113
  sourceType: 'module',
113
114
  ...parserOptions
114
115
  }
@@ -139,6 +140,37 @@ async function prettier(options = {}) {
139
140
  }];
140
141
  }
141
142
 
143
+ //#endregion
144
+ //#region src/configs/vue.ts
145
+ async function vue(options = {}) {
146
+ const { rules: overrideRules = {}, parserOptions = {project: true} } = options;
147
+ const useTypeScript = !!options.typescript;
148
+ const vue$1 = await loadPlugin('eslint-plugin-vue');
149
+ const vueParser = vue$1.configs['flat/base'][1]['languageOptions']['parser'];
150
+ async function getTypeScriptParser() {
151
+ const ts = await loadPlugin('typescript-eslint');
152
+ return ts.parser;
153
+ }
154
+ const customConfig = {
155
+ name: '@kazupon/vue',
156
+ files: [GLOB_VUE],
157
+ rules: {...overrideRules}
158
+ };
159
+ if (useTypeScript) {
160
+ customConfig.languageOptions = {
161
+ parser: vueParser,
162
+ parserOptions: {
163
+ sourceType: 'module',
164
+ parser: await getTypeScriptParser(),
165
+ ecmaFeatures: {jsx: true},
166
+ extraFileExtensions: ['.vue'],
167
+ ...parserOptions
168
+ }
169
+ };
170
+ }
171
+ return [...vue$1.configs['flat/recommended'], customConfig];
172
+ }
173
+
142
174
  //#endregion
143
175
  //#region src/index.ts
144
176
  var src_index_ns = {};
@@ -146,7 +178,8 @@ __export(src_index_ns, {
146
178
  defineConfig: () => defineConfig,
147
179
  javascript: () => javascript,
148
180
  prettier: () => prettier,
149
- typescript: () => typescript
181
+ typescript: () => typescript,
182
+ vue: () => vue
150
183
  });
151
184
 
152
185
  //#endregion
package/dist/index.js CHANGED
@@ -60,13 +60,14 @@ const GLOB_JS = '**/*.?([cm])js';
60
60
  const GLOB_JSX = '**/*.?([cm])jsx';
61
61
  const GLOB_TS = '**/*.?([cm])ts';
62
62
  const GLOB_TSX = '**/*.?([cm])tsx';
63
+ const GLOB_VUE = '**/*.vue';
63
64
 
64
65
  //#endregion
65
66
  //#region src/configs/typescript.ts
66
67
  async function typescript(options = {}) {
67
68
  const { rules: overrideRules = {}, extraFileExtensions = [], parserOptions = {project: true} } = options;
68
69
  const ts = await loadPlugin('typescript-eslint');
69
- const files = options.files ?? [GLOB_TS, GLOB_TSX, ...extraFileExtensions.map((ext) => `**/*.${ext}`)];
70
+ const files = options.files ?? [GLOB_TS, GLOB_TSX, ...extraFileExtensions.map((ext) => `**/*${ext}`)];
70
71
  return [...ts.configs.recommendedTypeChecked, {
71
72
  files: [GLOB_JS, GLOB_JSX],
72
73
  ...ts.configs.disableTypeChecked
@@ -76,7 +77,7 @@ async function typescript(options = {}) {
76
77
  languageOptions: {
77
78
  parser: ts.parser,
78
79
  parserOptions: {
79
- extraFileExtensions: extraFileExtensions.map((ext) => `.${ext}`),
80
+ extraFileExtensions: extraFileExtensions.map((ext) => `${ext}`),
80
81
  sourceType: 'module',
81
82
  ...parserOptions
82
83
  }
@@ -108,4 +109,35 @@ async function prettier(options = {}) {
108
109
  }
109
110
 
110
111
  //#endregion
111
- export { defineConfig, javascript, prettier, typescript };
112
+ //#region src/configs/vue.ts
113
+ async function vue(options = {}) {
114
+ const { rules: overrideRules = {}, parserOptions = {project: true} } = options;
115
+ const useTypeScript = !!options.typescript;
116
+ const vue$1 = await loadPlugin('eslint-plugin-vue');
117
+ const vueParser = vue$1.configs['flat/base'][1]['languageOptions']['parser'];
118
+ async function getTypeScriptParser() {
119
+ const ts = await loadPlugin('typescript-eslint');
120
+ return ts.parser;
121
+ }
122
+ const customConfig = {
123
+ name: '@kazupon/vue',
124
+ files: [GLOB_VUE],
125
+ rules: {...overrideRules}
126
+ };
127
+ if (useTypeScript) {
128
+ customConfig.languageOptions = {
129
+ parser: vueParser,
130
+ parserOptions: {
131
+ sourceType: 'module',
132
+ parser: await getTypeScriptParser(),
133
+ ecmaFeatures: {jsx: true},
134
+ extraFileExtensions: ['.vue'],
135
+ ...parserOptions
136
+ }
137
+ };
138
+ }
139
+ return [...vue$1.configs['flat/recommended'], customConfig];
140
+ }
141
+
142
+ //#endregion
143
+ export { defineConfig, javascript, prettier, typescript, vue };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kazupon/eslint-config",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "ESLint config for @kazupon",
5
5
  "keywords": [
6
6
  "config",
@@ -43,7 +43,8 @@
43
43
  "peerDependencies": {
44
44
  "eslint": ">=8.56.0 || >=9.0.0",
45
45
  "typescript-eslint": ">=7.0.0",
46
- "eslint-config-prettier": ">=9.1.0"
46
+ "eslint-config-prettier": ">=9.1.0",
47
+ "eslint-plugin-vue": ">=9.24.0"
47
48
  },
48
49
  "peerDependenciesMeta": {
49
50
  "typescript-eslint": {
@@ -51,6 +52,9 @@
51
52
  },
52
53
  "eslint-config-prettier": {
53
54
  "optional": true
55
+ },
56
+ "eslint-plugin-vue": {
57
+ "optional": true
54
58
  }
55
59
  },
56
60
  "devDependencies": {
@@ -60,6 +64,7 @@
60
64
  "bumpp": "^9.4.1",
61
65
  "eslint": "^9.6.0",
62
66
  "eslint-config-prettier": "^9.1.0",
67
+ "eslint-plugin-vue": "^9.27.0",
63
68
  "gh-changelogen": "^0.2.8",
64
69
  "lint-staged": "^15.2.7",
65
70
  "npm-run-all2": "^6.2.2",