@huangjunsen/stylelint-config 1.0.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.
Files changed (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +11 -0
  3. package/index.js +89 -0
  4. package/package.json +39 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 黄俊森
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,11 @@
1
+ # `stylelint-config`
2
+
3
+ > TODO: description
4
+
5
+ ## Usage
6
+
7
+ ```
8
+ const stylelintConfig = require('stylelint-config');
9
+
10
+ // TODO: DEMONSTRATE API
11
+ ```
package/index.js ADDED
@@ -0,0 +1,89 @@
1
+ module.exports = {
2
+ defaultSeverity: 'warning', // 设置所有规则的默认严重性级别。
3
+ plugins: ['stylelint-scss'], // 引入 stylelint-scss 插件,启用 SCSS 特定的规则。
4
+ extends: ['stylelint-config-standard','stylelint-config-standard-scss'], // 继承 stylelint-config-standard 配置。
5
+ rules: {
6
+ /**
7
+ * 可能的错误
8
+ * @link https://stylelint.io/user-guide/rules/#possible-errors
9
+ */
10
+ 'at-rule-no-unknown': null, // 禁用未知的 at 规则检查。
11
+ 'scss/at-rule-no-unknown': true, // 启用 SCSS 特定的未知 at 规则验证。
12
+ 'block-no-empty': null, // 禁用空块规则。
13
+ 'color-no-invalid-hex': true, // 确保十六进制颜色值有效。
14
+ 'comment-no-empty': true, // 禁止空注释。
15
+ 'declaration-block-no-duplicate-properties': [
16
+ true,
17
+ {
18
+ ignore: ['consecutive-duplicates-with-different-values'],
19
+ },
20
+ ], // 允许连续重复属性,如果它们的值不同。
21
+ 'declaration-block-no-shorthand-property-overrides': true, // 防止简写属性覆盖详细属性。
22
+ 'font-family-no-duplicate-names': true, // 确保字体族名称不重复。
23
+ 'function-calc-no-unspaced-operator': true, // 确保 calc 函数中的操作符周围有空格。
24
+ 'function-linear-gradient-no-nonstandard-direction': true, // 防止线性渐变中使用非标准方向。
25
+ 'keyframe-declaration-no-important': true, // 禁止在关键帧声明中使用 !important。
26
+ 'media-feature-name-no-unknown': true, // 禁止未知的媒体特性名称。
27
+ 'no-descending-specificity': null, // 禁用;忽略选择器优先级降序的规则。
28
+ 'no-duplicate-at-import-rules': true, // 禁止重复的 @import 规则。
29
+ 'no-duplicate-selectors': true, // 禁止选择器重复。
30
+ 'no-empty-source': null, // 允许空的源文件。
31
+ 'no-extra-semicolons': true, // 禁止多余的分号。
32
+ 'no-invalid-double-slash-comments': true, // 禁止无效的双斜杠注释(CSS 中不支持)。
33
+ 'property-no-unknown': true, // 禁止未知的属性。
34
+ 'selector-pseudo-class-no-unknown': [
35
+ true,
36
+ {
37
+ ignorePseudoClasses: ['global', 'local', 'export'],
38
+ },
39
+ ], // 允许特定的自定义伪类。
40
+ 'selector-pseudo-element-no-unknown': true, // 禁止未知的伪元素。
41
+ 'string-no-newline': true, // 禁止字符串中的换行符。
42
+ 'unit-no-unknown': [
43
+ true,
44
+ {
45
+ ignoreUnits: ['rpx'],
46
+ },
47
+ ], // 允许特定的自定义单位,如 rpx。
48
+
49
+ /**
50
+ * 风格问题
51
+ * @link https://stylelint.io/user-guide/rules/list#stylistic-issues
52
+ */
53
+ indentation: 2, // 强制使用两个空格的缩进。
54
+ 'block-closing-brace-newline-before': 'always-multi-line', // 多行块的结束括号前必须有换行。
55
+ 'block-closing-brace-space-before': 'always-single-line', // 单行块的结束括号前必须有空格。
56
+ 'block-opening-brace-newline-after': 'always-multi-line', // 多行块的开始括号后必须有换行。
57
+ 'block-opening-brace-space-before': 'always', // 开始括号前必须有空格。
58
+ 'block-opening-brace-space-after': 'always-single-line', // 单行块的开始括号后必须有空格。
59
+ // 'color-hex-case': 'lower', // 要求十六进制值使用小写。
60
+ 'color-hex-length': 'short', // 强制使用简短形式的十六进制值。
61
+ 'comment-whitespace-inside': 'always', // 注释内部必须有空白。
62
+ // 'declaration-colon-space-before': 'never', // 声明中的冒号前不能有空格。
63
+ // 'declaration-colon-space-after': 'always', // 声明中的冒号后必须有空格。
64
+ 'declaration-block-single-line-max-declarations': 1, // 单行声明块中的最大声明数为1。
65
+ 'declaration-block-trailing-semicolon': [
66
+ 'always',
67
+ {
68
+ severity: 'error',
69
+ },
70
+ ], // 声明块必须以分号结束,并将缺失分号视为错误。
71
+ 'length-zero-no-unit': [
72
+ true,
73
+ {
74
+ ignore: ['custom-properties'],
75
+ },
76
+ ], // 零长度值不得带单位,自定义属性除外。
77
+ 'max-line-length': 100, // 限制最大行长度。
78
+ 'selector-max-id': 0, // 禁止在选择器中使用 ID。
79
+ 'value-list-comma-space-after': 'always-single-line', // 单行值列表中逗号后必须有空格。
80
+
81
+ /**
82
+ * stylelint-scss 规则
83
+ * @link https://www.npmjs.com/package/stylelint-scss
84
+ */
85
+ 'scss/double-slash-comment-whitespace-inside': 'always', // SCSS 中双斜杠注释内必须有空白。
86
+ },
87
+ ignoreFiles: ['**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx'], // 指定 stylelint 忽略的文件类型。
88
+ };
89
+
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@huangjunsen/stylelint-config",
3
+ "version": "1.0.0",
4
+ "description": "CSS规范",
5
+ "keywords": [
6
+ "encode",
7
+ "style",
8
+ "lint"
9
+ ],
10
+ "author": "Huangjunsen <951434130@qq.com>",
11
+ "homepage": "https://github.com/Huang-junsen/js-encode-fe-spec#readme",
12
+ "license": "ISC",
13
+ "main": "index.js",
14
+ "directories": {
15
+ "test": "__tests__"
16
+ },
17
+ "files": [
18
+ "index.js",
19
+ "package.json",
20
+ "README.md"
21
+ ],
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "git+https://github.com/Huang-junsen/js-encode-fe-spec.git"
25
+ },
26
+ "bugs": {
27
+ "url": "https://github.com/Huang-junsen/js-encode-fe-spec/issues"
28
+ },
29
+ "devDependencies": {
30
+ "jest": "^29.5.0",
31
+ "stylelint": "15.11.0",
32
+ "stylelint-config-standard": "34.0.0",
33
+ "stylelint-config-standard-scss": "11.1.0",
34
+ "stylelint-scss": "5.3.2"
35
+ },
36
+ "scripts": {
37
+ "test": "jest"
38
+ }
39
+ }