@kazupon/eslint-config 0.2.0 → 0.4.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
@@ -7,10 +7,12 @@ ESLint config for @kazupon
7
7
 
8
8
  ## 🌟 Features
9
9
 
10
- - Flat configuration via `defineConfig` like [vite](https://vitejs.dev/config/)
11
- - Support built-in configurations
10
+ - Flat configuration via [vite](https://vitejs.dev/config/) flavor `defineConfig`
11
+ - Support [built-in configurations](#built-in-configurations)
12
12
  - `javascript`
13
+ - `comments`
13
14
  - `typescript`
15
+ - `jsdoc`
14
16
  - `prettier`
15
17
  - `vue`
16
18
  - Support primitive eslint flat configuration
@@ -82,7 +84,7 @@ Add the following settings to your `.vscode/settings.json`:
82
84
  // Enable eslint for supported languages
83
85
  "eslint.validate": ["javascript", "typescript", "vue"],
84
86
  // Enable flat configuration
85
- "eslint.experimental.useFlatConfig": true
87
+ "eslint.useFlatConfig": true
86
88
  }
87
89
  ```
88
90
 
@@ -90,12 +92,14 @@ Add the following settings to your `.vscode/settings.json`:
90
92
 
91
93
  The following built-in configurations are supported:
92
94
 
93
- | Configuration | Powered by eslint plugin or package | Need to install eslint plugin or package? |
94
- | ------------- | -------------------------------------------------------------------------------- | ----------------------------------------- |
95
- | `javascript` | [`@eslint/js`](https://www.npmjs.com/package/@eslint/js) | no (built-in) |
96
- | `typescript` | [`typescript-eslint`](https://www.npmjs.com/package/typescript-eslint) | yes |
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 |
95
+ | Configuration | Powered by eslint plugin or package | Need to install eslint plugin or package? |
96
+ | ------------- | ---------------------------------------------------------------------------------------------- | ----------------------------------------- |
97
+ | `javascript` | [`@eslint/js`](https://www.npmjs.com/package/@eslint/js) | no (built-in) |
98
+ | `comments` | [`eslint-plugin-eslint-comments`](https://www.npmjs.com/package/eslint-plugin-eslint-comments) | no (built-in) |
99
+ | `typescript` | [`typescript-eslint`](https://www.npmjs.com/package/typescript-eslint) | yes |
100
+ | `jsdoc` | [`eslint-plugin-jsdoc`](https://www.npmjs.com/package/eslint-plugin-jsdoc) | yes |
101
+ | `prettier` | [`eslint-config-prettier`](https://www.npmjs.com/package/eslint-config-prettier) | yes |
102
+ | `vue` | [`eslint-plugin-vue`](https://www.npmjs.com/package/eslint-plugin-vue) | yes |
99
103
 
100
104
  You can use `import` syntax:
101
105
 
@@ -0,0 +1,4 @@
1
+ import type { Linter } from 'eslint';
2
+ import type { OverridesOptions } from '../types';
3
+ export interface CommentsOptions {}
4
+ export declare function comments(options?: ((CommentsOptions) & (OverridesOptions))): Promise<(Linter.FlatConfig)[]>;
@@ -0,0 +1,4 @@
1
+ import type { Linter } from 'eslint';
2
+ import type { OverridesOptions } from '../types';
3
+ export interface CommentsOptions {}
4
+ export declare function comments(options?: ((CommentsOptions) & (OverridesOptions))): Promise<(Linter.FlatConfig)[]>;
@@ -1,4 +1,6 @@
1
1
  export * from './javascript';
2
+ export * from './comments';
2
3
  export * from './typescript';
4
+ export * from './jsdoc';
3
5
  export * from './prettier';
4
6
  export * from './vue';
@@ -1,4 +1,6 @@
1
1
  export * from './javascript';
2
+ export * from './comments';
2
3
  export * from './typescript';
4
+ export * from './jsdoc';
3
5
  export * from './prettier';
4
6
  export * from './vue';
@@ -0,0 +1,7 @@
1
+ import type { Linter } from 'eslint';
2
+ import type { OverridesOptions } from '../types';
3
+ export interface JsDocOptions {
4
+ typescript?: (('syntax') | ('flavor'));
5
+ error?: boolean;
6
+ }
7
+ export declare function jsdoc(options?: ((JsDocOptions) & (OverridesOptions))): Promise<(Linter.FlatConfig)[]>;
@@ -0,0 +1,7 @@
1
+ import type { Linter } from 'eslint';
2
+ import type { OverridesOptions } from '../types';
3
+ export interface JsDocOptions {
4
+ typescript?: (('syntax') | ('flavor'));
5
+ error?: boolean;
6
+ }
7
+ export declare function jsdoc(options?: ((JsDocOptions) & (OverridesOptions))): Promise<(Linter.FlatConfig)[]>;
package/dist/index.cjs CHANGED
@@ -7,12 +7,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
7
  var __getOwnPropNames = Object.getOwnPropertyNames;
8
8
  var __getProtoOf = Object.getPrototypeOf;
9
9
  var __hasOwnProp = Object.prototype.hasOwnProperty;
10
- var __export = (target, all) => {
11
- for (var name in all) __defProp(target, name, {
12
- get: all[name],
13
- enumerable: true
14
- });
15
- };
16
10
  var __copyProps = (to, from, except, desc) => {
17
11
  if (from && typeof from === 'object' || typeof from === 'function') for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
18
12
  key = keys[i];
@@ -27,7 +21,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
21
  value: mod,
28
22
  enumerable: true
29
23
  }) : target, mod));
30
- var __toCommonJS = (mod) => __copyProps(__defProp({}, '__esModule', {value: true}), mod);
31
24
 
32
25
  //#endregion
33
26
  const { FlatConfigComposer } = __toESM(require("eslint-flat-config-utils"));
@@ -43,7 +36,7 @@ function defineConfig(...configs) {
43
36
  //#region src/utils.ts
44
37
  async function interopDefault(mod) {
45
38
  const resolved = await mod;
46
- return resolved.default || resolved;
39
+ return (resolved).default || resolved;
47
40
  }
48
41
  async function loadPlugin(name) {
49
42
  try {
@@ -61,7 +54,7 @@ async function javascript(options = {}) {
61
54
  const js = await loadPlugin('@eslint/js');
62
55
  return [{
63
56
  name: 'eslint/defaults/rules',
64
- ...js.configs.recommended
57
+ ...(js.configs.recommended)
65
58
  }, {
66
59
  name: '@kazupon/javascript/@eslint/js',
67
60
  languageOptions: {
@@ -86,6 +79,21 @@ async function javascript(options = {}) {
86
79
  }];
87
80
  }
88
81
 
82
+ //#endregion
83
+ //#region src/configs/comments.ts
84
+ async function comments(options = {}) {
85
+ const { rules: overrideRules = {} } = options;
86
+ const comments$1 = await loadPlugin('eslint-plugin-eslint-comments');
87
+ return [{
88
+ name: 'eslint-comments/recommended',
89
+ plugins: {'eslint-comments': comments$1},
90
+ rules: {...(comments$1.configs.recommended.rules)}
91
+ }, {
92
+ name: '@kazupon/eslint-comments',
93
+ rules: {...overrideRules}
94
+ }];
95
+ }
96
+
89
97
  //#endregion
90
98
  //#region src/globs.ts
91
99
  const GLOB_JS = '**/*.?([cm])js';
@@ -100,9 +108,9 @@ async function typescript(options = {}) {
100
108
  const { rules: overrideRules = {}, extraFileExtensions = [], parserOptions = {project: true} } = options;
101
109
  const ts = await loadPlugin('typescript-eslint');
102
110
  const files = options.files ?? [GLOB_TS, GLOB_TSX, ...extraFileExtensions.map((ext) => `**/*${ext}`)];
103
- return [...ts.configs.recommendedTypeChecked, {
111
+ return [...(ts.configs.recommendedTypeChecked), {
104
112
  files: [GLOB_JS, GLOB_JSX],
105
- ...ts.configs.disableTypeChecked
113
+ ...(ts.configs.disableTypeChecked)
106
114
  }, {
107
115
  name: '@kazupon/typescipt/typescript-eslint',
108
116
  files,
@@ -129,6 +137,29 @@ async function typescript(options = {}) {
129
137
  }];
130
138
  }
131
139
 
140
+ //#endregion
141
+ //#region src/configs/jsdoc.ts
142
+ async function jsdoc(options = {}) {
143
+ const { rules: overrideRules = {}, typescript: typescript$1, error = false } = options;
144
+ const jsdoc$1 = await loadPlugin('eslint-plugin-jsdoc');
145
+ function resolvePreset() {
146
+ let preset = 'recommended';
147
+ if (typescript$1 === 'syntax') {
148
+ preset = `${preset}-typescript`;
149
+ } else if (typescript$1 === 'flavor') {
150
+ preset = `${preset}-typescript-flavor`;
151
+ }
152
+ if (error) {
153
+ preset = `${preset}-error`;
154
+ }
155
+ return preset;
156
+ }
157
+ return [jsdoc$1.configs[`flat/${resolvePreset()}`], {
158
+ name: '@kazupon/jsdoc',
159
+ rules: {...overrideRules}
160
+ }];
161
+ }
162
+
132
163
  //#endregion
133
164
  //#region src/configs/prettier.ts
134
165
  async function prettier(options = {}) {
@@ -168,19 +199,15 @@ async function vue(options = {}) {
168
199
  }
169
200
  };
170
201
  }
171
- return [...vue$1.configs['flat/recommended'], customConfig];
202
+ return [...(vue$1.configs['flat/recommended']), customConfig];
172
203
  }
173
204
 
174
205
  //#endregion
175
- //#region src/index.ts
176
- var src_index_ns = {};
177
- __export(src_index_ns, {
178
- defineConfig: () => defineConfig,
179
- javascript: () => javascript,
180
- prettier: () => prettier,
181
- typescript: () => typescript,
182
- vue: () => vue
183
- });
184
-
185
- //#endregion
186
- module.exports = __toCommonJS(src_index_ns)
206
+ Object.defineProperty(exports, '__esModule', { value: true });
207
+ exports.comments = comments;
208
+ exports.defineConfig = defineConfig;
209
+ exports.javascript = javascript;
210
+ exports.jsdoc = jsdoc;
211
+ exports.prettier = prettier;
212
+ exports.typescript = typescript;
213
+ exports.vue = vue;
package/dist/index.js CHANGED
@@ -11,7 +11,7 @@ function defineConfig(...configs) {
11
11
  //#region src/utils.ts
12
12
  async function interopDefault(mod) {
13
13
  const resolved = await mod;
14
- return resolved.default || resolved;
14
+ return (resolved).default || resolved;
15
15
  }
16
16
  async function loadPlugin(name) {
17
17
  try {
@@ -29,7 +29,7 @@ async function javascript(options = {}) {
29
29
  const js = await loadPlugin('@eslint/js');
30
30
  return [{
31
31
  name: 'eslint/defaults/rules',
32
- ...js.configs.recommended
32
+ ...(js.configs.recommended)
33
33
  }, {
34
34
  name: '@kazupon/javascript/@eslint/js',
35
35
  languageOptions: {
@@ -54,6 +54,21 @@ async function javascript(options = {}) {
54
54
  }];
55
55
  }
56
56
 
57
+ //#endregion
58
+ //#region src/configs/comments.ts
59
+ async function comments(options = {}) {
60
+ const { rules: overrideRules = {} } = options;
61
+ const comments$1 = await loadPlugin('eslint-plugin-eslint-comments');
62
+ return [{
63
+ name: 'eslint-comments/recommended',
64
+ plugins: {'eslint-comments': comments$1},
65
+ rules: {...(comments$1.configs.recommended.rules)}
66
+ }, {
67
+ name: '@kazupon/eslint-comments',
68
+ rules: {...overrideRules}
69
+ }];
70
+ }
71
+
57
72
  //#endregion
58
73
  //#region src/globs.ts
59
74
  const GLOB_JS = '**/*.?([cm])js';
@@ -68,9 +83,9 @@ async function typescript(options = {}) {
68
83
  const { rules: overrideRules = {}, extraFileExtensions = [], parserOptions = {project: true} } = options;
69
84
  const ts = await loadPlugin('typescript-eslint');
70
85
  const files = options.files ?? [GLOB_TS, GLOB_TSX, ...extraFileExtensions.map((ext) => `**/*${ext}`)];
71
- return [...ts.configs.recommendedTypeChecked, {
86
+ return [...(ts.configs.recommendedTypeChecked), {
72
87
  files: [GLOB_JS, GLOB_JSX],
73
- ...ts.configs.disableTypeChecked
88
+ ...(ts.configs.disableTypeChecked)
74
89
  }, {
75
90
  name: '@kazupon/typescipt/typescript-eslint',
76
91
  files,
@@ -97,6 +112,29 @@ async function typescript(options = {}) {
97
112
  }];
98
113
  }
99
114
 
115
+ //#endregion
116
+ //#region src/configs/jsdoc.ts
117
+ async function jsdoc(options = {}) {
118
+ const { rules: overrideRules = {}, typescript: typescript$1, error = false } = options;
119
+ const jsdoc$1 = await loadPlugin('eslint-plugin-jsdoc');
120
+ function resolvePreset() {
121
+ let preset = 'recommended';
122
+ if (typescript$1 === 'syntax') {
123
+ preset = `${preset}-typescript`;
124
+ } else if (typescript$1 === 'flavor') {
125
+ preset = `${preset}-typescript-flavor`;
126
+ }
127
+ if (error) {
128
+ preset = `${preset}-error`;
129
+ }
130
+ return preset;
131
+ }
132
+ return [jsdoc$1.configs[`flat/${resolvePreset()}`], {
133
+ name: '@kazupon/jsdoc',
134
+ rules: {...overrideRules}
135
+ }];
136
+ }
137
+
100
138
  //#endregion
101
139
  //#region src/configs/prettier.ts
102
140
  async function prettier(options = {}) {
@@ -136,8 +174,8 @@ async function vue(options = {}) {
136
174
  }
137
175
  };
138
176
  }
139
- return [...vue$1.configs['flat/recommended'], customConfig];
177
+ return [...(vue$1.configs['flat/recommended']), customConfig];
140
178
  }
141
179
 
142
180
  //#endregion
143
- export { defineConfig, javascript, prettier, typescript, vue };
181
+ export { comments, defineConfig, javascript, jsdoc, prettier, typescript, vue };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kazupon/eslint-config",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "ESLint config for @kazupon",
5
5
  "keywords": [
6
6
  "config",
@@ -38,13 +38,15 @@
38
38
  "dependencies": {
39
39
  "@eslint/js": "^9.0.0",
40
40
  "eslint-flat-config-utils": "^0.2.5",
41
+ "eslint-plugin-eslint-comments": "^3.2.0",
41
42
  "globals": "^15.8.0"
42
43
  },
43
44
  "peerDependencies": {
44
45
  "eslint": ">=8.56.0 || >=9.0.0",
45
- "typescript-eslint": ">=7.0.0",
46
46
  "eslint-config-prettier": ">=9.1.0",
47
- "eslint-plugin-vue": ">=9.24.0"
47
+ "eslint-plugin-jsdoc": ">=48.5.0",
48
+ "eslint-plugin-vue": ">=9.24.0",
49
+ "typescript-eslint": ">=7.0.0"
48
50
  },
49
51
  "peerDependenciesMeta": {
50
52
  "typescript-eslint": {
@@ -53,6 +55,9 @@
53
55
  "eslint-config-prettier": {
54
56
  "optional": true
55
57
  },
58
+ "eslint-plugin-jsdoc": {
59
+ "optional": true
60
+ },
56
61
  "eslint-plugin-vue": {
57
62
  "optional": true
58
63
  }
@@ -64,6 +69,7 @@
64
69
  "bumpp": "^9.4.1",
65
70
  "eslint": "^9.6.0",
66
71
  "eslint-config-prettier": "^9.1.0",
72
+ "eslint-plugin-jsdoc": "^48.5.2",
67
73
  "eslint-plugin-vue": "^9.27.0",
68
74
  "gh-changelogen": "^0.2.8",
69
75
  "lint-staged": "^15.2.7",