@tofrankie/eslint 0.0.15 → 0.0.17

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/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## eslint@0.0.17 (2026-03-29)
4
+
5
+ - Add `@tofrankie/tsconfig` to `devDependencies`
6
+
7
+ ## eslint@0.0.16 (2026-03-24)
8
+
9
+ - Add `unicorn/number-literal-case` rule
10
+ - Update `style/operator-linebreak` rule
11
+ - Disable `e18e/ban-dependencies`、`e18e/prefer-array-to-sorted`、`e18e/prefer-static-regex` rules
12
+
3
13
  ## eslint@0.0.15 (2026-03-17)
4
14
 
5
15
  - Require Node.js 20.x (`engines: ^20.0.0 || ^22.0.0 || ^24.0.0`)
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023-PRESENT Tom Gao<tom@tomgao.cc>
3
+ Copyright (c) 2026 Frankie
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 CHANGED
@@ -21,12 +21,14 @@ import { defineConfig } from '@tofrankie/eslint'
21
21
  export default defineConfig()
22
22
  ```
23
23
 
24
+ 更多自定义
25
+
24
26
  ```js
25
27
  import { defineConfig } from '@tofrankie/eslint'
26
28
 
27
29
  export default defineConfig(
28
30
  {
29
- // antfu options...
31
+ // antfu options... see: https://github.com/antfu/eslint-config#customization
30
32
  ignores: ['node_modules', 'dist'],
31
33
  typescript: true,
32
34
  react: true,
@@ -43,7 +45,7 @@ export default defineConfig(
43
45
 
44
46
  ## Configuration Examples
45
47
 
46
- ### Miniapp
48
+ ### Native Miniprogram
47
49
 
48
50
  ```js
49
51
  import { defineConfig } from '@tofrankie/eslint'
package/dist/index.cjs CHANGED
@@ -119,6 +119,18 @@ const BASE_PRESET_RULES = {
119
119
  }]
120
120
  };
121
121
  //#endregion
122
+ //#region src/preset-rules/e8e.ts
123
+ /**
124
+ * - rule: `e8e/*`
125
+ * - plugin: `@e18e/eslint-plugin`
126
+ * @see https://github.com/e18e/eslint-plugin
127
+ */
128
+ const E8E_PRESET_RULES = {
129
+ "e18e/ban-dependencies": "off",
130
+ "e18e/prefer-array-to-sorted": "off",
131
+ "e18e/prefer-static-regex": "off"
132
+ };
133
+ //#endregion
122
134
  //#region src/preset-rules/eslint-comments.ts
123
135
  /**
124
136
  * - rule: `eslint-comments/*`
@@ -189,7 +201,12 @@ const STYLE_PRESET_RULES = {
189
201
  "=": "after",
190
202
  "+": "after",
191
203
  "-": "after",
192
- "&": "after"
204
+ "*": "after",
205
+ "&": "after",
206
+ "<": "after",
207
+ "<=": "after",
208
+ ">": "after",
209
+ ">=": "after"
193
210
  } }
194
211
  ],
195
212
  "style/member-delimiter-style": ["error", {
@@ -227,6 +244,14 @@ const STYLE_PRESET_RULES = {
227
244
  */
228
245
  const TEST_PRESET_RULES = { "test/prefer-lowercase-title": "off" };
229
246
  //#endregion
247
+ //#region src/preset-rules/unicorn.ts
248
+ /**
249
+ * - rule: `unicorn/*`
250
+ * - plugin: `eslint-plugin-unicorn`
251
+ * @see https://github.com/sindresorhus/eslint-plugin-unicorn
252
+ */
253
+ const UNICORN_PRESET_RULES = { "unicorn/number-literal-case": ["error", { hexadecimalValue: "lowercase" }] };
254
+ //#endregion
230
255
  //#region src/preset-rules/vue.ts
231
256
  /**
232
257
  * - rule: `vue/*`
@@ -250,11 +275,15 @@ const VUE_PRESET_RULES = {
250
275
  ({
251
276
  ...ANTFU_PRESET_RULES,
252
277
  ...BASE_PRESET_RULES,
278
+ ...E8E_PRESET_RULES,
253
279
  ...ESLINT_COMMENTS_PRESET_RULES,
254
280
  ...NODE_PRESET_RULES,
255
281
  ...PNPM_PRESET_RULES,
282
+ ...REACT_PRESET_RULES,
256
283
  ...STYLE_PRESET_RULES,
257
- ...TEST_PRESET_RULES
284
+ ...TEST_PRESET_RULES,
285
+ ...UNICORN_PRESET_RULES,
286
+ ...VUE_PRESET_RULES
258
287
  });
259
288
  const PRESET_PREDICATES = [
260
289
  { rules: BASE_PRESET_RULES },
@@ -286,7 +315,9 @@ const PRESET_PREDICATES = [
286
315
  {
287
316
  rules: REACT_PRESET_RULES,
288
317
  predicate: (options) => options.react === true
289
- }
318
+ },
319
+ { rules: E8E_PRESET_RULES },
320
+ { rules: UNICORN_PRESET_RULES }
290
321
  ];
291
322
  function buildPresetRules(resolvedOptions) {
292
323
  return PRESET_PREDICATES.reduce((acc, { rules, predicate }) => {
package/dist/index.d.cts CHANGED
@@ -13,4 +13,5 @@ type Config = ReturnType<typeof antfu>;
13
13
  */
14
14
  declare function defineConfig(antfuOptions?: AntfuOptions, ...userFlatConfigs: UserFlatConfig[]): Config;
15
15
  //#endregion
16
- export { OptionsConfig, defineConfig };
16
+ export { OptionsConfig, defineConfig };
17
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/types.ts","../src/config.ts"],"mappings":";;;UAEiB,aAAA,SAAsB,eAAA;;;KCMlC,YAAA,GAAe,aAAA,GAAgB,IAAA,CAAK,mBAAA;AAAA,KACpC,cAAA,GAAiB,UAAA,QAAkB,KAAA;AAAA,KACnC,MAAA,GAAS,UAAA,QAAkB,KAAA;;;;;iBAMhB,YAAA,CACd,YAAA,GAAe,YAAA,KACZ,eAAA,EAAiB,cAAA,KACnB,MAAA"}
package/dist/index.d.mts CHANGED
@@ -13,4 +13,5 @@ type Config = ReturnType<typeof antfu>;
13
13
  */
14
14
  declare function defineConfig(antfuOptions?: AntfuOptions, ...userFlatConfigs: UserFlatConfig[]): Config;
15
15
  //#endregion
16
- export { OptionsConfig, defineConfig };
16
+ export { OptionsConfig, defineConfig };
17
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/types.ts","../src/config.ts"],"mappings":";;;UAEiB,aAAA,SAAsB,eAAA;;;KCMlC,YAAA,GAAe,aAAA,GAAgB,IAAA,CAAK,mBAAA;AAAA,KACpC,cAAA,GAAiB,UAAA,QAAkB,KAAA;AAAA,KACnC,MAAA,GAAS,UAAA,QAAkB,KAAA;;;;;iBAMhB,YAAA,CACd,YAAA,GAAe,YAAA,KACZ,eAAA,EAAiB,cAAA,KACnB,MAAA"}
package/dist/index.mjs CHANGED
@@ -95,6 +95,18 @@ const BASE_PRESET_RULES = {
95
95
  }]
96
96
  };
97
97
  //#endregion
98
+ //#region src/preset-rules/e8e.ts
99
+ /**
100
+ * - rule: `e8e/*`
101
+ * - plugin: `@e18e/eslint-plugin`
102
+ * @see https://github.com/e18e/eslint-plugin
103
+ */
104
+ const E8E_PRESET_RULES = {
105
+ "e18e/ban-dependencies": "off",
106
+ "e18e/prefer-array-to-sorted": "off",
107
+ "e18e/prefer-static-regex": "off"
108
+ };
109
+ //#endregion
98
110
  //#region src/preset-rules/eslint-comments.ts
99
111
  /**
100
112
  * - rule: `eslint-comments/*`
@@ -165,7 +177,12 @@ const STYLE_PRESET_RULES = {
165
177
  "=": "after",
166
178
  "+": "after",
167
179
  "-": "after",
168
- "&": "after"
180
+ "*": "after",
181
+ "&": "after",
182
+ "<": "after",
183
+ "<=": "after",
184
+ ">": "after",
185
+ ">=": "after"
169
186
  } }
170
187
  ],
171
188
  "style/member-delimiter-style": ["error", {
@@ -203,6 +220,14 @@ const STYLE_PRESET_RULES = {
203
220
  */
204
221
  const TEST_PRESET_RULES = { "test/prefer-lowercase-title": "off" };
205
222
  //#endregion
223
+ //#region src/preset-rules/unicorn.ts
224
+ /**
225
+ * - rule: `unicorn/*`
226
+ * - plugin: `eslint-plugin-unicorn`
227
+ * @see https://github.com/sindresorhus/eslint-plugin-unicorn
228
+ */
229
+ const UNICORN_PRESET_RULES = { "unicorn/number-literal-case": ["error", { hexadecimalValue: "lowercase" }] };
230
+ //#endregion
206
231
  //#region src/preset-rules/vue.ts
207
232
  /**
208
233
  * - rule: `vue/*`
@@ -226,11 +251,15 @@ const VUE_PRESET_RULES = {
226
251
  ({
227
252
  ...ANTFU_PRESET_RULES,
228
253
  ...BASE_PRESET_RULES,
254
+ ...E8E_PRESET_RULES,
229
255
  ...ESLINT_COMMENTS_PRESET_RULES,
230
256
  ...NODE_PRESET_RULES,
231
257
  ...PNPM_PRESET_RULES,
258
+ ...REACT_PRESET_RULES,
232
259
  ...STYLE_PRESET_RULES,
233
- ...TEST_PRESET_RULES
260
+ ...TEST_PRESET_RULES,
261
+ ...UNICORN_PRESET_RULES,
262
+ ...VUE_PRESET_RULES
234
263
  });
235
264
  const PRESET_PREDICATES = [
236
265
  { rules: BASE_PRESET_RULES },
@@ -262,7 +291,9 @@ const PRESET_PREDICATES = [
262
291
  {
263
292
  rules: REACT_PRESET_RULES,
264
293
  predicate: (options) => options.react === true
265
- }
294
+ },
295
+ { rules: E8E_PRESET_RULES },
296
+ { rules: UNICORN_PRESET_RULES }
266
297
  ];
267
298
  function buildPresetRules(resolvedOptions) {
268
299
  return PRESET_PREDICATES.reduce((acc, { rules, predicate }) => {
@@ -306,3 +337,5 @@ function defineConfig(antfuOptions, ...userFlatConfigs) {
306
337
  }
307
338
  //#endregion
308
339
  export { defineConfig };
340
+
341
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/preset-configs/jsdoc.ts","../src/preset-configs/typescript.ts","../src/preset-rules/antfu.ts","../src/preset-rules/base.ts","../src/preset-rules/e8e.ts","../src/preset-rules/eslint-comments.ts","../src/preset-rules/node.ts","../src/preset-rules/pnpm.ts","../src/preset-rules/react.ts","../src/preset-rules/style.ts","../src/preset-rules/test.ts","../src/preset-rules/unicorn.ts","../src/preset-rules/vue.ts","../src/preset-rules/index.ts","../src/config.ts"],"sourcesContent":["import type { Linter } from 'eslint'\nimport { jsdoc } from 'eslint-plugin-jsdoc'\n\nconst SHARED_RULES = {\n 'jsdoc/check-syntax': 'error',\n 'jsdoc/no-defaults': 'off',\n 'jsdoc/require-jsdoc': 'off',\n 'jsdoc/require-param-description': 'off',\n 'jsdoc/require-property-description': 'off',\n 'jsdoc/require-returns': 'off',\n 'jsdoc/require-returns-type': 'off',\n 'jsdoc/require-returns-description': 'off',\n 'jsdoc/newline-after-description': 'off',\n 'jsdoc/reject-any-type': 'off',\n} as const\n\nconst SHARED_SETTINGS = {\n tagNamePreference: {\n description: 'desc',\n property: 'prop',\n returns: 'return',\n },\n} as const\n\n// https://github.com/gajus/eslint-plugin-jsdoc\nconst JSDOC_JS_CONFIG = jsdoc({\n config: 'flat/recommended-typescript-flavor-error',\n files: ['**/*.js', '**/*.jsx', '**/*.cjs', '**/*.mjs'],\n rules: {\n ...SHARED_RULES,\n 'jsdoc/require-param-type': 'warn',\n },\n settings: SHARED_SETTINGS,\n})\n\nconst JSDOC_TS_CONFIG = jsdoc({\n config: 'flat/recommended-typescript-error',\n files: ['**/*.ts', '**/*.tsx', '**/*.cts', '**/*.mts'],\n rules: {\n ...SHARED_RULES,\n 'jsdoc/require-param-type': 'off',\n },\n settings: SHARED_SETTINGS,\n})\n\nexport const JSDOC_PRESET_CONFIG: Linter.Config[] = [JSDOC_JS_CONFIG, JSDOC_TS_CONFIG]\n","import type { Linter } from 'eslint'\n\nexport const TYPESCRIPT_PRESET_CONFIG: Linter.Config = {\n files: ['**/*.ts', '**/*.tsx'],\n rules: {\n // Note: you must disable the base rule as it can report incorrect errors\n 'no-unused-vars': 'off',\n // https://typescript-eslint.io/rules/no-unused-vars/\n 'ts/no-unused-vars': [\n 'error',\n {\n args: 'all',\n argsIgnorePattern: '^_',\n caughtErrors: 'all',\n caughtErrorsIgnorePattern: '^_',\n destructuredArrayIgnorePattern: '^_',\n varsIgnorePattern: '^_',\n ignoreRestSiblings: true,\n },\n ],\n },\n}\n","import type { Linter } from 'eslint'\n\n/**\n * - rule: `antfu/*`\n * - plugin: `eslint-plugin-antfu`\n * @see https://github.com/antfu/eslint-config#top-level-function-style-etc\n * @see https://github.com/antfu/eslint-plugin-antfu\n */\nexport const ANTFU_PRESET_RULES: Linter.RulesRecord = {\n 'antfu/if-newline': 'off',\n 'antfu/consistent-list-newline': 'off',\n}\n","import type { Linter } from 'eslint'\n\n/**\n * - rule: `*`\n * - plugin: `none`\n * @see https://eslint.org/docs/latest/rules/\n */\nexport const BASE_PRESET_RULES: Linter.RulesRecord = {\n // https://eslint.org/docs/latest/rules/\n 'no-console': 'off',\n 'no-debugger': 'warn',\n 'no-unused-vars': [\n 'error',\n {\n vars: 'all',\n args: 'all',\n argsIgnorePattern: '^_',\n destructuredArrayIgnorePattern: '^_',\n varsIgnorePattern: '^_',\n ignoreRestSiblings: true,\n },\n ],\n}\n","import type { Linter } from 'eslint'\n\n/**\n * - rule: `e8e/*`\n * - plugin: `@e18e/eslint-plugin`\n * @see https://github.com/e18e/eslint-plugin\n */\nexport const E8E_PRESET_RULES: Linter.RulesRecord = {\n // https://github.com/es-tooling/eslint-plugin-depend/blob/main/docs/rules/ban-dependencies.md\n 'e18e/ban-dependencies': 'off',\n 'e18e/prefer-array-to-sorted': 'off',\n 'e18e/prefer-static-regex': 'off',\n}\n","import type { Linter } from 'eslint'\n\n/**\n * - rule: `eslint-comments/*`\n * - plugin: `eslint-plugin-eslint-comments`\n * @see https://github.com/antfu/eslint-config\n * @see https://github.com/eslint-community/eslint-plugin-eslint-comments\n */\nexport const ESLINT_COMMENTS_PRESET_RULES: Linter.RulesRecord = {\n 'eslint-comments/no-unlimited-disable': 'off',\n}\n","import type { Linter } from 'eslint'\n\n/**\n * - rule: `node/*`\n * - original rule: `n/*`\n * - plugin: `eslint-plugin-n`\n * @see https://github.com/antfu/eslint-config#node\n * @see https://github.com/eslint-community/eslint-plugin-n\n */\nexport const NODE_PRESET_RULES: Linter.RulesRecord = {\n 'node/prefer-global/process': 'off',\n}\n","import type { Linter } from 'eslint'\n\n/**\n * - rule: `pnpm/*`\n * - plugin: `eslint-plugin-pnpm`\n * @see https://github.com/antfu/eslint-config\n * @see https://github.com/antfu/pnpm-workspace-utils/tree/main/packages/eslint-plugin-pnpm\n */\nexport const PNPM_PRESET_RULES: Linter.RulesRecord = {\n 'pnpm/yaml-enforce-settings': 'off',\n}\n","import type { Linter } from 'eslint'\n\n/**\n * - rule: `react/*`、`react-hooks-extra/*`\n * - plugin: `eslint-plugin-react-hooks-extra`\n * @see https://www.npmjs.com/package/eslint-plugin-react-hooks-extra\n */\nexport const REACT_PRESET_RULES: Linter.RulesRecord = {\n 'react-hooks-extra/no-direct-set-state-in-use-effect': 'off',\n}\n","import type { Linter } from 'eslint'\n\n/**\n * - rule: `style/*`\n * - original rule: `@stylistic/*`\n * - plugin: `@stylistic/eslint-plugin`\n * @see https://github.com/antfu/eslint-config#stylistic\n * @see https://eslint.style/rules\n */\nexport const STYLE_PRESET_RULES: Linter.RulesRecord = {\n // https://eslint.style/rules/quotes#single\n 'style/quotes': ['error', 'single', { avoidEscape: true, allowTemplateLiterals: 'avoidEscape' }],\n // https://eslint.style/rules/quote-props#as-needed\n 'style/quote-props': ['error', 'as-needed'],\n 'style/arrow-parens': ['error', 'as-needed'],\n 'style/brace-style': ['error', '1tbs', { allowSingleLine: false }],\n 'style/operator-linebreak': [\n 'error',\n 'before',\n {\n // 与 Prettier 保持一致\n overrides: {\n '&&': 'after',\n '||': 'after',\n '??': 'after',\n '=': 'after',\n '+': 'after',\n '-': 'after',\n '*': 'after',\n '&': 'after',\n '<': 'after',\n '<=': 'after',\n '>': 'after',\n '>=': 'after',\n },\n },\n ],\n 'style/member-delimiter-style': [\n 'error',\n {\n multiline: {\n delimiter: 'none',\n requireLast: false,\n },\n singleline: {\n delimiter: 'semi', // 与 Prettier 保持一致\n requireLast: false,\n },\n multilineDetection: 'brackets',\n overrides: {\n interface: {\n multiline: {\n delimiter: 'none',\n requireLast: false,\n },\n },\n },\n },\n ],\n // 关闭以下样式相关的规则,交由 prettier 处理\n 'style/comma-dangle': 'off',\n 'style/indent': 'off',\n 'style/indent-binary-ops': 'off',\n 'style/multiline-ternary': 'off',\n 'style/jsx-wrap-multilines': 'off',\n 'style/jsx-curly-newline': 'off',\n 'style/jsx-one-expression-per-line': 'off',\n}\n","import type { Linter } from 'eslint'\n\n/**\n * - rule: `test/*`\n * - original rule: `vitest/*`, `no-only-tests/*`\n * - plugin: `@vitest/eslint-plugin`, `eslint-plugin-no-only-tests`\n * @see https://github.com/antfu/eslint-config#test\n * @see https://github.com/vitest-dev/eslint-plugin-vitest\n * @see https://github.com/levibuzolic/eslint-plugin-no-only-tests\n */\nexport const TEST_PRESET_RULES: Linter.RulesRecord = {\n 'test/prefer-lowercase-title': 'off',\n}\n","import type { Linter } from 'eslint'\n\n/**\n * - rule: `unicorn/*`\n * - plugin: `eslint-plugin-unicorn`\n * @see https://github.com/sindresorhus/eslint-plugin-unicorn\n */\nexport const UNICORN_PRESET_RULES: Linter.RulesRecord = {\n // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/number-literal-case.md\n 'unicorn/number-literal-case': ['error', { hexadecimalValue: 'lowercase' }], // 与 Prettier 0xFF -> 0xff\n}\n","import type { Linter } from 'eslint'\n\n/**\n * - rule: `vue/*`\n * - plugin: `eslint-plugin-vue`\n * @see https://eslint.vuejs.org/rules/\n */\nexport const VUE_PRESET_RULES: Linter.RulesRecord = {\n // https://eslint.vuejs.org/rules/singleline-html-element-content-newline.html\n 'vue/singleline-html-element-content-newline': 'off', // 避免与 prettier 冲突\n // https://eslint.vuejs.org/rules/html-closing-bracket-newline.html\n 'vue/html-closing-bracket-newline': 'off', // 避免与 prettier 冲突\n // https://eslint.vuejs.org/rules/html-indent.html\n 'vue/html-indent': 'off', // 避免与 prettier 冲突\n 'vue/html-self-closing': [\n 'warn',\n {\n html: {\n void: 'always', // 与 Prettier 保持一致,对于 <br />、<img /> 此类 void element 保留末尾 />,而不是 vue/html-self-closing 默认推荐的 <br>、<img>\n normal: 'always', // 对于 <div></div> 此类无内容的非 void element 处理成 <div /> 以符合 Vue 推荐的风格 https://vuejs.org/style-guide/rules-strongly-recommended.html#self-closing-components\n component: 'always', // 对于 <my-component></my-component> 此类无内容的自定义组件处理成 <my-component /> 以符合 Vue 推荐的风格 https://vuejs.org/style-guide/rules-strongly-recommended.html#self-closing-components\n },\n svg: 'always',\n math: 'always',\n },\n ],\n}\n","import type { Linter } from 'eslint'\nimport type { OptionsConfig } from '../types'\nimport { ANTFU_PRESET_RULES } from './antfu'\nimport { BASE_PRESET_RULES } from './base'\nimport { E8E_PRESET_RULES } from './e8e'\nimport { ESLINT_COMMENTS_PRESET_RULES } from './eslint-comments'\nimport { NODE_PRESET_RULES } from './node'\nimport { PNPM_PRESET_RULES } from './pnpm'\nimport { REACT_PRESET_RULES } from './react'\nimport { STYLE_PRESET_RULES } from './style'\nimport { TEST_PRESET_RULES } from './test'\nimport { UNICORN_PRESET_RULES } from './unicorn'\nimport { VUE_PRESET_RULES } from './vue'\n\nexport const ALL_PRESET_RULES = {\n ...ANTFU_PRESET_RULES,\n ...BASE_PRESET_RULES,\n ...E8E_PRESET_RULES,\n ...ESLINT_COMMENTS_PRESET_RULES,\n ...NODE_PRESET_RULES,\n ...PNPM_PRESET_RULES,\n ...REACT_PRESET_RULES,\n ...STYLE_PRESET_RULES,\n ...TEST_PRESET_RULES,\n ...UNICORN_PRESET_RULES,\n ...VUE_PRESET_RULES,\n}\n\n// 如果关闭 antfu 对应选项,则不加载相关预设 rules,以避免 lint 时找不到规则而报错\nconst PRESET_PREDICATES: Array<{\n rules: Linter.RulesRecord\n predicate?: OptionPredicate\n}> = [\n { rules: BASE_PRESET_RULES },\n { rules: ESLINT_COMMENTS_PRESET_RULES },\n { rules: STYLE_PRESET_RULES, predicate: notFalse('stylistic') },\n {\n rules: ANTFU_PRESET_RULES,\n predicate: options => (options as Record<string, unknown>).lessOpinionated !== true,\n },\n { rules: NODE_PRESET_RULES, predicate: notFalse('node') },\n { rules: TEST_PRESET_RULES, predicate: notFalse('test') },\n { rules: PNPM_PRESET_RULES, predicate: notFalse('pnpm') },\n {\n rules: VUE_PRESET_RULES,\n predicate: options => (options as Record<string, unknown>).vue === true,\n },\n {\n rules: REACT_PRESET_RULES,\n predicate: options => (options as Record<string, unknown>).react === true,\n },\n { rules: E8E_PRESET_RULES },\n { rules: UNICORN_PRESET_RULES },\n]\n\nexport function buildPresetRules(resolvedOptions: OptionsConfig): Linter.RulesRecord {\n return PRESET_PREDICATES.reduce<Linter.RulesRecord>((acc, { rules, predicate }) => {\n if (!predicate || predicate(resolvedOptions)) {\n Object.assign(acc, rules)\n }\n return acc\n }, {})\n}\n\ntype OptionPredicate = (options: OptionsConfig) => boolean\n\n/**\n * 自动检测/默认开启的配置,若不为 false 则加载相关预设 rules\n * 如果默认关闭的配置,若为 true 才加载相关预设 rules\n * @param key - The key of the option to check.\n * @return A predicate function that checks if the option is not false.\n */\nfunction notFalse(key: keyof OptionsConfig): OptionPredicate {\n return options => (options as Record<string, unknown>)[key as string] !== false\n}\n","import type { TypedFlatConfigItem } from '@antfu/eslint-config'\nimport type { OptionsConfig } from './types'\nimport { antfu } from '@antfu/eslint-config'\nimport merge from 'lodash.merge'\nimport { JSDOC_PRESET_CONFIG } from './preset-configs/jsdoc'\nimport { TYPESCRIPT_PRESET_CONFIG } from './preset-configs/typescript'\nimport { buildPresetRules } from './preset-rules'\n\ntype AntfuOptions = OptionsConfig & Omit<TypedFlatConfigItem, 'files'>\ntype UserFlatConfig = Parameters<typeof antfu>[1]\ntype Config = ReturnType<typeof antfu>\n\n/**\n * @param antfuOptions Configures for antfu's config.\n * @param userFlatConfigs From the second arguments they are ESLint Flat Configs, you can have multiple configs.\n */\nexport function defineConfig(\n antfuOptions?: AntfuOptions,\n ...userFlatConfigs: UserFlatConfig[]\n): Config {\n const userOptions = antfuOptions ?? {}\n const { rules: userRules, ...userOptionsWithoutRules } = userOptions\n\n const baseOptions: AntfuOptions = {\n formatters: {\n // Same configuration as @tofrankie/prettier\n prettierOptions: {\n printWidth: 100,\n semi: false,\n singleQuote: true,\n arrowParens: 'avoid',\n trailingComma: 'es5',\n htmlWhitespaceSensitivity: 'css',\n },\n },\n typescript: true,\n }\n\n // 1. 合并预设选项与用户选项(排除 rules)\n const mergedOptions = merge({}, baseOptions, userOptionsWithoutRules) as AntfuOptions\n\n // 2. 根据 mergedOptions 取预设规则\n const presetRules = buildPresetRules(mergedOptions)\n\n // 3. presetRules 与 userRules 合并,用户覆盖预设\n const mergedRules = merge({}, presetRules, userRules ?? {})\n\n // 4. mergedOptions 与 rules 合并\n const resolvedOptions = merge({}, mergedOptions, { rules: mergedRules })\n\n // 5. 根据 resolvedOptions 决定是否加载相关预设\n const presetConfigs = []\n if (mergedOptions.typescript) {\n presetConfigs.push(TYPESCRIPT_PRESET_CONFIG)\n }\n if (mergedOptions.jsdoc !== false) {\n presetConfigs.push(...JSDOC_PRESET_CONFIG)\n }\n\n return antfu(resolvedOptions, ...presetConfigs, ...userFlatConfigs)\n}\n"],"mappings":";;;;AAGA,MAAM,eAAe;CACnB,sBAAsB;CACtB,qBAAqB;CACrB,uBAAuB;CACvB,mCAAmC;CACnC,sCAAsC;CACtC,yBAAyB;CACzB,8BAA8B;CAC9B,qCAAqC;CACrC,mCAAmC;CACnC,yBAAyB;CAC1B;AAED,MAAM,kBAAkB,EACtB,mBAAmB;CACjB,aAAa;CACb,UAAU;CACV,SAAS;CACV,EACF;AAuBD,MAAa,sBAAuC,CApB5B,MAAM;CAC5B,QAAQ;CACR,OAAO;EAAC;EAAW;EAAY;EAAY;EAAW;CACtD,OAAO;EACL,GAAG;EACH,4BAA4B;EAC7B;CACD,UAAU;CACX,CAAC,EAEsB,MAAM;CAC5B,QAAQ;CACR,OAAO;EAAC;EAAW;EAAY;EAAY;EAAW;CACtD,OAAO;EACL,GAAG;EACH,4BAA4B;EAC7B;CACD,UAAU;CACX,CAAC,CAEoF;;;AC3CtF,MAAa,2BAA0C;CACrD,OAAO,CAAC,WAAW,WAAW;CAC9B,OAAO;EAEL,kBAAkB;E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AC1C,QAAO,OAAO,KAAK,MAAM;AAE3B,SAAO;IACN,EAAE,CAAC;;;;;;;;AAWR,SAAS,SAAS,KAA2C;AAC3D,SAAO,YAAY,QAAoC,SAAmB;;;;;;;;ACzD5E,SAAgB,aACd,cACA,GAAG,iBACK;CAER,MAAM,EAAE,OAAO,WAAW,GAAG,4BADT,gBAAgB,EAAE;CAmBtC,MAAM,gBAAgB,MAAM,EAAE,EAhBI;EAChC,YAAY,EAEV,iBAAiB;GACf,YAAY;GACZ,MAAM;GACN,aAAa;GACb,aAAa;GACb,eAAe;GACf,2BAA2B;GAC5B,EACF;EACD,YAAY;EACb,EAG4C,wBAAwB;CASrE,MAAM,kBAAkB,MAAM,EAAE,EAAE,eAAe,EAAE,OAH/B,MAAM,EAAE,EAHR,iBAAiB,cAAc,EAGR,aAAa,EAAE,CAAC,EAGY,CAAC;CAGxE,MAAM,gBAAgB,EAAE;AACxB,KAAI,cAAc,WAChB,eAAc,KAAK,yBAAyB;AAE9C,KAAI,cAAc,UAAU,MAC1B,eAAc,KAAK,GAAG,oBAAoB;AAG5C,QAAO,MAAM,iBAAiB,GAAG,eAAe,GAAG,gBAAgB"}
package/package.json CHANGED
@@ -1,12 +1,16 @@
1
1
  {
2
2
  "name": "@tofrankie/eslint",
3
3
  "type": "module",
4
- "version": "0.0.15",
4
+ "version": "0.0.17",
5
5
  "description": "Shared ESLint configuration",
6
6
  "author": "Frankie <1426203851@qq.com>",
7
7
  "license": "MIT",
8
8
  "homepage": "https://github.com/tofrankie/config/tree/main/packages/eslint",
9
- "repository": "github:tofrankie/config",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/tofrankie/config.git",
12
+ "directory": "packages/eslint"
13
+ },
10
14
  "bugs": "https://github.com/tofrankie/config/issues",
11
15
  "keywords": [
12
16
  "eslint",
@@ -54,9 +58,11 @@
54
58
  },
55
59
  "devDependencies": {
56
60
  "@types/lodash.merge": "^4.6.9",
57
- "eslint": "^9.39.4"
61
+ "eslint": "^9.39.4",
62
+ "@tofrankie/tsconfig": "0.0.1"
58
63
  },
59
64
  "scripts": {
65
+ "dev": "tsdown --watch",
60
66
  "build": "tsdown",
61
67
  "publint": "publint"
62
68
  }