format-demo-stylelint-config 1.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/README.md +22 -0
- package/__tests__/fixtures/css-module.scss +47 -0
- package/__tests__/fixtures/essential.css +58 -0
- package/__tests__/fixtures/index.css +33 -0
- package/__tests__/fixtures/less-test.less +25 -0
- package/__tests__/fixtures/sass-test.scss +12 -0
- package/__tests__/rules-validate.test.js +85 -0
- package/index.js +87 -0
- package/package.json +34 -0
package/README.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# format-demo-markdownlint-config
|
|
2
|
+
|
|
3
|
+
支持配套的 [stylelint 可共享配置](https://stylelint.io/user-guide/configure)。
|
|
4
|
+
|
|
5
|
+
## 安装
|
|
6
|
+
|
|
7
|
+
需要先行安装 [stylelint](https://www.npmjs.com/package/stylelint) �?[stylelint-scss](https://www.npmjs.com/package/stylelint-scss):
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install format-demo-stylelint-config stylelint stylelint-scss --save-dev
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## 使用
|
|
14
|
+
|
|
15
|
+
在 `.stylelintrc` 中继承本包:
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
{
|
|
19
|
+
"extends": "format-demo-stylelint-config"
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
.commits {
|
|
2
|
+
padding: 0;
|
|
3
|
+
|
|
4
|
+
:global(.ant-timeline-item-content) {
|
|
5
|
+
overflow: hidden;
|
|
6
|
+
text-overflow: ellipsis;
|
|
7
|
+
white-space: nowrap;
|
|
8
|
+
color: #fff1aa;
|
|
9
|
+
|
|
10
|
+
&>span {
|
|
11
|
+
margin-right: 20px;
|
|
12
|
+
white-space: nowrap;
|
|
13
|
+
user-select: none;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
:global(.tree-node-yellow) {
|
|
19
|
+
:global(.ant-tree-node-content-wrapper) {
|
|
20
|
+
color: var(--color-yellow) !important;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
:global(.ant-tree-treenode-switcher-close), :global(.tree-node-file) {
|
|
25
|
+
display: flex;
|
|
26
|
+
overflow: hidden;
|
|
27
|
+
|
|
28
|
+
:global(.ant-tree-switcher) {
|
|
29
|
+
flex-shrink: 0;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
:global(.ant-tree-node-content-wrapper) {
|
|
33
|
+
flex-shrink: 1;
|
|
34
|
+
display: inline-flex !important;
|
|
35
|
+
overflow: hidden;
|
|
36
|
+
|
|
37
|
+
:global(.ant-tree-iconEle) {
|
|
38
|
+
flex-shrink: 0;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
:global(.ant-tree-title) {
|
|
42
|
+
flex-shrink: 1;
|
|
43
|
+
overflow: hidden;
|
|
44
|
+
text-overflow: ellipsis;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
@charset "UTF-8";
|
|
2
|
+
@unknown {}
|
|
3
|
+
|
|
4
|
+
.a {
|
|
5
|
+
color: #fff1az;
|
|
6
|
+
|
|
7
|
+
/**/
|
|
8
|
+
|
|
9
|
+
font-weight: 400;
|
|
10
|
+
color: #fff;
|
|
11
|
+
|
|
12
|
+
padding-left: 10px;
|
|
13
|
+
padding: 20px;
|
|
14
|
+
|
|
15
|
+
font-family: 'Times', Times, serif;
|
|
16
|
+
|
|
17
|
+
font-family: Helvetica, Arial, Verdana, Tahoma;
|
|
18
|
+
|
|
19
|
+
top: calc(1px +2px);
|
|
20
|
+
|
|
21
|
+
background: linear-gradient(bottom, #fff, #000);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@keyframes important1 {
|
|
25
|
+
from {
|
|
26
|
+
margin-top: 50px;
|
|
27
|
+
}
|
|
28
|
+
to {
|
|
29
|
+
margin-top: 100px !important;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@media screen and (unknown) {
|
|
34
|
+
.a {
|
|
35
|
+
color: #fff;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@import 'a.css';
|
|
40
|
+
@import 'a.css';
|
|
41
|
+
|
|
42
|
+
.a {
|
|
43
|
+
background: #000;;
|
|
44
|
+
colr: blue;
|
|
45
|
+
}
|
|
46
|
+
// css注释
|
|
47
|
+
.b:unknown {
|
|
48
|
+
background: #000;
|
|
49
|
+
}
|
|
50
|
+
.b::unknown {
|
|
51
|
+
background: #000;
|
|
52
|
+
}
|
|
53
|
+
unknown {
|
|
54
|
+
content: "first
|
|
55
|
+
second";
|
|
56
|
+
width: 10pixels;
|
|
57
|
+
background: #000
|
|
58
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
.foo {
|
|
2
|
+
color: #abc;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.selector{padding-left: 15px;}
|
|
6
|
+
|
|
7
|
+
.selector1 {
|
|
8
|
+
padding-left :15px;
|
|
9
|
+
|
|
10
|
+
background-size: 0,0;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.selector2 {padding-left: 15px;
|
|
14
|
+
}
|
|
15
|
+
.selector3 {
|
|
16
|
+
padding-left: 15px;}
|
|
17
|
+
|
|
18
|
+
.selector4 { color: pink; top: 3px; }
|
|
19
|
+
|
|
20
|
+
.selector5 {
|
|
21
|
+
width: 0rem;
|
|
22
|
+
|
|
23
|
+
color: #AAA;
|
|
24
|
+
background: #aaaaaa;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
#foo {
|
|
28
|
+
color: #ccc;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/*comment */
|
|
32
|
+
|
|
33
|
+
@unkown colorTag(#abc);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
@nice-bg: #abc;
|
|
2
|
+
|
|
3
|
+
.normal {
|
|
4
|
+
background: @nice-bg;
|
|
5
|
+
|
|
6
|
+
.nest {
|
|
7
|
+
font-size: 60px
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.my-hover-mixin() {
|
|
12
|
+
&:hover {
|
|
13
|
+
border: 1px solid red;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
.btn {
|
|
17
|
+
.my-hover-mixin();
|
|
18
|
+
width: $default-width /2;
|
|
19
|
+
:global(.ant-table) {
|
|
20
|
+
font-size: 10px;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
.extProp:extend(.btn) {
|
|
24
|
+
background-color:yellowgreen;
|
|
25
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
const assert = require('assert');
|
|
2
|
+
const stylelint = require('stylelint');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
|
|
5
|
+
describe('test/rules-validate.test.js', () => {
|
|
6
|
+
// 每一个it就是一个jest的小单元
|
|
7
|
+
// 验证默认值的选项
|
|
8
|
+
it('Validate default', async () => {
|
|
9
|
+
const filePaths = [path.join(__dirname, './fixtures/index.css')];
|
|
10
|
+
const result = await stylelint.lint({
|
|
11
|
+
configFile: path.join(__dirname, '../index.js'), // 配置stylelint规则的的路径
|
|
12
|
+
files: filePaths, // 需要校验的文件路径
|
|
13
|
+
fix: false, // 是否自动修复,默认为false
|
|
14
|
+
});
|
|
15
|
+
if (result && result.errored) {
|
|
16
|
+
const filesResult = JSON.parse(result.output || '[]') || [];
|
|
17
|
+
filesResult.forEach((fileResult) => {
|
|
18
|
+
console.log(`========= ${filePaths} ==========`);
|
|
19
|
+
console.log(fileResult.warnings);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
assert.ok(filesResult.length !== 0);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('Validate sass', async () => {
|
|
27
|
+
const filePaths = [path.join(__dirname, './fixtures/sass-test.scss')];
|
|
28
|
+
|
|
29
|
+
const result = await stylelint.lint({
|
|
30
|
+
configFile: path.join(__dirname, '../index.js'),
|
|
31
|
+
files: filePaths,
|
|
32
|
+
fix: false,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
if (result && result.errored) {
|
|
36
|
+
const filesResult = JSON.parse(result.output || '[]') || [];
|
|
37
|
+
filesResult.forEach((fileResult) => {
|
|
38
|
+
console.log(`========= ${filePaths} ==========`);
|
|
39
|
+
console.log(fileResult.warnings);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
assert.ok(filesResult.length !== 0);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('Validate less', async () => {
|
|
47
|
+
const filePaths = [path.join(__dirname, './fixtures/less-test.less')];
|
|
48
|
+
|
|
49
|
+
const result = await stylelint.lint({
|
|
50
|
+
configFile: path.join(__dirname, '../index.js'),
|
|
51
|
+
files: filePaths,
|
|
52
|
+
fix: false,
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
if (result && result.errored) {
|
|
56
|
+
const filesResult = JSON.parse(result.output || '[]') || [];
|
|
57
|
+
filesResult.forEach((fileResult) => {
|
|
58
|
+
console.log(`========= ${filePaths} ==========`);
|
|
59
|
+
console.log(fileResult.warnings);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
assert.ok(filesResult.length !== 0);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('Validate css-module', async () => {
|
|
67
|
+
const filePaths = [path.join(__dirname, './fixtures/css-module.scss')];
|
|
68
|
+
|
|
69
|
+
const result = await stylelint.lint({
|
|
70
|
+
configFile: path.join(__dirname, '../index.js'),
|
|
71
|
+
files: filePaths,
|
|
72
|
+
fix: false,
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
if (result && result.errored) {
|
|
76
|
+
const filesResult = JSON.parse(result.output || '[]') || [];
|
|
77
|
+
filesResult.forEach((fileResult) => {
|
|
78
|
+
console.log(`========= ${filePaths} ==========`);
|
|
79
|
+
console.log(fileResult.warnings);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
assert.ok(filesResult.length === 0);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
});
|
package/index.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
defaultSeverity: 'error',
|
|
3
|
+
plugins: ['stylelint-scss'],
|
|
4
|
+
rules: {
|
|
5
|
+
/**
|
|
6
|
+
* Possible errors
|
|
7
|
+
* @link https://stylelint.io/user-guide/rules/#possible-errors
|
|
8
|
+
*/
|
|
9
|
+
'at-rule-no-unknown': null,
|
|
10
|
+
'scss/at-rule-no-unknown': true,
|
|
11
|
+
'block-no-empty': null,
|
|
12
|
+
'color-no-invalid-hex': true,
|
|
13
|
+
'comment-no-empty': true,
|
|
14
|
+
'declaration-block-no-duplicate-properties': [
|
|
15
|
+
true,
|
|
16
|
+
{
|
|
17
|
+
ignore: ['consecutive-duplicates-with-different-values'],
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
'declaration-block-no-shorthand-property-overrides': true,
|
|
21
|
+
'font-family-no-duplicate-names': true,
|
|
22
|
+
'function-calc-no-unspaced-operator': true,
|
|
23
|
+
'function-linear-gradient-no-nonstandard-direction': true,
|
|
24
|
+
'keyframe-declaration-no-important': true,
|
|
25
|
+
'media-feature-name-no-unknown': true,
|
|
26
|
+
'no-descending-specificity': null, // @reason 实际有很多这样用的,且多数人熟悉 css 优先级
|
|
27
|
+
'no-duplicate-at-import-rules': true,
|
|
28
|
+
'no-duplicate-selectors': true,
|
|
29
|
+
'no-empty-source': null,
|
|
30
|
+
'no-extra-semicolons': true,
|
|
31
|
+
'no-invalid-double-slash-comments': true,
|
|
32
|
+
'property-no-unknown': true,
|
|
33
|
+
'selector-pseudo-class-no-unknown': [
|
|
34
|
+
true,
|
|
35
|
+
{
|
|
36
|
+
ignorePseudoClasses: ['global', 'local', 'export'],
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
'selector-pseudo-element-no-unknown': true,
|
|
40
|
+
'string-no-newline': true,
|
|
41
|
+
'unit-no-unknown': [
|
|
42
|
+
true,
|
|
43
|
+
{
|
|
44
|
+
ignoreUnits: ['rpx'],
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Stylistic issues
|
|
50
|
+
* @link https://stylelint.io/user-guide/rules/list#stylistic-issues
|
|
51
|
+
*/
|
|
52
|
+
indentation: 2,
|
|
53
|
+
'block-closing-brace-newline-before': 'always-multi-line',
|
|
54
|
+
'block-closing-brace-space-before': 'always-single-line',
|
|
55
|
+
'block-opening-brace-newline-after': 'always-multi-line',
|
|
56
|
+
'block-opening-brace-space-before': 'always',
|
|
57
|
+
'block-opening-brace-space-after': 'always-single-line',
|
|
58
|
+
'color-hex-case': 'lower',
|
|
59
|
+
'color-hex-length': 'short',
|
|
60
|
+
'comment-whitespace-inside': 'always',
|
|
61
|
+
'declaration-colon-space-before': 'never',
|
|
62
|
+
'declaration-colon-space-after': 'always',
|
|
63
|
+
'declaration-block-single-line-max-declarations': 1,
|
|
64
|
+
'declaration-block-trailing-semicolon': [
|
|
65
|
+
'always',
|
|
66
|
+
{
|
|
67
|
+
severity: 'error',
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
'length-zero-no-unit': [
|
|
71
|
+
true,
|
|
72
|
+
{
|
|
73
|
+
ignore: ['custom-properties'],
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
'max-line-length': 100,
|
|
77
|
+
'selector-max-id': 0,
|
|
78
|
+
'value-list-comma-space-after': 'always-single-line',
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* stylelint-scss rules
|
|
82
|
+
* @link https://www.npmjs.com/package/stylelint-scss
|
|
83
|
+
*/
|
|
84
|
+
'scss/double-slash-comment-whitespace-inside': 'always',
|
|
85
|
+
},
|
|
86
|
+
ignoreFiles: ['**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx'],
|
|
87
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "format-demo-stylelint-config",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "印客学院 CSS规范",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"encode",
|
|
8
|
+
"style",
|
|
9
|
+
"lint"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"test": "jest"
|
|
13
|
+
},
|
|
14
|
+
"author": "hyx",
|
|
15
|
+
"homepage": "https://github.com/Huang-Yux/format_demo#readme",
|
|
16
|
+
"license": "ISC",
|
|
17
|
+
"peerDependencies": {
|
|
18
|
+
"stylelint": ">=8.3.0",
|
|
19
|
+
"stylelint-scss": ">=2.0.0"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"jest": "^29.5.0",
|
|
23
|
+
"stylelint": "^14.3.0",
|
|
24
|
+
"stylelint-scss": "^4.1.0"
|
|
25
|
+
},
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "git+https://github.com/Huang-Yux/format_demo.git"
|
|
29
|
+
},
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/Huang-Yux/format_demo/issues"
|
|
32
|
+
},
|
|
33
|
+
"gitHead": "400e366da374414a0b11d025d7f31d37a6a03643"
|
|
34
|
+
}
|