@vida0905/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
@@ -8,7 +8,7 @@ Self use eslint config, extends [antfu's config](https://github.com/antfu/eslint
8
8
 
9
9
  - More stricter rules.
10
10
  - Support `pinia`.
11
- - Disable `formatter` and `jsx`
11
+ - Disable `jsx` by default.
12
12
 
13
13
  ### Setup
14
14
 
@@ -19,9 +19,9 @@ npm i -D @vida/eslint-config
19
19
  in `eslint.config.js`
20
20
 
21
21
  ```js
22
- import { vida } from '@vida0905/eslint-config';
22
+ import { vida } from '@vida0905/eslint-config'
23
23
 
24
- export default vida();
24
+ export default vida()
25
25
  ```
26
26
 
27
27
  in `.vscode/settings.json`, more info to [@antfu/eslint-config](https://github.com/antfu/eslint-config?tab=readme-ov-file#vs-code-support-auto-fix-on-save)
package/dist/index.d.ts CHANGED
@@ -1,18 +1,76 @@
1
1
  import * as eslint_flat_config_utils from 'eslint-flat-config-utils';
2
2
  import * as _antfu_eslint_config from '@antfu/eslint-config';
3
- import { antfu, TypedFlatConfigItem } from '@antfu/eslint-config';
3
+ import { antfu, TypedFlatConfigItem as TypedFlatConfigItem$1 } from '@antfu/eslint-config';
4
4
  export * from '@antfu/eslint-config';
5
+ import { Linter } from 'eslint';
6
+
7
+ /* eslint-disable */
8
+ /* prettier-ignore */
9
+
10
+
11
+ interface RuleOptions {
12
+ /**
13
+ * Never export an initialized named or default store.
14
+ * @see https://github.com/lisilinhart/eslint-plugin-pinia/blob/main/docs/rules/never-export-initialized-store.md
15
+ */
16
+ 'pinia/never-export-initialized-store'?: Linter.RuleEntry<[]>
17
+ /**
18
+ * Disallow duplicate store ids.
19
+ * @see https://github.com/lisilinhart/eslint-plugin-pinia/blob/main/docs/rules/no-duplicate-store-ids.md
20
+ */
21
+ 'pinia/no-duplicate-store-ids'?: Linter.RuleEntry<[]>
22
+ /**
23
+ * Disallows returning globally provided properties from Pinia stores.
24
+ * @see https://github.com/lisilinhart/eslint-plugin-pinia/blob/main/docs/rules/no-return-global-properties.md
25
+ */
26
+ 'pinia/no-return-global-properties'?: Linter.RuleEntry<[]>
27
+ /**
28
+ * Encourages defining each store in a separate file.
29
+ * @see https://github.com/lisilinhart/eslint-plugin-pinia/blob/main/docs/rules/prefer-single-store-per-file.md
30
+ */
31
+ 'pinia/prefer-single-store-per-file'?: Linter.RuleEntry<[]>
32
+ /**
33
+ * Enforces the convention of naming stores with the prefix `use` followed by the store name.
34
+ * @see https://github.com/lisilinhart/eslint-plugin-pinia/blob/main/docs/rules/prefer-use-store-naming-convention.md
35
+ */
36
+ 'pinia/prefer-use-store-naming-convention'?: Linter.RuleEntry<PiniaPreferUseStoreNamingConvention>
37
+ /**
38
+ * In setup stores all state properties must be exported.
39
+ * @see https://github.com/lisilinhart/eslint-plugin-pinia/blob/main/docs/rules/require-setup-store-properties-export.md
40
+ */
41
+ 'pinia/require-setup-store-properties-export'?: Linter.RuleEntry<[]>
42
+ }
43
+
44
+ /* ======= Declarations ======= */
45
+ // ----- pinia/prefer-use-store-naming-convention -----
46
+ type PiniaPreferUseStoreNamingConvention = []|[{
47
+ checkStoreNameMismatch?: boolean
48
+ storeSuffix?: string
49
+ [k: string]: unknown | undefined
50
+ }]
5
51
 
6
52
  type AntfuOptions = Parameters<typeof antfu>[0];
7
- type OptionsConfig = AntfuOptions & {
53
+ type Rules = RuleOptions;
54
+ type TypedFlatConfigItem = Omit<Linter.FlatConfig<Linter.RulesRecord & Rules>, 'plugins'> & {
55
+ /**
56
+ * An object containing a name-value mapping of plugin names to plugin objects. When `files` is specified, these plugins are only available to the matching files.
57
+ *
58
+ * @see [Using plugins in your configuration](https://eslint.org/docs/latest/user-guide/configuring/configuration-files-new#using-plugins-in-your-configuration)
59
+ */
60
+ plugins?: Record<string, any>;
61
+ };
62
+ interface OptionsOverrides {
63
+ overrides?: TypedFlatConfigItem['rules'];
64
+ }
65
+ type OptionsConfig = Omit<AntfuOptions, 'overrides'> & {
8
66
  /**
9
67
  * Enable Pinia support.
10
68
  *
11
69
  * @default auto-detect based on the dependencies
12
70
  */
13
- pinia?: boolean;
71
+ pinia?: boolean | OptionsOverrides;
14
72
  };
15
73
 
16
- declare function vida(options?: OptionsConfig, ...userConfigs: TypedFlatConfigItem[]): eslint_flat_config_utils.FlatConfigComposer<TypedFlatConfigItem, _antfu_eslint_config.ConfigNames>;
74
+ declare function vida(options?: OptionsConfig & TypedFlatConfigItem$1, ...userConfigs: TypedFlatConfigItem$1[]): eslint_flat_config_utils.FlatConfigComposer<TypedFlatConfigItem$1, _antfu_eslint_config.ConfigNames>;
17
75
 
18
76
  export { vida as default, vida };
package/dist/index.js CHANGED
@@ -1,30 +1,37 @@
1
1
  // src/index.ts
2
- import antfu from "@antfu/eslint-config";
2
+ import antfu, { resolveSubOptions } from "@antfu/eslint-config";
3
3
  import { isPackageExists } from "local-pkg";
4
4
 
5
5
  // src/configs/pinia.ts
6
- import { GLOB_JS, GLOB_TS } from "@antfu/eslint-config";
7
- import pluginPinia from "eslint-plugin-pinia";
8
- var GLOB_PINIA_JS = `stores/${GLOB_JS}`;
9
- var GLOB_PINIA_TS = `stores/${GLOB_TS}`;
10
- var pinia = [
11
- {
12
- name: "vida/pinia",
13
- files: [GLOB_PINIA_JS, GLOB_PINIA_TS],
14
- plugins: {
15
- pinia: pluginPinia
16
- },
17
- rules: {
18
- "pinia/prefer-single-store-per-file": ["error"],
19
- "pinia/prefer-use-store-naming-convention": ["error", {
20
- checkStoreNameMismatch: true,
21
- storeSuffix: "Store"
22
- }],
23
- "pinia/require-setup-store-properties-export": ["warn"],
24
- "pinia/no-duplicate-store-ids": ["error"]
6
+ import { GLOB_JS, GLOB_TS, interopDefault } from "@antfu/eslint-config";
7
+ var GLOB_PINIA_JS = `**/stores/${GLOB_JS}`;
8
+ var GLOB_PINIA_TS = `**/stores/${GLOB_TS}`;
9
+ async function pinia(options = {}) {
10
+ const {
11
+ files = [GLOB_PINIA_JS, GLOB_PINIA_TS],
12
+ overrides = {}
13
+ } = options;
14
+ return [
15
+ {
16
+ name: "@vida/pinia",
17
+ files,
18
+ plugins: {
19
+ pinia: await interopDefault(import("eslint-plugin-pinia"))
20
+ },
21
+ rules: {
22
+ "pinia/never-export-initialized-store": "error",
23
+ "pinia/prefer-single-store-per-file": "warn",
24
+ "pinia/prefer-use-store-naming-convention": ["error", {
25
+ checkStoreNameMismatch: true,
26
+ storeSuffix: "Store"
27
+ }],
28
+ "pinia/require-setup-store-properties-export": "warn",
29
+ "pinia/no-duplicate-store-ids": "error",
30
+ ...overrides
31
+ }
25
32
  }
26
- }
27
- ];
33
+ ];
34
+ }
28
35
 
29
36
  // src/overrides/javascript.ts
30
37
  var javascript = {
@@ -49,7 +56,7 @@ function vida(options = {}, ...userConfigs) {
49
56
  } = options;
50
57
  const configs = [];
51
58
  if (enablePinia)
52
- configs.push(pinia);
59
+ configs.push(pinia(resolveSubOptions(options, "pinia")));
53
60
  const antfuConfig = {
54
61
  stylistic: {
55
62
  indent: 2,
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@vida0905/eslint-config",
3
3
  "type": "module",
4
- "version": "0.2.0",
5
- "packageManager": "pnpm@9.1.2",
4
+ "version": "0.4.0",
5
+ "packageManager": "pnpm@9.5.0",
6
6
  "description": "Vida Xie's ESLint Config",
7
7
  "author": "Vida Xie <vida_2020@163.com> (https://github.com/9romise/)",
8
8
  "license": "MIT",
@@ -33,21 +33,47 @@
33
33
  "lint:fix": "eslint . --fix",
34
34
  "dev": "tsup --watch",
35
35
  "inspect": "npx @eslint/config-inspector",
36
- "build": "tsup",
36
+ "typegen": "tsx scripts/typegen",
37
+ "build": "npm run typegen && tsup",
37
38
  "release": "npm run lint && npm run typecheck && bumpp",
38
39
  "typecheck": "tsc --noEmit",
39
- "prepublish": "npm run build"
40
+ "prepack": "npm run build",
41
+ "prepare": "simple-git-hooks"
42
+ },
43
+ "peerDependencies": {
44
+ "@unocss/eslint-plugin": ">=0.50.0",
45
+ "eslint": ">=8.40.0",
46
+ "eslint-plugin-format": ">=0.1.0"
47
+ },
48
+ "peerDependenciesMeta": {
49
+ "@unocss/eslint-plugin": {
50
+ "optional": true
51
+ },
52
+ "eslint-plugin-format": {
53
+ "optional": true
54
+ }
40
55
  },
41
56
  "dependencies": {
42
- "@antfu/eslint-config": "^2.18.1",
43
- "eslint-plugin-pinia": "^0.1.13",
57
+ "@antfu/eslint-config": "^2.22.4",
58
+ "eslint-plugin-pinia": "^0.2.0",
44
59
  "local-pkg": "^0.5.0"
45
60
  },
46
61
  "devDependencies": {
47
- "@eslint/config-inspector": "^0.4.8",
62
+ "@eslint/config-inspector": "^0.5.1",
63
+ "@types/node": "^20.14.11",
48
64
  "bumpp": "^9.4.1",
49
- "eslint": "^9.3.0",
50
- "tsup": "^8.0.2",
51
- "typescript": "^5.4.5"
65
+ "eslint": "^9.7.0",
66
+ "eslint-typegen": "^0.2.4",
67
+ "lint-staged": "^15.2.7",
68
+ "simple-git-hooks": "^2.11.1",
69
+ "tsup": "^8.1.0",
70
+ "tsx": "^4.16.2",
71
+ "typescript": "^5.5.3"
72
+ },
73
+ "simple-git-hooks": {
74
+ "pre-commit": "npx lint-staged"
75
+ },
76
+ "lint-staged": {
77
+ "*": "eslint --fix"
52
78
  }
53
79
  }
package/dist/index.cjs DELETED
@@ -1,121 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
21
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
29
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
-
31
- // src/index.ts
32
- var src_exports = {};
33
- __export(src_exports, {
34
- default: () => src_default,
35
- vida: () => vida
36
- });
37
- module.exports = __toCommonJS(src_exports);
38
- var import_eslint_config2 = __toESM(require("@antfu/eslint-config"), 1);
39
- var import_local_pkg = require("local-pkg");
40
-
41
- // src/configs/pinia.ts
42
- var import_eslint_config = require("@antfu/eslint-config");
43
- var import_eslint_plugin_pinia = __toESM(require("eslint-plugin-pinia"), 1);
44
- var GLOB_PINIA_JS = `stores/${import_eslint_config.GLOB_JS}`;
45
- var GLOB_PINIA_TS = `stores/${import_eslint_config.GLOB_TS}`;
46
- var pinia = [
47
- {
48
- name: "vida/pinia",
49
- files: [GLOB_PINIA_JS, GLOB_PINIA_TS],
50
- plugins: {
51
- pinia: import_eslint_plugin_pinia.default
52
- },
53
- rules: {
54
- "pinia/prefer-single-store-per-file": ["error"],
55
- "pinia/prefer-use-store-naming-convention": ["error", {
56
- checkStoreNameMismatch: true,
57
- storeSuffix: "Store"
58
- }],
59
- "pinia/require-setup-store-properties-export": ["warn"],
60
- "pinia/no-duplicate-store-ids": ["error"]
61
- }
62
- }
63
- ];
64
-
65
- // src/overrides/javascript.ts
66
- var javascript = {
67
- "arrow-body-style": ["error", "as-needed"],
68
- "no-unused-private-class-members": "error",
69
- "require-atomic-updates": ["error", { allowProperties: true }]
70
- };
71
-
72
- // src/overrides/vue.ts
73
- var vue = {
74
- "vue/max-attributes-per-line": ["error", {
75
- singleline: 5,
76
- multiline: 1
77
- }]
78
- };
79
-
80
- // src/index.ts
81
- __reExport(src_exports, require("@antfu/eslint-config"), module.exports);
82
- function vida(options = {}, ...userConfigs) {
83
- const {
84
- pinia: enablePinia = (0, import_local_pkg.isPackageExists)("pinia")
85
- } = options;
86
- const configs = [];
87
- if (enablePinia)
88
- configs.push(pinia);
89
- const antfuConfig = {
90
- stylistic: {
91
- indent: 2,
92
- quotes: "single",
93
- semi: false,
94
- overrides: {
95
- "style/arrow-parens": ["error", "always"],
96
- "style/brace-style": ["error", "1tbs", { allowSingleLine: true }]
97
- }
98
- },
99
- javascript: {
100
- overrides: javascript
101
- },
102
- vue: {
103
- overrides: vue
104
- },
105
- jsx: false
106
- };
107
- return (0, import_eslint_config2.default)(
108
- {
109
- ...antfuConfig,
110
- ...options
111
- },
112
- ...configs,
113
- ...userConfigs
114
- );
115
- }
116
- var src_default = vida;
117
- // Annotate the CommonJS export names for ESM import in node:
118
- 0 && (module.exports = {
119
- vida,
120
- ...require("@antfu/eslint-config")
121
- });
package/dist/index.d.cts DELETED
@@ -1,18 +0,0 @@
1
- import * as eslint_flat_config_utils from 'eslint-flat-config-utils';
2
- import * as _antfu_eslint_config from '@antfu/eslint-config';
3
- import { antfu, TypedFlatConfigItem } from '@antfu/eslint-config';
4
- export * from '@antfu/eslint-config';
5
-
6
- type AntfuOptions = Parameters<typeof antfu>[0];
7
- type OptionsConfig = AntfuOptions & {
8
- /**
9
- * Enable Pinia support.
10
- *
11
- * @default auto-detect based on the dependencies
12
- */
13
- pinia?: boolean;
14
- };
15
-
16
- declare function vida(options?: OptionsConfig, ...userConfigs: TypedFlatConfigItem[]): eslint_flat_config_utils.FlatConfigComposer<TypedFlatConfigItem, _antfu_eslint_config.ConfigNames>;
17
-
18
- export { vida as default, vida };