@kazupon/eslint-config 0.5.0 → 0.7.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
@@ -14,8 +14,11 @@ ESLint config for @kazupon
14
14
  - `typescript`
15
15
  - `jsdoc`
16
16
  - `regexp`
17
+ - `unicorn`
17
18
  - `prettier`
18
- - `vue`
19
+ - `jsonc`
20
+ - `vue`,
21
+ - `yml`
19
22
  - Support primitive eslint flat configuration
20
23
  - Support overrides for built-in configurations
21
24
  - `rules`
@@ -83,7 +86,7 @@ Add the following settings to your `.vscode/settings.json`:
83
86
  "source.fixAll.eslint": "explicit"
84
87
  },
85
88
  // Enable eslint for supported languages
86
- "eslint.validate": ["javascript", "typescript", "vue"],
89
+ "eslint.validate": ["javascript", "typescript", "json", "jsonc", "json5", "vue", "yaml"],
87
90
  // Enable flat configuration
88
91
  "eslint.useFlatConfig": true
89
92
  }
@@ -100,8 +103,11 @@ The following built-in configurations are supported:
100
103
  | `typescript` | [`typescript-eslint`](https://www.npmjs.com/package/typescript-eslint) | yes |
101
104
  | `jsdoc` | [`eslint-plugin-jsdoc`](https://www.npmjs.com/package/eslint-plugin-jsdoc) | yes |
102
105
  | `regexp` | [`eslint-plugin-regexp`](https://www.npmjs.com/package/eslint-plugin-regexp) | yes |
106
+ | `unicorn` | [`eslint-plugin-unicorn`](https://www.npmjs.com/package/eslint-plugin-unicorn) | yes |
103
107
  | `prettier` | [`eslint-config-prettier`](https://www.npmjs.com/package/eslint-config-prettier) | yes |
108
+ | `jsonc` | [`eslint-plugin-jsonc`](https://www.npmjs.com/package/eslint-plugin-jsonc) | yes |
104
109
  | `vue` | [`eslint-plugin-vue`](https://www.npmjs.com/package/eslint-plugin-vue) | yes |
110
+ | `yml` | [`eslint-plugin-yml`](https://www.npmjs.com/package/eslint-plugin-yml) | yes |
105
111
 
106
112
  You can use `import` syntax:
107
113
 
@@ -3,5 +3,8 @@ export * from './comments';
3
3
  export * from './typescript';
4
4
  export * from './jsdoc';
5
5
  export * from './regexp';
6
+ export * from './unicorn';
6
7
  export * from './prettier';
8
+ export * from './jsonc';
9
+ export * from './yml';
7
10
  export * from './vue';
@@ -3,5 +3,8 @@ export * from './comments';
3
3
  export * from './typescript';
4
4
  export * from './jsdoc';
5
5
  export * from './regexp';
6
+ export * from './unicorn';
6
7
  export * from './prettier';
8
+ export * from './jsonc';
9
+ export * from './yml';
7
10
  export * from './vue';
@@ -1,7 +1,7 @@
1
1
  import type { Linter } from 'eslint';
2
2
  import type { OverridesOptions } from '../types';
3
- export interface JsDocOptions {
3
+ export interface JsDocumentOptions {
4
4
  typescript?: (('syntax') | ('flavor'));
5
5
  error?: boolean;
6
6
  }
7
- export declare function jsdoc(options?: ((JsDocOptions) & (OverridesOptions))): Promise<(Linter.FlatConfig)[]>;
7
+ export declare function jsdoc(options?: ((JsDocumentOptions) & (OverridesOptions))): Promise<(Linter.FlatConfig)[]>;
@@ -1,7 +1,7 @@
1
1
  import type { Linter } from 'eslint';
2
2
  import type { OverridesOptions } from '../types';
3
- export interface JsDocOptions {
3
+ export interface JsDocumentOptions {
4
4
  typescript?: (('syntax') | ('flavor'));
5
5
  error?: boolean;
6
6
  }
7
- export declare function jsdoc(options?: ((JsDocOptions) & (OverridesOptions))): Promise<(Linter.FlatConfig)[]>;
7
+ export declare function jsdoc(options?: ((JsDocumentOptions) & (OverridesOptions))): Promise<(Linter.FlatConfig)[]>;
@@ -0,0 +1,9 @@
1
+ import type { Linter } from 'eslint';
2
+ import type { OverridesOptions } from '../types';
3
+ export interface JsoncOptions {
4
+ json?: boolean;
5
+ jsonc?: boolean;
6
+ json5?: boolean;
7
+ prettier?: boolean;
8
+ }
9
+ export declare function jsonc(options?: ((JsoncOptions) & (OverridesOptions))): Promise<(Linter.FlatConfig)[]>;
@@ -0,0 +1,9 @@
1
+ import type { Linter } from 'eslint';
2
+ import type { OverridesOptions } from '../types';
3
+ export interface JsoncOptions {
4
+ json?: boolean;
5
+ jsonc?: boolean;
6
+ json5?: boolean;
7
+ prettier?: boolean;
8
+ }
9
+ export declare function jsonc(options?: ((JsoncOptions) & (OverridesOptions))): Promise<(Linter.FlatConfig)[]>;
@@ -0,0 +1,4 @@
1
+ import type { Linter } from 'eslint';
2
+ import type { OverridesOptions } from '../types';
3
+ export interface UnicornOptions {}
4
+ export declare function unicorn(options?: ((UnicornOptions) & (OverridesOptions))): Promise<(Linter.FlatConfig)[]>;
@@ -0,0 +1,4 @@
1
+ import type { Linter } from 'eslint';
2
+ import type { OverridesOptions } from '../types';
3
+ export interface UnicornOptions {}
4
+ export declare function unicorn(options?: ((UnicornOptions) & (OverridesOptions))): Promise<(Linter.FlatConfig)[]>;
@@ -0,0 +1,7 @@
1
+ import type { Linter } from 'eslint';
2
+ import type { OverridesOptions } from '../types';
3
+ export interface YmlOptions {
4
+ prettier?: boolean;
5
+ }
6
+ export declare function yml(options?: ((YmlOptions) & (OverridesOptions))): Promise<(Linter.FlatConfig)[]>;
7
+ export declare const yaml: typeof yml;
@@ -0,0 +1,7 @@
1
+ import type { Linter } from 'eslint';
2
+ import type { OverridesOptions } from '../types';
3
+ export interface YmlOptions {
4
+ prettier?: boolean;
5
+ }
6
+ export declare function yml(options?: ((YmlOptions) & (OverridesOptions))): Promise<(Linter.FlatConfig)[]>;
7
+ export declare const yaml: typeof yml;
package/dist/globs.d.cts CHANGED
@@ -2,4 +2,8 @@ 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_JSON = '**/*.json';
6
+ export declare const GLOB_JSON5 = '**/*.json5';
7
+ export declare const GLOB_JSONC = '**/*.jsonc';
8
+ export declare const GLOB_YAML = '**/*.y?(a)ml';
5
9
  export declare const GLOB_VUE = '**/*.vue';
package/dist/globs.d.ts CHANGED
@@ -2,4 +2,8 @@ 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_JSON = '**/*.json';
6
+ export declare const GLOB_JSON5 = '**/*.json5';
7
+ export declare const GLOB_JSONC = '**/*.jsonc';
8
+ export declare const GLOB_YAML = '**/*.y?(a)ml';
5
9
  export declare const GLOB_VUE = '**/*.vue';
package/dist/index.cjs CHANGED
@@ -39,8 +39,8 @@ async function interopDefault(mod) {
39
39
  return (resolved).default || resolved;
40
40
  }
41
41
  async function loadPlugin(name) {
42
- const mod = await import(name).catch((err) => {
43
- console.error(err);
42
+ const mod = await import(name).catch((error) => {
43
+ console.error(error);
44
44
  throw new Error(`Failed to load eslint plugin '${name}'. Please install it!`);
45
45
  });
46
46
  return interopDefault(mod);
@@ -99,6 +99,10 @@ const GLOB_JS = '**/*.?([cm])js';
99
99
  const GLOB_JSX = '**/*.?([cm])jsx';
100
100
  const GLOB_TS = '**/*.?([cm])ts';
101
101
  const GLOB_TSX = '**/*.?([cm])tsx';
102
+ const GLOB_JSON = '**/*.json';
103
+ const GLOB_JSON5 = '**/*.json5';
104
+ const GLOB_JSONC = '**/*.jsonc';
105
+ const GLOB_YAML = '**/*.y?(a)ml';
102
106
  const GLOB_VUE = '**/*.vue';
103
107
 
104
108
  //#endregion
@@ -108,7 +112,7 @@ async function typescript(options = {}) {
108
112
  const ts = await loadPlugin('typescript-eslint');
109
113
  const files = options.files ?? [GLOB_TS, GLOB_TSX, ...extraFileExtensions.map((ext) => `**/*${ext}`)];
110
114
  return [...(ts.configs.recommendedTypeChecked), {
111
- files: [GLOB_JS, GLOB_JSX],
115
+ files: [GLOB_JS, GLOB_JSX, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_YAML],
112
116
  ...(ts.configs.disableTypeChecked)
113
117
  }, {
114
118
  name: '@kazupon/typescipt/typescript-eslint',
@@ -173,6 +177,17 @@ async function regexp(options = {}) {
173
177
  }];
174
178
  }
175
179
 
180
+ //#endregion
181
+ //#region src/configs/unicorn.ts
182
+ async function unicorn(options = {}) {
183
+ const { rules: overrideRules = {} } = options;
184
+ const unicorn$1 = await loadPlugin('eslint-plugin-unicorn');
185
+ return [unicorn$1.configs['flat/recommended'], {
186
+ name: '@kazupon/unicorn',
187
+ rules: {...overrideRules}
188
+ }];
189
+ }
190
+
176
191
  //#endregion
177
192
  //#region src/configs/prettier.ts
178
193
  async function prettier(options = {}) {
@@ -184,6 +199,81 @@ async function prettier(options = {}) {
184
199
  }];
185
200
  }
186
201
 
202
+ //#endregion
203
+ //#region src/configs/jsonc.ts
204
+ async function jsonc(options = {}) {
205
+ const { rules: overrideRules = {} } = options;
206
+ const kinds = [options.json ? 'json' : '', options.jsonc ? 'jsonc' : '', options.json5 ? 'json5' : ''];
207
+ const usePrettier = !!options.prettier;
208
+ const jsonc$1 = await loadPlugin('eslint-plugin-jsonc');
209
+ const configs = [];
210
+ const defaultRules = {'jsonc/sort-keys': ['warn', 'asc', {
211
+ caseSensitive: true,
212
+ natural: false,
213
+ minKeys: 2,
214
+ allowLineSeparatedGroups: false
215
+ }]};
216
+ for (const kind of kinds) {
217
+ if (kind) {
218
+ configs.push(...jsonc$1.configs[`flat/recommended-with-${kind}`].map((config, index) => {
219
+ return config.name ? config : {
220
+ name: `jsonc/flat/recommended-with-${kind}/${index}`,
221
+ ...config
222
+ };
223
+ }));
224
+ }
225
+ }
226
+ if (usePrettier) {
227
+ configs.push(...jsonc$1.configs['flat/prettier'].map((config, index) => {
228
+ return config.name ? config : {
229
+ name: `jsonc/flat/prettier/${index}`,
230
+ ...config
231
+ };
232
+ }));
233
+ }
234
+ const overriddenConfig = {
235
+ name: '@kazupon/jsonc',
236
+ files: [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
237
+ rules: {
238
+ ...defaultRules,
239
+ ...overrideRules
240
+ }
241
+ };
242
+ configs.push(overriddenConfig);
243
+ return configs;
244
+ }
245
+
246
+ //#endregion
247
+ //#region src/configs/yml.ts
248
+ async function yml(options = {}) {
249
+ const { rules: overrideRules = {} } = options;
250
+ const usePrettier = !!options.prettier;
251
+ const yml$1 = await loadPlugin('eslint-plugin-yml');
252
+ const configs = [];
253
+ configs.push(...yml$1.configs['flat/standard'].map((config, index) => {
254
+ return config.name ? config : {
255
+ name: `yml/flat/standard/${index}`,
256
+ ...config
257
+ };
258
+ }));
259
+ if (usePrettier) {
260
+ configs.push(...yml$1.configs['flat/prettier'].map((config, index) => {
261
+ return config.name ? config : {
262
+ name: `yml/flat/prettier/${index}`,
263
+ ...config
264
+ };
265
+ }));
266
+ }
267
+ const overriddenConfig = {
268
+ name: '@kazupon/yml',
269
+ files: [GLOB_YAML],
270
+ rules: {...overrideRules}
271
+ };
272
+ configs.push(overriddenConfig);
273
+ return configs;
274
+ }
275
+ const yaml = yml;
276
+
187
277
  //#endregion
188
278
  //#region src/configs/vue.ts
189
279
  async function vue(options = {}) {
@@ -221,7 +311,11 @@ exports.comments = comments;
221
311
  exports.defineConfig = defineConfig;
222
312
  exports.javascript = javascript;
223
313
  exports.jsdoc = jsdoc;
314
+ exports.jsonc = jsonc;
224
315
  exports.prettier = prettier;
225
316
  exports.regexp = regexp;
226
317
  exports.typescript = typescript;
227
- exports.vue = vue;
318
+ exports.unicorn = unicorn;
319
+ exports.vue = vue;
320
+ exports.yaml = yaml;
321
+ exports.yml = yml;
package/dist/index.js CHANGED
@@ -14,8 +14,8 @@ async function interopDefault(mod) {
14
14
  return (resolved).default || resolved;
15
15
  }
16
16
  async function loadPlugin(name) {
17
- const mod = await import(name).catch((err) => {
18
- console.error(err);
17
+ const mod = await import(name).catch((error) => {
18
+ console.error(error);
19
19
  throw new Error(`Failed to load eslint plugin '${name}'. Please install it!`);
20
20
  });
21
21
  return interopDefault(mod);
@@ -74,6 +74,10 @@ const GLOB_JS = '**/*.?([cm])js';
74
74
  const GLOB_JSX = '**/*.?([cm])jsx';
75
75
  const GLOB_TS = '**/*.?([cm])ts';
76
76
  const GLOB_TSX = '**/*.?([cm])tsx';
77
+ const GLOB_JSON = '**/*.json';
78
+ const GLOB_JSON5 = '**/*.json5';
79
+ const GLOB_JSONC = '**/*.jsonc';
80
+ const GLOB_YAML = '**/*.y?(a)ml';
77
81
  const GLOB_VUE = '**/*.vue';
78
82
 
79
83
  //#endregion
@@ -83,7 +87,7 @@ async function typescript(options = {}) {
83
87
  const ts = await loadPlugin('typescript-eslint');
84
88
  const files = options.files ?? [GLOB_TS, GLOB_TSX, ...extraFileExtensions.map((ext) => `**/*${ext}`)];
85
89
  return [...(ts.configs.recommendedTypeChecked), {
86
- files: [GLOB_JS, GLOB_JSX],
90
+ files: [GLOB_JS, GLOB_JSX, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_YAML],
87
91
  ...(ts.configs.disableTypeChecked)
88
92
  }, {
89
93
  name: '@kazupon/typescipt/typescript-eslint',
@@ -148,6 +152,17 @@ async function regexp(options = {}) {
148
152
  }];
149
153
  }
150
154
 
155
+ //#endregion
156
+ //#region src/configs/unicorn.ts
157
+ async function unicorn(options = {}) {
158
+ const { rules: overrideRules = {} } = options;
159
+ const unicorn$1 = await loadPlugin('eslint-plugin-unicorn');
160
+ return [unicorn$1.configs['flat/recommended'], {
161
+ name: '@kazupon/unicorn',
162
+ rules: {...overrideRules}
163
+ }];
164
+ }
165
+
151
166
  //#endregion
152
167
  //#region src/configs/prettier.ts
153
168
  async function prettier(options = {}) {
@@ -159,6 +174,81 @@ async function prettier(options = {}) {
159
174
  }];
160
175
  }
161
176
 
177
+ //#endregion
178
+ //#region src/configs/jsonc.ts
179
+ async function jsonc(options = {}) {
180
+ const { rules: overrideRules = {} } = options;
181
+ const kinds = [options.json ? 'json' : '', options.jsonc ? 'jsonc' : '', options.json5 ? 'json5' : ''];
182
+ const usePrettier = !!options.prettier;
183
+ const jsonc$1 = await loadPlugin('eslint-plugin-jsonc');
184
+ const configs = [];
185
+ const defaultRules = {'jsonc/sort-keys': ['warn', 'asc', {
186
+ caseSensitive: true,
187
+ natural: false,
188
+ minKeys: 2,
189
+ allowLineSeparatedGroups: false
190
+ }]};
191
+ for (const kind of kinds) {
192
+ if (kind) {
193
+ configs.push(...jsonc$1.configs[`flat/recommended-with-${kind}`].map((config, index) => {
194
+ return config.name ? config : {
195
+ name: `jsonc/flat/recommended-with-${kind}/${index}`,
196
+ ...config
197
+ };
198
+ }));
199
+ }
200
+ }
201
+ if (usePrettier) {
202
+ configs.push(...jsonc$1.configs['flat/prettier'].map((config, index) => {
203
+ return config.name ? config : {
204
+ name: `jsonc/flat/prettier/${index}`,
205
+ ...config
206
+ };
207
+ }));
208
+ }
209
+ const overriddenConfig = {
210
+ name: '@kazupon/jsonc',
211
+ files: [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
212
+ rules: {
213
+ ...defaultRules,
214
+ ...overrideRules
215
+ }
216
+ };
217
+ configs.push(overriddenConfig);
218
+ return configs;
219
+ }
220
+
221
+ //#endregion
222
+ //#region src/configs/yml.ts
223
+ async function yml(options = {}) {
224
+ const { rules: overrideRules = {} } = options;
225
+ const usePrettier = !!options.prettier;
226
+ const yml$1 = await loadPlugin('eslint-plugin-yml');
227
+ const configs = [];
228
+ configs.push(...yml$1.configs['flat/standard'].map((config, index) => {
229
+ return config.name ? config : {
230
+ name: `yml/flat/standard/${index}`,
231
+ ...config
232
+ };
233
+ }));
234
+ if (usePrettier) {
235
+ configs.push(...yml$1.configs['flat/prettier'].map((config, index) => {
236
+ return config.name ? config : {
237
+ name: `yml/flat/prettier/${index}`,
238
+ ...config
239
+ };
240
+ }));
241
+ }
242
+ const overriddenConfig = {
243
+ name: '@kazupon/yml',
244
+ files: [GLOB_YAML],
245
+ rules: {...overrideRules}
246
+ };
247
+ configs.push(overriddenConfig);
248
+ return configs;
249
+ }
250
+ const yaml = yml;
251
+
162
252
  //#endregion
163
253
  //#region src/configs/vue.ts
164
254
  async function vue(options = {}) {
@@ -191,4 +281,4 @@ async function vue(options = {}) {
191
281
  }
192
282
 
193
283
  //#endregion
194
- export { comments, defineConfig, javascript, jsdoc, prettier, regexp, typescript, vue };
284
+ export { comments, defineConfig, javascript, jsdoc, jsonc, prettier, regexp, typescript, unicorn, vue, yaml, yml };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kazupon/eslint-config",
3
- "version": "0.5.0",
3
+ "version": "0.7.0",
4
4
  "description": "ESLint config for @kazupon",
5
5
  "keywords": [
6
6
  "config",
@@ -45,25 +45,37 @@
45
45
  "eslint": ">=8.56.0 || >=9.0.0",
46
46
  "eslint-config-prettier": ">=9.1.0",
47
47
  "eslint-plugin-jsdoc": ">=48.5.0",
48
+ "eslint-plugin-jsonc": ">=2.16.0",
48
49
  "eslint-plugin-regexp": ">=2.6.0",
50
+ "eslint-plugin-unicorn": ">=54.0.0",
49
51
  "eslint-plugin-vue": ">=9.24.0",
52
+ "eslint-plugin-yml": ">=1.14.0",
50
53
  "typescript-eslint": ">=7.0.0"
51
54
  },
52
55
  "peerDependenciesMeta": {
53
- "typescript-eslint": {
54
- "optional": true
55
- },
56
56
  "eslint-config-prettier": {
57
57
  "optional": true
58
58
  },
59
59
  "eslint-plugin-jsdoc": {
60
60
  "optional": true
61
61
  },
62
+ "eslint-plugin-jsonc": {
63
+ "optional": true
64
+ },
62
65
  "eslint-plugin-regexp": {
63
66
  "optional": true
64
67
  },
68
+ "eslint-plugin-unicorn": {
69
+ "optional": true
70
+ },
65
71
  "eslint-plugin-vue": {
66
72
  "optional": true
73
+ },
74
+ "eslint-plugin-yml": {
75
+ "optional": true
76
+ },
77
+ "typescript-eslint": {
78
+ "optional": true
67
79
  }
68
80
  },
69
81
  "devDependencies": {
@@ -74,8 +86,11 @@
74
86
  "eslint": "^9.6.0",
75
87
  "eslint-config-prettier": "^9.1.0",
76
88
  "eslint-plugin-jsdoc": "^48.5.2",
89
+ "eslint-plugin-jsonc": "^2.16.0",
77
90
  "eslint-plugin-regexp": "^2.6.0",
91
+ "eslint-plugin-unicorn": "^54.0.0",
78
92
  "eslint-plugin-vue": "^9.27.0",
93
+ "eslint-plugin-yml": "^1.14.0",
79
94
  "gh-changelogen": "^0.2.8",
80
95
  "lint-staged": "^15.2.7",
81
96
  "npm-run-all2": "^6.2.2",
@@ -87,7 +102,7 @@
87
102
  "vitest": "^2.0.0"
88
103
  },
89
104
  "lint-staged": {
90
- "*.{json,md,yml}": [
105
+ "*.{json,jsonc,json5,md,yml,yaml}": [
91
106
  "prettier --write"
92
107
  ],
93
108
  "*.{js,mjs,cjs}": [