@vida0905/eslint-config 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Vida Xie
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,57 @@
1
+ # @vida/eslint-config
2
+
3
+ [![npm](https://img.shields.io/npm/v/@vida/eslint-config.svg)](https://npmjs.com/package/@vida/eslint-config)
4
+
5
+ Self use eslint config, extends [antfu's config](https://github.com/antfu/eslint-config)
6
+
7
+ ### Difference
8
+
9
+ - More stricter rules.
10
+ - Support `pinia`.
11
+
12
+ ### Setup
13
+
14
+ ```shell
15
+ npm i -D @vida/eslint-config
16
+ ```
17
+
18
+ in `eslint.config.js`
19
+
20
+ ```js
21
+ import { vida } from '@vida/eslint-config';
22
+
23
+ export default vida();
24
+ ```
25
+
26
+ 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)
27
+
28
+ ```json
29
+ {
30
+ // Enable the ESlint flat config support
31
+ "eslint.experimental.useFlatConfig": true,
32
+
33
+ // Disable the default formatter, use eslint instead
34
+ "prettier.enable": false,
35
+ "editor.formatOnSave": false,
36
+
37
+ // Auto fix
38
+ "editor.codeActionsOnSave": {
39
+ "source.fixAll.eslint": "explicit",
40
+ "source.organizeImports": "never"
41
+ },
42
+
43
+ // Enable eslint for all supported languages
44
+ "eslint.validate": [
45
+ "javascript",
46
+ "javascriptreact",
47
+ "typescript",
48
+ "typescriptreact",
49
+ "vue",
50
+ "html",
51
+ "markdown",
52
+ "json",
53
+ "jsonc",
54
+ "yaml"
55
+ ]
56
+ }
57
+ ```
package/dist/index.cjs ADDED
@@ -0,0 +1,119 @@
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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var src_exports = {};
32
+ __export(src_exports, {
33
+ default: () => src_default,
34
+ vida: () => vida
35
+ });
36
+ module.exports = __toCommonJS(src_exports);
37
+ var import_eslint_config3 = __toESM(require("@antfu/eslint-config"), 1);
38
+ var import_local_pkg = require("local-pkg");
39
+
40
+ // src/configs/pinia.ts
41
+ var import_eslint_config = require("@antfu/eslint-config");
42
+ var import_eslint_plugin_pinia = __toESM(require("eslint-plugin-pinia"), 1);
43
+ var pinia = [
44
+ {
45
+ name: "vida:pinia",
46
+ files: [import_eslint_config.GLOB_JS, import_eslint_config.GLOB_TS],
47
+ plugins: {
48
+ pinia: import_eslint_plugin_pinia.default
49
+ },
50
+ rules: {
51
+ "pinia/prefer-single-store-per-file": ["error"],
52
+ "pinia/prefer-use-store-naming-convention": ["error", {
53
+ checkStoreNameMismatch: true,
54
+ storeSuffix: "Store"
55
+ }],
56
+ "pinia/require-setup-store-properties-export": ["warn"]
57
+ }
58
+ }
59
+ ];
60
+
61
+ // src/configs/vue.ts
62
+ var import_eslint_config2 = require("@antfu/eslint-config");
63
+ var vue = [
64
+ {
65
+ name: "vida:vue",
66
+ files: [import_eslint_config2.GLOB_VUE],
67
+ rules: {
68
+ "vue/max-attributes-per-line": ["error", {
69
+ singleline: { max: 5 },
70
+ multiline: { max: 1 }
71
+ }]
72
+ }
73
+ }
74
+ ];
75
+
76
+ // src/index.ts
77
+ var VuePackages = [
78
+ "vue",
79
+ "nuxt",
80
+ "vitepress",
81
+ "@slidev/cli"
82
+ ];
83
+ function vida(options = {}, ...userConfigs) {
84
+ const {
85
+ pinia: enablePinia = (0, import_local_pkg.isPackageExists)("pinia"),
86
+ // https://github.com/antfu/eslint-config/blob/main/src/factory.ts
87
+ vue: enableVue = VuePackages.some((i) => (0, import_local_pkg.isPackageExists)(i))
88
+ } = options;
89
+ const configs = [];
90
+ if (enableVue)
91
+ configs.push(vue);
92
+ if (enablePinia)
93
+ configs.push(pinia);
94
+ const antfuConfig = {
95
+ stylistic: {
96
+ indent: 2,
97
+ quotes: "single",
98
+ semi: true
99
+ },
100
+ formatters: {
101
+ css: true,
102
+ html: true
103
+ },
104
+ jsx: false
105
+ };
106
+ return (0, import_eslint_config3.default)(
107
+ {
108
+ ...antfuConfig,
109
+ ...options
110
+ },
111
+ ...configs,
112
+ ...userConfigs
113
+ );
114
+ }
115
+ var src_default = vida;
116
+ // Annotate the CommonJS export names for ESM import in node:
117
+ 0 && (module.exports = {
118
+ vida
119
+ });
@@ -0,0 +1,16 @@
1
+ import * as eslint_flat_config_utils from 'eslint-flat-config-utils';
2
+ import { antfu, TypedFlatConfigItem } from '@antfu/eslint-config';
3
+
4
+ type AntfuOptions = Parameters<typeof antfu>[0];
5
+ type OptionsConfig = AntfuOptions & {
6
+ /**
7
+ * Enable Pinia support.
8
+ *
9
+ * @default auto-detect based on the dependencies
10
+ */
11
+ pinia?: boolean;
12
+ };
13
+
14
+ declare function vida(options?: OptionsConfig, ...userConfigs: TypedFlatConfigItem[]): eslint_flat_config_utils.FlatConfigComposer<TypedFlatConfigItem, string>;
15
+
16
+ export { vida as default, vida };
@@ -0,0 +1,16 @@
1
+ import * as eslint_flat_config_utils from 'eslint-flat-config-utils';
2
+ import { antfu, TypedFlatConfigItem } from '@antfu/eslint-config';
3
+
4
+ type AntfuOptions = Parameters<typeof antfu>[0];
5
+ type OptionsConfig = AntfuOptions & {
6
+ /**
7
+ * Enable Pinia support.
8
+ *
9
+ * @default auto-detect based on the dependencies
10
+ */
11
+ pinia?: boolean;
12
+ };
13
+
14
+ declare function vida(options?: OptionsConfig, ...userConfigs: TypedFlatConfigItem[]): eslint_flat_config_utils.FlatConfigComposer<TypedFlatConfigItem, string>;
15
+
16
+ export { vida as default, vida };
package/dist/index.js ADDED
@@ -0,0 +1,84 @@
1
+ // src/index.ts
2
+ import antfu from "@antfu/eslint-config";
3
+ import { isPackageExists } from "local-pkg";
4
+
5
+ // src/configs/pinia.ts
6
+ import { GLOB_JS, GLOB_TS } from "@antfu/eslint-config";
7
+ import pluginPinia from "eslint-plugin-pinia";
8
+ var pinia = [
9
+ {
10
+ name: "vida:pinia",
11
+ files: [GLOB_JS, GLOB_TS],
12
+ plugins: {
13
+ pinia: pluginPinia
14
+ },
15
+ rules: {
16
+ "pinia/prefer-single-store-per-file": ["error"],
17
+ "pinia/prefer-use-store-naming-convention": ["error", {
18
+ checkStoreNameMismatch: true,
19
+ storeSuffix: "Store"
20
+ }],
21
+ "pinia/require-setup-store-properties-export": ["warn"]
22
+ }
23
+ }
24
+ ];
25
+
26
+ // src/configs/vue.ts
27
+ import { GLOB_VUE } from "@antfu/eslint-config";
28
+ var vue = [
29
+ {
30
+ name: "vida:vue",
31
+ files: [GLOB_VUE],
32
+ rules: {
33
+ "vue/max-attributes-per-line": ["error", {
34
+ singleline: { max: 5 },
35
+ multiline: { max: 1 }
36
+ }]
37
+ }
38
+ }
39
+ ];
40
+
41
+ // src/index.ts
42
+ var VuePackages = [
43
+ "vue",
44
+ "nuxt",
45
+ "vitepress",
46
+ "@slidev/cli"
47
+ ];
48
+ function vida(options = {}, ...userConfigs) {
49
+ const {
50
+ pinia: enablePinia = isPackageExists("pinia"),
51
+ // https://github.com/antfu/eslint-config/blob/main/src/factory.ts
52
+ vue: enableVue = VuePackages.some((i) => isPackageExists(i))
53
+ } = options;
54
+ const configs = [];
55
+ if (enableVue)
56
+ configs.push(vue);
57
+ if (enablePinia)
58
+ configs.push(pinia);
59
+ const antfuConfig = {
60
+ stylistic: {
61
+ indent: 2,
62
+ quotes: "single",
63
+ semi: true
64
+ },
65
+ formatters: {
66
+ css: true,
67
+ html: true
68
+ },
69
+ jsx: false
70
+ };
71
+ return antfu(
72
+ {
73
+ ...antfuConfig,
74
+ ...options
75
+ },
76
+ ...configs,
77
+ ...userConfigs
78
+ );
79
+ }
80
+ var src_default = vida;
81
+ export {
82
+ src_default as default,
83
+ vida
84
+ };
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@vida0905/eslint-config",
3
+ "type": "module",
4
+ "version": "0.1.0",
5
+ "packageManager": "pnpm@8.15.6",
6
+ "description": "Vida Xie's ESLint Config",
7
+ "author": "Vida Xie <vida_2020@163.com> (https://github.com/9romise/)",
8
+ "license": "MIT",
9
+ "homepage": "https://github.com/9romise/eslint-config#readme",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/9romise/eslint-config.git"
13
+ },
14
+ "bugs": {
15
+ "url": "https://github.com/9romise/eslint-config/issues"
16
+ },
17
+ "keywords": [
18
+ "eslint-config"
19
+ ],
20
+ "exports": {
21
+ ".": {
22
+ "import": "./dist/index.js",
23
+ "require": "./dist/index.cjs"
24
+ }
25
+ },
26
+ "main": "./dits/index.js",
27
+ "types": "./dist/index.d.ts",
28
+ "files": [
29
+ "dist"
30
+ ],
31
+ "scripts": {
32
+ "lint": "eslint .",
33
+ "lint:fix": "eslint . --fix",
34
+ "dev": "npx @eslint/config-inspector",
35
+ "build": "tsup",
36
+ "release": "bumpp && pnpm publish",
37
+ "typecheck": "tsc --noEmit"
38
+ },
39
+ "peerDependencies": {
40
+ "eslint": ">=8.0.0"
41
+ },
42
+ "dependencies": {
43
+ "@antfu/eslint-config": "^2.12.1",
44
+ "eslint-plugin-pinia": "^0.1.10",
45
+ "local-pkg": "^0.5.0"
46
+ },
47
+ "devDependencies": {
48
+ "@eslint/config-inspector": "^0.3.1",
49
+ "@unocss/eslint-plugin": "0.59.0-beta.1",
50
+ "bumpp": "^9.4.0",
51
+ "eslint": "npm:eslint-ts-patch@8.57.0-0",
52
+ "eslint-plugin-format": "^0.1.0",
53
+ "eslint-ts-patch": "8.57.0-0",
54
+ "tsup": "^8.0.2",
55
+ "typescript": "^5.4.4"
56
+ }
57
+ }