@kazupon/eslint-config 0.5.0 → 0.6.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,7 +14,9 @@ ESLint config for @kazupon
14
14
  - `typescript`
15
15
  - `jsdoc`
16
16
  - `regexp`
17
+ - `unicorn`
17
18
  - `prettier`
19
+ - `jsonc`
18
20
  - `vue`
19
21
  - Support primitive eslint flat configuration
20
22
  - Support overrides for built-in configurations
@@ -83,7 +85,7 @@ Add the following settings to your `.vscode/settings.json`:
83
85
  "source.fixAll.eslint": "explicit"
84
86
  },
85
87
  // Enable eslint for supported languages
86
- "eslint.validate": ["javascript", "typescript", "vue"],
88
+ "eslint.validate": ["javascript", "typescript", "json", "jsonc", "json5", "vue"],
87
89
  // Enable flat configuration
88
90
  "eslint.useFlatConfig": true
89
91
  }
@@ -100,7 +102,9 @@ The following built-in configurations are supported:
100
102
  | `typescript` | [`typescript-eslint`](https://www.npmjs.com/package/typescript-eslint) | yes |
101
103
  | `jsdoc` | [`eslint-plugin-jsdoc`](https://www.npmjs.com/package/eslint-plugin-jsdoc) | yes |
102
104
  | `regexp` | [`eslint-plugin-regexp`](https://www.npmjs.com/package/eslint-plugin-regexp) | yes |
105
+ | `unicorn` | [`eslint-plugin-unicorn`](https://www.npmjs.com/package/eslint-plugin-unicorn) | yes |
103
106
  | `prettier` | [`eslint-config-prettier`](https://www.npmjs.com/package/eslint-config-prettier) | yes |
107
+ | `jsonc` | [`eslint-plugin-jsonc`](https://www.npmjs.com/package/eslint-plugin-jsonc) | yes |
104
108
  | `vue` | [`eslint-plugin-vue`](https://www.npmjs.com/package/eslint-plugin-vue) | yes |
105
109
 
106
110
  You can use `import` syntax:
@@ -3,5 +3,7 @@ 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';
7
9
  export * from './vue';
@@ -3,5 +3,7 @@ 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';
7
9
  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)[]>;
package/dist/globs.d.cts CHANGED
@@ -3,3 +3,6 @@ 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
5
  export declare const GLOB_VUE = '**/*.vue';
6
+ export declare const GLOB_JSON = '**/*.json';
7
+ export declare const GLOB_JSON5 = '**/*.json5';
8
+ export declare const GLOB_JSONC = '**/*.jsonc';
package/dist/globs.d.ts CHANGED
@@ -3,3 +3,6 @@ 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
5
  export declare const GLOB_VUE = '**/*.vue';
6
+ export declare const GLOB_JSON = '**/*.json';
7
+ export declare const GLOB_JSON5 = '**/*.json5';
8
+ export declare const GLOB_JSONC = '**/*.jsonc';
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);
@@ -100,6 +100,9 @@ const GLOB_JSX = '**/*.?([cm])jsx';
100
100
  const GLOB_TS = '**/*.?([cm])ts';
101
101
  const GLOB_TSX = '**/*.?([cm])tsx';
102
102
  const GLOB_VUE = '**/*.vue';
103
+ const GLOB_JSON = '**/*.json';
104
+ const GLOB_JSON5 = '**/*.json5';
105
+ const GLOB_JSONC = '**/*.jsonc';
103
106
 
104
107
  //#endregion
105
108
  //#region src/configs/typescript.ts
@@ -108,7 +111,7 @@ async function typescript(options = {}) {
108
111
  const ts = await loadPlugin('typescript-eslint');
109
112
  const files = options.files ?? [GLOB_TS, GLOB_TSX, ...extraFileExtensions.map((ext) => `**/*${ext}`)];
110
113
  return [...(ts.configs.recommendedTypeChecked), {
111
- files: [GLOB_JS, GLOB_JSX],
114
+ files: [GLOB_JS, GLOB_JSX, GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
112
115
  ...(ts.configs.disableTypeChecked)
113
116
  }, {
114
117
  name: '@kazupon/typescipt/typescript-eslint',
@@ -173,6 +176,17 @@ async function regexp(options = {}) {
173
176
  }];
174
177
  }
175
178
 
179
+ //#endregion
180
+ //#region src/configs/unicorn.ts
181
+ async function unicorn(options = {}) {
182
+ const { rules: overrideRules = {} } = options;
183
+ const unicorn$1 = await loadPlugin('eslint-plugin-unicorn');
184
+ return [unicorn$1.configs['flat/recommended'], {
185
+ name: '@kazupon/unicorn',
186
+ rules: {...overrideRules}
187
+ }];
188
+ }
189
+
176
190
  //#endregion
177
191
  //#region src/configs/prettier.ts
178
192
  async function prettier(options = {}) {
@@ -184,6 +198,50 @@ async function prettier(options = {}) {
184
198
  }];
185
199
  }
186
200
 
201
+ //#endregion
202
+ //#region src/configs/jsonc.ts
203
+ async function jsonc(options = {}) {
204
+ const { rules: overrideRules = {} } = options;
205
+ const kinds = [options.json ? 'json' : '', options.jsonc ? 'jsonc' : '', options.json5 ? 'json5' : ''];
206
+ const usePrettier = !!options.prettier;
207
+ const jsonc$1 = await loadPlugin('eslint-plugin-jsonc');
208
+ const configs = [];
209
+ const defaultRules = {'jsonc/sort-keys': ['warn', 'asc', {
210
+ caseSensitive: true,
211
+ natural: false,
212
+ minKeys: 2,
213
+ allowLineSeparatedGroups: false
214
+ }]};
215
+ for (const kind of kinds) {
216
+ if (kind) {
217
+ configs.push(...jsonc$1.configs[`flat/recommended-with-${kind}`].map((config, index) => {
218
+ return config.name ? config : {
219
+ name: `jsonc/flat/recommended-with-${kind}/${index}`,
220
+ ...config
221
+ };
222
+ }));
223
+ }
224
+ }
225
+ if (usePrettier) {
226
+ configs.push(...jsonc$1.configs['flat/prettier'].map((config, index) => {
227
+ return config.name ? config : {
228
+ name: `jsonc/flat/prettier/${index}`,
229
+ ...config
230
+ };
231
+ }));
232
+ }
233
+ const overriddenConfig = {
234
+ name: '@kazupon/jsonc',
235
+ files: [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
236
+ rules: {
237
+ ...defaultRules,
238
+ ...overrideRules
239
+ }
240
+ };
241
+ configs.push(overriddenConfig);
242
+ return configs;
243
+ }
244
+
187
245
  //#endregion
188
246
  //#region src/configs/vue.ts
189
247
  async function vue(options = {}) {
@@ -221,7 +279,9 @@ exports.comments = comments;
221
279
  exports.defineConfig = defineConfig;
222
280
  exports.javascript = javascript;
223
281
  exports.jsdoc = jsdoc;
282
+ exports.jsonc = jsonc;
224
283
  exports.prettier = prettier;
225
284
  exports.regexp = regexp;
226
285
  exports.typescript = typescript;
286
+ exports.unicorn = unicorn;
227
287
  exports.vue = vue;
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);
@@ -75,6 +75,9 @@ const GLOB_JSX = '**/*.?([cm])jsx';
75
75
  const GLOB_TS = '**/*.?([cm])ts';
76
76
  const GLOB_TSX = '**/*.?([cm])tsx';
77
77
  const GLOB_VUE = '**/*.vue';
78
+ const GLOB_JSON = '**/*.json';
79
+ const GLOB_JSON5 = '**/*.json5';
80
+ const GLOB_JSONC = '**/*.jsonc';
78
81
 
79
82
  //#endregion
80
83
  //#region src/configs/typescript.ts
@@ -83,7 +86,7 @@ async function typescript(options = {}) {
83
86
  const ts = await loadPlugin('typescript-eslint');
84
87
  const files = options.files ?? [GLOB_TS, GLOB_TSX, ...extraFileExtensions.map((ext) => `**/*${ext}`)];
85
88
  return [...(ts.configs.recommendedTypeChecked), {
86
- files: [GLOB_JS, GLOB_JSX],
89
+ files: [GLOB_JS, GLOB_JSX, GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
87
90
  ...(ts.configs.disableTypeChecked)
88
91
  }, {
89
92
  name: '@kazupon/typescipt/typescript-eslint',
@@ -148,6 +151,17 @@ async function regexp(options = {}) {
148
151
  }];
149
152
  }
150
153
 
154
+ //#endregion
155
+ //#region src/configs/unicorn.ts
156
+ async function unicorn(options = {}) {
157
+ const { rules: overrideRules = {} } = options;
158
+ const unicorn$1 = await loadPlugin('eslint-plugin-unicorn');
159
+ return [unicorn$1.configs['flat/recommended'], {
160
+ name: '@kazupon/unicorn',
161
+ rules: {...overrideRules}
162
+ }];
163
+ }
164
+
151
165
  //#endregion
152
166
  //#region src/configs/prettier.ts
153
167
  async function prettier(options = {}) {
@@ -159,6 +173,50 @@ async function prettier(options = {}) {
159
173
  }];
160
174
  }
161
175
 
176
+ //#endregion
177
+ //#region src/configs/jsonc.ts
178
+ async function jsonc(options = {}) {
179
+ const { rules: overrideRules = {} } = options;
180
+ const kinds = [options.json ? 'json' : '', options.jsonc ? 'jsonc' : '', options.json5 ? 'json5' : ''];
181
+ const usePrettier = !!options.prettier;
182
+ const jsonc$1 = await loadPlugin('eslint-plugin-jsonc');
183
+ const configs = [];
184
+ const defaultRules = {'jsonc/sort-keys': ['warn', 'asc', {
185
+ caseSensitive: true,
186
+ natural: false,
187
+ minKeys: 2,
188
+ allowLineSeparatedGroups: false
189
+ }]};
190
+ for (const kind of kinds) {
191
+ if (kind) {
192
+ configs.push(...jsonc$1.configs[`flat/recommended-with-${kind}`].map((config, index) => {
193
+ return config.name ? config : {
194
+ name: `jsonc/flat/recommended-with-${kind}/${index}`,
195
+ ...config
196
+ };
197
+ }));
198
+ }
199
+ }
200
+ if (usePrettier) {
201
+ configs.push(...jsonc$1.configs['flat/prettier'].map((config, index) => {
202
+ return config.name ? config : {
203
+ name: `jsonc/flat/prettier/${index}`,
204
+ ...config
205
+ };
206
+ }));
207
+ }
208
+ const overriddenConfig = {
209
+ name: '@kazupon/jsonc',
210
+ files: [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
211
+ rules: {
212
+ ...defaultRules,
213
+ ...overrideRules
214
+ }
215
+ };
216
+ configs.push(overriddenConfig);
217
+ return configs;
218
+ }
219
+
162
220
  //#endregion
163
221
  //#region src/configs/vue.ts
164
222
  async function vue(options = {}) {
@@ -191,4 +249,4 @@ async function vue(options = {}) {
191
249
  }
192
250
 
193
251
  //#endregion
194
- export { comments, defineConfig, javascript, jsdoc, prettier, regexp, typescript, vue };
252
+ export { comments, defineConfig, javascript, jsdoc, jsonc, prettier, regexp, typescript, unicorn, vue };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kazupon/eslint-config",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "ESLint config for @kazupon",
5
5
  "keywords": [
6
6
  "config",
@@ -45,7 +45,9 @@
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",
50
52
  "typescript-eslint": ">=7.0.0"
51
53
  },
@@ -59,9 +61,15 @@
59
61
  "eslint-plugin-jsdoc": {
60
62
  "optional": true
61
63
  },
64
+ "eslint-plugin-jsonc": {
65
+ "optional": true
66
+ },
62
67
  "eslint-plugin-regexp": {
63
68
  "optional": true
64
69
  },
70
+ "eslint-plugin-unicorn": {
71
+ "optional": true
72
+ },
65
73
  "eslint-plugin-vue": {
66
74
  "optional": true
67
75
  }
@@ -74,7 +82,9 @@
74
82
  "eslint": "^9.6.0",
75
83
  "eslint-config-prettier": "^9.1.0",
76
84
  "eslint-plugin-jsdoc": "^48.5.2",
85
+ "eslint-plugin-jsonc": "^2.16.0",
77
86
  "eslint-plugin-regexp": "^2.6.0",
87
+ "eslint-plugin-unicorn": "^54.0.0",
78
88
  "eslint-plugin-vue": "^9.27.0",
79
89
  "gh-changelogen": "^0.2.8",
80
90
  "lint-staged": "^15.2.7",