@blueking/bkui-lint 0.0.2

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.js ADDED
@@ -0,0 +1,329 @@
1
+ /* eslint-disable @typescript-eslint/no-var-requires */
2
+ /* eslint-disable @typescript-eslint/no-require-imports */
3
+ const typescriptEslint = require('@typescript-eslint/eslint-plugin');
4
+ const eslintConfigPrettier = require('eslint-config-prettier');
5
+ const prettier = require('eslint-plugin-prettier');
6
+ const typescriptEslintParser = require('@typescript-eslint/parser');
7
+ const codecc = require('eslint-plugin-codecc');
8
+ const eslintVueParser = require('vue-eslint-parser');
9
+ const perfectionist = require('eslint-plugin-perfectionist');
10
+ const eslintVuePlugin = require('eslint-plugin-vue');
11
+ const { rules: tencentEslintLegacyRules } = require('eslint-config-tencent/ts');
12
+ const prettierConfig = require('./prettier');
13
+ // deprecating formatting rules https://typescript-eslint.io/blog/deprecating-formatting-rules
14
+ const deprecateRules = Object.fromEntries(
15
+ [
16
+ 'ban-ts-comment',
17
+ 'block-spacing',
18
+ 'brace-style',
19
+ 'comma-dangle',
20
+ 'comma-spacing',
21
+ 'func-call-spacing',
22
+ 'indent',
23
+ 'key-spacing',
24
+ 'keyword-spacing',
25
+ 'lines-around-comment',
26
+ 'lines-between-class-members',
27
+ 'member-delimiter-style',
28
+ 'no-extra-parens',
29
+ 'no-extra-semi',
30
+ 'padding-line-between-statements',
31
+ 'quotes',
32
+ 'semi',
33
+ 'space-before-blocks',
34
+ 'space-before-function-paren',
35
+ 'space-infix-ops',
36
+ 'type-annotation-spacing',
37
+ ].map(rule => [`@typescript-eslint/${rule}`, 'off']),
38
+ );
39
+ const jsxOrVueSortGroups = {
40
+ 'custom-groups': {
41
+ DEFINITION: '*(is|vIs|v-is)',
42
+ LIST_RENDERING: '*(v-for|vFor)',
43
+ CONDITIONALS: '*(v-if|v-else-if|v-else|vIf|vElseIf|vElse)',
44
+ RENDER_MODIFIERS: '*(v-pre|v-once|vPre|vOnce)',
45
+ GLOBAL: 'id',
46
+ UNIQUE: '*(ref|key)',
47
+ WIDTH: 'width',
48
+ HEIGHT: 'height',
49
+ STYLE: '*style',
50
+ CLASS: '*(class|ext-cls|extCls)',
51
+ TWO_WAY_BINDING: '*(v-model|vModel)',
52
+ SLOT: '*(v-slot|slot|vSlot)',
53
+ OTHER_DIRECTIVES: 'v-*',
54
+ EVENTS: '*(on*|v-on|vOn|@*)',
55
+ CONTENT: '*(v-html|v-text|vHtml|vText)',
56
+ },
57
+ groups: [
58
+ 'DEFINITION',
59
+ 'LIST_RENDERING',
60
+ 'CONDITIONALS',
61
+ 'RENDER_MODIFIERS',
62
+ 'GLOBAL',
63
+ 'UNIQUE',
64
+ 'STYLE',
65
+ 'WIDTH',
66
+ 'HEIGHT',
67
+ 'CLASS',
68
+ 'TWO_WAY_BINDING',
69
+ 'SLOT',
70
+ 'OTHER_DIRECTIVES',
71
+ 'multiline',
72
+ 'unknown',
73
+ 'shorthand',
74
+ 'EVENTS',
75
+ ],
76
+ };
77
+ module.exports = [
78
+ {
79
+ files: ['*.js', '**/*.js', '*.ts', '**/*.ts'],
80
+ ignores: ['*.tsx', '**/*.tsx', '*.vue', '**/*.vue'],
81
+ plugins: { perfectionist },
82
+ rules: {
83
+ 'perfectionist/sort-classes': [
84
+ 'error',
85
+ {
86
+ groups: [
87
+ 'decorated-accessor-property',
88
+ 'static-private-method',
89
+ 'private-property',
90
+ 'static-property',
91
+ 'index-signature',
92
+ 'private-method',
93
+ 'static-method',
94
+ 'property',
95
+ 'private-decorated-accessor-property',
96
+ 'private-decorated-property',
97
+ 'decorated-property',
98
+ 'constructor',
99
+ ['get-method', 'set-method'],
100
+ 'decorated-set-method',
101
+ 'decorated-get-method',
102
+ 'decorated-method',
103
+ 'unknown',
104
+ 'method',
105
+ ],
106
+ order: 'asc',
107
+ type: 'natural',
108
+ },
109
+ ],
110
+ // 'perfectionist/sort-objects': [
111
+ // 'error',
112
+ // {
113
+ // 'custom-groups': {
114
+ // ID: '*(id|ID|Id)',
115
+ // NAME: '*(name|Name|NAME)',
116
+ // path: 'path',
117
+ // // components: 'components',
118
+ // // directives: 'directives',
119
+ // // emits: 'emits',
120
+ // // props: 'props',
121
+ // // setup: 'setup',
122
+ // // render: 'render',
123
+ // },
124
+ // groups: ['ID', 'NAME', 'path', 'unknown'],
125
+ // order: 'asc',
126
+ // 'partition-by-comment': 'Part:**',
127
+ // type: 'natural',
128
+ // },
129
+ // ],
130
+ },
131
+ },
132
+ {
133
+ plugins: { perfectionist },
134
+ rules: {
135
+ 'perfectionist/sort-enums': [
136
+ 'error',
137
+ {
138
+ order: 'asc',
139
+ type: 'natural',
140
+ },
141
+ ],
142
+ 'perfectionist/sort-exports': [
143
+ 'error',
144
+ {
145
+ order: 'asc',
146
+ type: 'natural',
147
+ },
148
+ ],
149
+ 'perfectionist/sort-imports': [
150
+ 'error',
151
+ {
152
+ 'custom-groups': {
153
+ type: {
154
+ magicBox: 'magicBox',
155
+ top: 'top',
156
+ tsxSupport: 'tsxSupport',
157
+ vueI18n: 'vueI18n',
158
+ },
159
+ value: {
160
+ magicBox: ['./common/import-magicbox-ui', 'monitor-ui/directive/index', 'monitor-static/svg-icons'],
161
+ top: ['./public-path', './public-path.ts', 'monitor-common/polyfill'],
162
+ tsxSupport: ['vue-property-decorator', 'vue-tsx-support'],
163
+ vueI18n: ['./i18n/i18n', 'vue', 'vue-*'],
164
+ },
165
+ },
166
+ groups: [
167
+ 'top',
168
+ 'vueI18n',
169
+ 'magicBox',
170
+ 'tsxSupport',
171
+ ['builtin', 'external'],
172
+ ['internal', 'sibling', 'parent', 'side-effect', 'index', 'object'],
173
+ 'unknown',
174
+ ['type', 'builtin-type', 'external-type', 'internal-type', 'parent-type', 'sibling-type', 'index-type'],
175
+ ['style', 'side-effect-style'],
176
+ ],
177
+ 'internal-pattern': ['@/*', '@router/*', '@store/*', '@page/*', '@static/*'],
178
+ 'newlines-between': 'always',
179
+ order: 'asc',
180
+ type: 'natural',
181
+ },
182
+ ],
183
+ 'perfectionist/sort-jsx-props': [
184
+ 'error',
185
+ {
186
+ ...jsxOrVueSortGroups,
187
+ order: 'asc',
188
+ type: 'natural',
189
+ },
190
+ ],
191
+ 'perfectionist/sort-maps': [
192
+ 'error',
193
+ {
194
+ order: 'asc',
195
+ type: 'natural',
196
+ },
197
+ ],
198
+ // 'perfectionist/sort-intersection-types': [
199
+ // 'error',
200
+ // {
201
+ // type: 'natural',
202
+ // order: 'asc',
203
+ // },
204
+ // ],
205
+ 'perfectionist/sort-union-types': [
206
+ 'error',
207
+ {
208
+ order: 'asc',
209
+ type: 'natural',
210
+ },
211
+ ],
212
+ 'perfectionist/sort-vue-attributes': [
213
+ 'error',
214
+ {
215
+ ...jsxOrVueSortGroups,
216
+ type: 'natural',
217
+ order: 'asc',
218
+ },
219
+ ],
220
+ },
221
+ },
222
+ {
223
+ plugins: { prettier },
224
+ rules: {
225
+ ...prettier.configs.recommended.rules,
226
+ 'prettier/prettier': [
227
+ 'error',
228
+ {
229
+ ...prettierConfig,
230
+ },
231
+ ],
232
+ },
233
+ },
234
+ {
235
+ files: ['*.js', '**/*.js', '*.ts', '**/*.ts', '*.tsx', '**/*.tsx'],
236
+ ignores: [],
237
+ languageOptions: {
238
+ parser: typescriptEslintParser,
239
+ parserOptions: {
240
+ ecmaVersion: 'latest',
241
+ project: true,
242
+ },
243
+ },
244
+ plugins: {
245
+ '@typescript-eslint': typescriptEslint,
246
+ codecc,
247
+ },
248
+ rules: {
249
+ 'codecc/license': [
250
+ 'error',
251
+ {
252
+ license: `/*
253
+ * Tencent is pleased to support the open source community by making
254
+ * 蓝鲸智云PaaS平台 (BlueKing PaaS) available.
255
+ *
256
+ * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
257
+ *
258
+ * 蓝鲸智云PaaS平台 (BlueKing PaaS) is licensed under the MIT License.
259
+ *
260
+ * License for 蓝鲸智云PaaS平台 (BlueKing PaaS):
261
+ *
262
+ * ---------------------------------------------------
263
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
264
+ * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
265
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
266
+ * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
267
+ *
268
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of
269
+ * the Software.
270
+ *
271
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
272
+ * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
273
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
274
+ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
275
+ * IN THE SOFTWARE.
276
+ */\n`,
277
+ pattern: '.*Tencent is pleased to support the open source community.+',
278
+ },
279
+ ],
280
+ ...typescriptEslint.configs.recommended.rules,
281
+ ...tencentEslintLegacyRules,
282
+ ...deprecateRules,
283
+ },
284
+ },
285
+ ...eslintVuePlugin.configs['flat/recommended'].map(config =>
286
+ config.files
287
+ ? {
288
+ ...config,
289
+ files: ['*.vue', '**/*.vue'],
290
+ languageOptions: {
291
+ ...config.languageOptions,
292
+ parser: eslintVueParser,
293
+ parserOptions: {
294
+ ...config.languageOptions.parserOptions,
295
+ allowAutomaticSingleRunInference: false,
296
+ ecmaFeatures: { jsx: true, legacyDecorators: true },
297
+ ecmaVersion: 'latest',
298
+ extraFileExtensions: ['.vue'],
299
+ parser: typescriptEslintParser,
300
+ project: true,
301
+ tsconfigRootDir: process.cwd(),
302
+ },
303
+ },
304
+ plugins: {
305
+ '@typescript-eslint': typescriptEslint,
306
+ vue: eslintVuePlugin,
307
+ },
308
+ rules: {
309
+ ...config.rules,
310
+ ...tencentEslintLegacyRules,
311
+ '@typescript-eslint/explicit-member-accessibility': 'off',
312
+ 'comma-dangle': ['error', 'always-multiline'],
313
+ ...deprecateRules,
314
+ },
315
+ }
316
+ : config,
317
+ ),
318
+ {
319
+ rules: {
320
+ 'vue/html-self-closing': 'off',
321
+ 'vue/require-default-prop': 'off',
322
+ 'vue/attributes-order': 'off',
323
+ },
324
+ },
325
+ eslintConfigPrettier,
326
+ {
327
+ ignores: ['node_modules'],
328
+ },
329
+ ];
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@blueking/bkui-lint",
3
+ "version": "0.0.2",
4
+ "description": "蓝鲸监控平台公共lint工具",
5
+ "license": "MIT",
6
+ "author": "Tencent BlueKing",
7
+ "module": "index.js",
8
+ "files": [
9
+ "eslint.js",
10
+ "prettier.js",
11
+ "stylelint.js"
12
+ ],
13
+ "publishConfig": {
14
+ "access": "public",
15
+ "registry": "https://registry.npmjs.org/"
16
+ },
17
+ "dependencies": {
18
+ "@typescript-eslint/eslint-plugin": "^7.8.0",
19
+ "@typescript-eslint/parser": "^7.8.0",
20
+ "eslint": "^9.2.0",
21
+ "eslint-config-prettier": "^9.1.0",
22
+ "eslint-config-tencent": "^1.0.4",
23
+ "eslint-plugin-codecc": "^1.0.0-beta.1",
24
+ "eslint-plugin-perfectionist": "^2.10.0",
25
+ "eslint-plugin-prettier": "^5.1.3",
26
+ "eslint-plugin-vue": "^9.26.0",
27
+ "postcss-html": "^1.7.0",
28
+ "postcss-less": "^6.0.0",
29
+ "postcss-scss": "^4.0.9",
30
+ "prettier": "^3.2.5",
31
+ "stylelint": "^16.5.0",
32
+ "stylelint-config-recess-order": "^5.0.1",
33
+ "stylelint-config-recommended-vue": "^1.5.0",
34
+ "stylelint-config-standard": "^36.0.0",
35
+ "stylelint-order": "^6.0.4",
36
+ "stylelint-scss": "^6.3.0",
37
+ "vue-eslint-parser": "^9.4.2"
38
+ },
39
+ "scripts": {}
40
+ }
package/prettier.js ADDED
@@ -0,0 +1,40 @@
1
+ /*
2
+ * Tencent is pleased to support the open source community by making
3
+ * 蓝鲸智云PaaS平台 (BlueKing PaaS) available.
4
+ *
5
+ * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
6
+ *
7
+ * 蓝鲸智云PaaS平台 (BlueKing PaaS) is licensed under the MIT License.
8
+ *
9
+ * License for 蓝鲸智云PaaS平台 (BlueKing PaaS):
10
+ *
11
+ * ---------------------------------------------------
12
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
13
+ * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
14
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
15
+ * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
16
+ *
17
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of
18
+ * the Software.
19
+ *
20
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
21
+ * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
23
+ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24
+ * IN THE SOFTWARE.
25
+ */
26
+ module.exports = {
27
+ arrowParens: 'avoid',
28
+ bracketSameLine: false,
29
+ jsxSingleQuote: true,
30
+ printWidth: 120,
31
+ quoteProps: 'as-needed',
32
+ semi: true,
33
+ singleAttributePerLine: true,
34
+ singleQuote: true,
35
+ tabWidth: 2,
36
+ trailingComma: 'all',
37
+ useTabs: false,
38
+ vueIndentScriptAndStyle: true,
39
+ jsxBracketSameLine: false,
40
+ };
package/stylelint.js ADDED
@@ -0,0 +1,74 @@
1
+ /*
2
+ * Tencent is pleased to support the open source community by making
3
+ * 蓝鲸智云PaaS平台 (BlueKing PaaS) available.
4
+ *
5
+ * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
6
+ *
7
+ * 蓝鲸智云PaaS平台 (BlueKing PaaS) is licensed under the MIT License.
8
+ *
9
+ * License for 蓝鲸智云PaaS平台 (BlueKing PaaS):
10
+ *
11
+ * ---------------------------------------------------
12
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
13
+ * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
14
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
15
+ * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
16
+ *
17
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of
18
+ * the Software.
19
+ *
20
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
21
+ * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
23
+ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24
+ * IN THE SOFTWARE.
25
+ */
26
+ module.exports = {
27
+ extends: ['stylelint-config-recommended-vue', 'stylelint-config-recess-order'],
28
+ overrides: [
29
+ {
30
+ customSyntax: 'postcss-scss',
31
+ files: ['*.scss', '*.css', '**/*.scss', '**/*.css'],
32
+ },
33
+ {
34
+ customSyntax: 'postcss-html',
35
+ files: ['*.vue', './**/*.vue'],
36
+ },
37
+ {
38
+ customSyntax: 'postcss-less',
39
+ files: ['*.less', './**/*.less'],
40
+ },
41
+ ],
42
+ plugins: ['stylelint-scss', 'stylelint-order'],
43
+ rules: {
44
+ 'at-rule-no-unknown': [
45
+ true,
46
+ {
47
+ ignoreAtRules: ['/.*/'],
48
+ },
49
+ ],
50
+ 'at-rule-no-vendor-prefix': true,
51
+ 'comment-empty-line-before': ['always', { except: ['first-nested'] }],
52
+ // 不能用important
53
+ 'declaration-no-important': true,
54
+ // Sass rules
55
+ 'max-nesting-depth': 10,
56
+ // 不要使用已被 autoprefixer 支持的浏览器前缀
57
+ 'media-feature-name-no-vendor-prefix': true,
58
+ 'order/order': ['declarations', { type: 'at-rule' }, { hasBlock: true, type: 'at-rule' }, 'rules'],
59
+ 'property-no-vendor-prefix': true,
60
+ // 去掉多个import、extends、父子声明之间的空行 --开始
61
+ 'rule-empty-line-before': [
62
+ 'always',
63
+ {
64
+ except: ['first-nested'],
65
+ ignore: ['after-comment'],
66
+ },
67
+ ],
68
+ 'scss/at-extend-no-missing-placeholder': true,
69
+ 'scss/dollar-variable-pattern': '^_?[a-z]+[\\w-]*$',
70
+ 'selector-max-id': 3,
71
+ 'selector-no-vendor-prefix': true,
72
+ 'value-no-vendor-prefix': true,
73
+ },
74
+ };