@leexi/shared 0.0.1
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/eslint/base.js +120 -0
- package/eslint/index.js +2 -0
- package/eslint/vue.js +45 -0
- package/package.json +33 -0
- package/utils/index.js +1 -0
- package/utils/objects/deepDup.js +20 -0
package/eslint/base.js
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import js from '@eslint/js';
|
|
2
|
+
import stylisticJS from '@stylistic/eslint-plugin-js';
|
|
3
|
+
import stylisticTS from '@stylistic/eslint-plugin-ts';
|
|
4
|
+
import tailwind from 'eslint-plugin-tailwindcss';
|
|
5
|
+
import globals from 'globals';
|
|
6
|
+
import tseslint from 'typescript-eslint';
|
|
7
|
+
|
|
8
|
+
export default [
|
|
9
|
+
js.configs.recommended,
|
|
10
|
+
...tseslint.configs.recommended,
|
|
11
|
+
...tailwind.configs['flat/recommended'],
|
|
12
|
+
|
|
13
|
+
// base config
|
|
14
|
+
{
|
|
15
|
+
languageOptions: {
|
|
16
|
+
globals: {
|
|
17
|
+
...globals.browser,
|
|
18
|
+
...globals.node,
|
|
19
|
+
},
|
|
20
|
+
parserOptions: {
|
|
21
|
+
ecmaVersion: 'latest',
|
|
22
|
+
sourceType: 'module',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
plugins: {
|
|
26
|
+
'@stylistic/js': stylisticJS,
|
|
27
|
+
},
|
|
28
|
+
rules: {
|
|
29
|
+
'arrow-body-style': ['error', 'as-needed'],
|
|
30
|
+
'eqeqeq': ['error', 'smart'],
|
|
31
|
+
'no-console': 'error',
|
|
32
|
+
'no-unused-vars': ['error', {
|
|
33
|
+
argsIgnorePattern: '^_',
|
|
34
|
+
destructuredArrayIgnorePattern: '^_',
|
|
35
|
+
ignoreRestSiblings: true,
|
|
36
|
+
}],
|
|
37
|
+
'prefer-const': ['error', {
|
|
38
|
+
destructuring: 'all',
|
|
39
|
+
}],
|
|
40
|
+
'prefer-template': 'error',
|
|
41
|
+
|
|
42
|
+
'tailwindcss/no-custom-classname': 'error',
|
|
43
|
+
|
|
44
|
+
'@stylistic/js/array-bracket-spacing': ['error', 'never'],
|
|
45
|
+
'@stylistic/js/comma-dangle': ['error', 'always-multiline'],
|
|
46
|
+
'@stylistic/js/comma-spacing': 'error',
|
|
47
|
+
'@stylistic/js/eol-last': ['error', 'always'],
|
|
48
|
+
'@stylistic/js/indent': ['error', 2, {
|
|
49
|
+
SwitchCase: 1,
|
|
50
|
+
}],
|
|
51
|
+
'@stylistic/js/key-spacing': 'error',
|
|
52
|
+
'@stylistic/js/keyword-spacing': 'error',
|
|
53
|
+
'@stylistic/js/no-multi-spaces': 'error',
|
|
54
|
+
'@stylistic/js/no-multiple-empty-lines': ['error', {
|
|
55
|
+
max: 1,
|
|
56
|
+
}],
|
|
57
|
+
'@stylistic/js/no-trailing-spaces': 'error',
|
|
58
|
+
'@stylistic/js/object-curly-spacing': ['error', 'always'],
|
|
59
|
+
'@stylistic/js/quotes': ['error', 'single'],
|
|
60
|
+
'@stylistic/js/quote-props': ['error', 'consistent-as-needed'],
|
|
61
|
+
'@stylistic/js/semi': ['error', 'always'],
|
|
62
|
+
'@stylistic/js/semi-spacing': 'error',
|
|
63
|
+
'@stylistic/js/space-before-blocks': ['error', 'always'],
|
|
64
|
+
'@stylistic/js/space-before-function-paren': ['error', 'always'],
|
|
65
|
+
'@stylistic/js/space-in-parens': ['error', 'never'],
|
|
66
|
+
'@stylistic/js/space-infix-ops': 'error',
|
|
67
|
+
'@stylistic/js/spaced-comment': 'error',
|
|
68
|
+
'@stylistic/js/template-curly-spacing': ['error', 'never'],
|
|
69
|
+
|
|
70
|
+
'@typescript-eslint/no-unused-vars': ['error', {
|
|
71
|
+
argsIgnorePattern: '^_',
|
|
72
|
+
destructuredArrayIgnorePattern: '^_',
|
|
73
|
+
ignoreRestSiblings: true,
|
|
74
|
+
}],
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
// typescript
|
|
79
|
+
{
|
|
80
|
+
files: ['**/*.ts'],
|
|
81
|
+
plugins: {
|
|
82
|
+
'@stylistic/ts': stylisticTS,
|
|
83
|
+
},
|
|
84
|
+
rules: {
|
|
85
|
+
'@stylistic/js/comma-dangle': 'off',
|
|
86
|
+
'@stylistic/js/comma-spacing': 'off',
|
|
87
|
+
'@stylistic/js/indent': 'off',
|
|
88
|
+
'@stylistic/js/key-spacing': 'off',
|
|
89
|
+
'@stylistic/js/keyword-spacing': 'off',
|
|
90
|
+
'@stylistic/js/object-curly-spacing': 'off',
|
|
91
|
+
'@stylistic/js/quotes': 'off',
|
|
92
|
+
'@stylistic/js/quote-props': 'off',
|
|
93
|
+
'@stylistic/js/semi': 'off',
|
|
94
|
+
'@stylistic/js/space-before-blocks': 'off',
|
|
95
|
+
'@stylistic/js/space-before-function-paren': 'off',
|
|
96
|
+
'@stylistic/js/space-infix-ops': 'off',
|
|
97
|
+
|
|
98
|
+
'@stylistic/ts/comma-dangle': ['error', 'always-multiline'],
|
|
99
|
+
'@stylistic/ts/comma-spacing': 'error',
|
|
100
|
+
'@stylistic/ts/indent': ['error', 2, {
|
|
101
|
+
SwitchCase: 1,
|
|
102
|
+
}],
|
|
103
|
+
'@stylistic/ts/key-spacing': 'error',
|
|
104
|
+
'@stylistic/ts/keyword-spacing': 'error',
|
|
105
|
+
'@stylistic/ts/object-curly-spacing': ['error', 'always'],
|
|
106
|
+
'@stylistic/ts/quotes': ['error', 'single'],
|
|
107
|
+
'@stylistic/ts/quote-props': ['error', 'consistent-as-needed'],
|
|
108
|
+
'@stylistic/ts/semi': ['error', 'always'],
|
|
109
|
+
'@stylistic/ts/space-before-blocks': ['error', 'always'],
|
|
110
|
+
'@stylistic/ts/space-before-function-paren': ['error', 'always'],
|
|
111
|
+
'@stylistic/ts/space-infix-ops': 'error',
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
|
|
115
|
+
{
|
|
116
|
+
ignores: [
|
|
117
|
+
'node_modules/',
|
|
118
|
+
],
|
|
119
|
+
},
|
|
120
|
+
];
|
package/eslint/index.js
ADDED
package/eslint/vue.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
|
|
2
|
+
import vue from 'eslint-plugin-vue';
|
|
3
|
+
import base from './base.js';
|
|
4
|
+
|
|
5
|
+
export default [
|
|
6
|
+
...base,
|
|
7
|
+
...vue.configs['flat/recommended'],
|
|
8
|
+
|
|
9
|
+
{
|
|
10
|
+
files: ['**/*.vue'],
|
|
11
|
+
rules: {
|
|
12
|
+
'@stylistic/js/indent': 'off',
|
|
13
|
+
'@stylistic/js/object-curly-spacing': 'off',
|
|
14
|
+
|
|
15
|
+
'vue/attributes-order': ['error', {
|
|
16
|
+
alphabetical: true,
|
|
17
|
+
}],
|
|
18
|
+
'vue/component-name-in-template-casing': ['error', 'PascalCase', {
|
|
19
|
+
registeredComponentsOnly: false,
|
|
20
|
+
}],
|
|
21
|
+
'vue/first-attribute-linebreak': ['error', {
|
|
22
|
+
singleline: 'beside',
|
|
23
|
+
}],
|
|
24
|
+
'vue/multi-word-component-names': 'off',
|
|
25
|
+
'vue/no-bare-strings-in-template': ['error', {
|
|
26
|
+
allowlist: ['Leexi'],
|
|
27
|
+
}],
|
|
28
|
+
'vue/object-curly-spacing': ['error', 'always'],
|
|
29
|
+
'vue/prefer-template': 'error',
|
|
30
|
+
'vue/script-indent': ['error', 2, {
|
|
31
|
+
baseIndent: 1,
|
|
32
|
+
switchCase: 1,
|
|
33
|
+
}],
|
|
34
|
+
'vue/template-curly-spacing': ['error', 'never'],
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
{
|
|
39
|
+
ignores: [
|
|
40
|
+
'.nuxt/',
|
|
41
|
+
'.output/',
|
|
42
|
+
'dist/',
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
];
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@leexi/shared",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"lint": "eslint .",
|
|
7
|
+
"test": "vitest run"
|
|
8
|
+
},
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"@stylistic/eslint-plugin-js": "^4.0.1",
|
|
11
|
+
"@stylistic/eslint-plugin-ts": "^4.0.1",
|
|
12
|
+
"@types/eslint-plugin-tailwindcss": "^3.17.0",
|
|
13
|
+
"eslint-plugin-tailwindcss": "^3.18.0",
|
|
14
|
+
"eslint-plugin-vue": "^9.32.0",
|
|
15
|
+
"globals": "^16.0.0",
|
|
16
|
+
"typescript-eslint": "^8.24.1"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"eslint": "^9.21.0",
|
|
20
|
+
"happy-dom": "^17.1.3",
|
|
21
|
+
"tailwindcss": "<4.0.0",
|
|
22
|
+
"typescript": "^5.7.3",
|
|
23
|
+
"vitest": "^3.0.6"
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"eslint": ">9.0.0"
|
|
27
|
+
},
|
|
28
|
+
"exports": {
|
|
29
|
+
"./eslint": "./eslint/index.js",
|
|
30
|
+
"./utils": "./utils/index.js"
|
|
31
|
+
},
|
|
32
|
+
"files": ["eslint", "utils"]
|
|
33
|
+
}
|
package/utils/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { deepDup } from './objects/deepDup.js';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const deepDup = object => {
|
|
2
|
+
if (!object || typeof object !== 'object') { return object; }
|
|
3
|
+
|
|
4
|
+
const duplicate = value => typeof value === 'object' ? deepDup(value) : value;
|
|
5
|
+
|
|
6
|
+
if (Array.isArray(object)) {
|
|
7
|
+
return object.map(duplicate);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
if (object instanceof Set) {
|
|
11
|
+
return new Set([...object].map(duplicate));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (Object.getPrototypeOf(object) === Object.prototype) {
|
|
15
|
+
const dup = Object.entries(object).map(([key, value]) => [key, duplicate(value)]);
|
|
16
|
+
return Object.fromEntries(dup);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return object;
|
|
20
|
+
};
|