@d-zero/stylelint-config 5.0.0-alpha.2 → 5.0.0-alpha.20
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 +1 -1
- package/README.md +52 -2
- package/base.js +5 -49
- package/index.js +8 -6
- package/name.js +29 -5
- package/order.js +33 -0
- package/package.json +10 -9
- package/scss.js +18 -0
- package/values.js +35 -11
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,4 +1,54 @@
|
|
|
1
1
|
# `@d-zero/stylelint-config`
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
## 個別インストール
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
yarn add -D @d-zero/stylelint-config
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## 使い方
|
|
10
|
+
|
|
11
|
+
`.stylelintrc`を作成し、[`extends`](https://stylelint.io/user-guide/configure#extends)機能を使って読み込みます。
|
|
12
|
+
|
|
13
|
+
```json
|
|
14
|
+
{
|
|
15
|
+
"extends": ["@d-zero/stylelint-config"]
|
|
16
|
+
}
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### 拡張
|
|
20
|
+
|
|
21
|
+
プロジェクトに合わせて設定を追加します。
|
|
22
|
+
|
|
23
|
+
```json
|
|
24
|
+
{
|
|
25
|
+
"extends": "@d-zero/stylelint-config",
|
|
26
|
+
"rules": {
|
|
27
|
+
// 例: @ルールで未知のルールを許可する
|
|
28
|
+
"at-rule-no-unknown": null
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## 種類別プリセット
|
|
34
|
+
|
|
35
|
+
| パッケージパス | 用途 |
|
|
36
|
+
| --------------------------------- | ---------------- |
|
|
37
|
+
| `@d-zero/stylelint-config` | フルセット |
|
|
38
|
+
| `@d-zero/stylelint-config/base` | 基本セット |
|
|
39
|
+
| `@d-zero/stylelint-config/name` | 命名規則 |
|
|
40
|
+
| `@d-zero/stylelint-config/order` | プロパティの順番 |
|
|
41
|
+
| `@d-zero/stylelint-config/values` | プロパティ値 |
|
|
42
|
+
| `@d-zero/stylelint-config/scss` | SCSS関連 |
|
|
43
|
+
|
|
44
|
+
`@d-zero/stylelint-config`はすべてのルールを含んでいるので、一部のルールのみを利用する場合は、それぞれ種類別のものを利用します。
|
|
45
|
+
|
|
46
|
+
```json
|
|
47
|
+
{
|
|
48
|
+
"extends": [
|
|
49
|
+
"@d-zero/stylelint-config/scss",
|
|
50
|
+
"@d-zero/stylelint-config/base",
|
|
51
|
+
"@d-zero/stylelint-config/values"
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
```
|
package/base.js
CHANGED
|
@@ -1,34 +1,6 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
extends: ['stylelint-config-standard'
|
|
3
|
-
plugins: ['stylelint-scss', 'stylelint-order'],
|
|
2
|
+
extends: ['stylelint-config-standard'],
|
|
4
3
|
rules: {
|
|
5
|
-
'order/order': [
|
|
6
|
-
'dollar-variables',
|
|
7
|
-
'custom-properties',
|
|
8
|
-
{
|
|
9
|
-
type: 'at-rule',
|
|
10
|
-
name: 'custom-media',
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
type: 'at-rule',
|
|
14
|
-
name: 'extend',
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
type: 'at-rule',
|
|
18
|
-
name: 'mixin',
|
|
19
|
-
},
|
|
20
|
-
'declarations',
|
|
21
|
-
{
|
|
22
|
-
type: 'at-rule',
|
|
23
|
-
name: 'supports',
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
type: 'at-rule',
|
|
27
|
-
name: 'media',
|
|
28
|
-
hasBlock: true,
|
|
29
|
-
},
|
|
30
|
-
'rules',
|
|
31
|
-
],
|
|
32
4
|
'at-rule-disallowed-list': null,
|
|
33
5
|
'at-rule-empty-line-before': [
|
|
34
6
|
'always',
|
|
@@ -38,12 +10,7 @@ module.exports = {
|
|
|
38
10
|
},
|
|
39
11
|
],
|
|
40
12
|
'at-rule-no-vendor-prefix': true,
|
|
41
|
-
'at-rule-no-unknown':
|
|
42
|
-
true,
|
|
43
|
-
{
|
|
44
|
-
ignoreAtRules: ['mixin', 'extend', 'for', 'if', 'include', 'use', 'forward'],
|
|
45
|
-
},
|
|
46
|
-
],
|
|
13
|
+
'at-rule-no-unknown': true,
|
|
47
14
|
'color-hex-length': 'short',
|
|
48
15
|
'color-named': 'never',
|
|
49
16
|
'color-no-invalid-hex': true,
|
|
@@ -72,12 +39,7 @@ module.exports = {
|
|
|
72
39
|
'function-calc-no-unspaced-operator': true,
|
|
73
40
|
'function-linear-gradient-no-nonstandard-direction': true,
|
|
74
41
|
'function-name-case': 'lower',
|
|
75
|
-
'function-no-unknown':
|
|
76
|
-
true,
|
|
77
|
-
{
|
|
78
|
-
ignoreFunctions: ['a', 'lighten', 'darken', 'resolve'],
|
|
79
|
-
},
|
|
80
|
-
],
|
|
42
|
+
'function-no-unknown': true,
|
|
81
43
|
'function-url-scheme-allowed-list': null,
|
|
82
44
|
'function-url-no-scheme-relative': true,
|
|
83
45
|
'function-url-quotes': 'always',
|
|
@@ -111,8 +73,8 @@ module.exports = {
|
|
|
111
73
|
'selector-attribute-operator-disallowed-list': null,
|
|
112
74
|
'selector-attribute-quotes': 'always',
|
|
113
75
|
'selector-max-compound-selectors': 8,
|
|
114
|
-
'selector-max-specificity':
|
|
115
|
-
'selector-max-id': 0,
|
|
76
|
+
'selector-max-specificity': null,
|
|
77
|
+
'selector-max-id': [0, { message: 'スタイル定義でIDセレクタは使わないでください' }],
|
|
116
78
|
'selector-max-universal': 1,
|
|
117
79
|
'selector-no-vendor-prefix': true,
|
|
118
80
|
'selector-pseudo-class-disallowed-list': ['link'],
|
|
@@ -132,10 +94,4 @@ module.exports = {
|
|
|
132
94
|
'custom-property-pattern': null,
|
|
133
95
|
'selector-class-pattern': null,
|
|
134
96
|
},
|
|
135
|
-
overrides: [
|
|
136
|
-
{
|
|
137
|
-
files: ['__assets/**/*.scss'],
|
|
138
|
-
customSyntax: 'postcss-scss',
|
|
139
|
-
},
|
|
140
|
-
],
|
|
141
97
|
};
|
package/index.js
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
const base = require('./base');
|
|
2
2
|
const name = require('./name');
|
|
3
|
+
const order = require('./order');
|
|
4
|
+
const scss = require('./scss');
|
|
3
5
|
const values = require('./values');
|
|
4
6
|
|
|
5
7
|
module.exports = {
|
|
8
|
+
...scss,
|
|
6
9
|
...base,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
'htdocs/**/*',
|
|
11
|
-
'docs/**/*.md',
|
|
12
|
-
],
|
|
10
|
+
extends: [...base.extends, ...order.extends],
|
|
11
|
+
plugins: [...scss.plugins, ...order.plugins, ...values.plugins],
|
|
12
|
+
ignoreFiles: ['**/*.{js,jsx,ts,tsx,html,pug}', 'htdocs/**/*', 'docs/**/*.md'],
|
|
13
13
|
rules: {
|
|
14
14
|
...base.rules,
|
|
15
|
+
...order.rules,
|
|
15
16
|
...name.rules,
|
|
16
17
|
...values.rules,
|
|
18
|
+
...scss.rules,
|
|
17
19
|
},
|
|
18
20
|
};
|
package/name.js
CHANGED
|
@@ -1,17 +1,41 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
rules: {
|
|
3
|
-
'scss/dollar-variable-pattern':
|
|
4
|
-
'^(?:[a-z]{2,}-[a-z0-9-]+|_[a-z][a-z0-9]*(?:-[a-z0-9]+)*)$',
|
|
5
|
-
'scss/percent-placeholder-pattern': '^[a-z]{2,}(-[a-z0-9-]+)?$',
|
|
6
3
|
'custom-media-pattern': '[a-z][a-z-]*',
|
|
7
4
|
'custom-property-pattern': '[a-z][a-z-]*',
|
|
8
5
|
'selector-class-pattern': [
|
|
9
6
|
'^c-[a-z][a-z0-9]*(?:-[a-z0-9]+)*(?:__[a-z0-9]+(?:-[a-z0-9]+)*)?$',
|
|
10
7
|
{
|
|
11
8
|
resolveNestedSelectors: true,
|
|
9
|
+
/**
|
|
10
|
+
* @param {string} selector
|
|
11
|
+
* @returns {string}
|
|
12
|
+
*/
|
|
13
|
+
message: (selector) => {
|
|
14
|
+
if (!selector.startsWith('.c-')) {
|
|
15
|
+
return `クラス名は「c-」から始めてください: ${selector}`;
|
|
16
|
+
}
|
|
17
|
+
if (selector.split('__').length > 2) {
|
|
18
|
+
return `「__」はコンポーネント名とエレメント名の区切りを表します。エレメント名の文字区切りは「-」を使います: ${selector}`;
|
|
19
|
+
}
|
|
20
|
+
return `クラス名に命名規則にない文字が含まれています: ${selector}`;
|
|
21
|
+
},
|
|
12
22
|
},
|
|
13
23
|
],
|
|
14
|
-
'selector-
|
|
15
|
-
|
|
24
|
+
'selector-nested-pattern': [
|
|
25
|
+
'^[^.]+.*',
|
|
26
|
+
{
|
|
27
|
+
/**
|
|
28
|
+
* @param {string} selector
|
|
29
|
+
* @returns {string}
|
|
30
|
+
*/
|
|
31
|
+
message: (selector) => {
|
|
32
|
+
return `コンポーネントのスタイル定義の中で別のコンポーネントを定義してはいけません: ${selector}`;
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
|
|
37
|
+
'scss/dollar-variable-pattern':
|
|
38
|
+
'^(?:[a-z]{2,}-[a-z0-9-]+|_[a-z][a-z0-9]*(?:-[a-z0-9]+)*)$',
|
|
39
|
+
'scss/percent-placeholder-pattern': '^[a-z]{2,}(-[a-z0-9-]+)?$',
|
|
16
40
|
},
|
|
17
41
|
};
|
package/order.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
extends: ['stylelint-config-recess-order'],
|
|
3
|
+
plugins: ['stylelint-order'],
|
|
4
|
+
rules: {
|
|
5
|
+
'order/order': [
|
|
6
|
+
'dollar-variables',
|
|
7
|
+
'custom-properties',
|
|
8
|
+
{
|
|
9
|
+
type: 'at-rule',
|
|
10
|
+
name: 'custom-media',
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
type: 'at-rule',
|
|
14
|
+
name: 'extend',
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
type: 'at-rule',
|
|
18
|
+
name: 'mixin',
|
|
19
|
+
},
|
|
20
|
+
'declarations',
|
|
21
|
+
{
|
|
22
|
+
type: 'at-rule',
|
|
23
|
+
name: 'supports',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
type: 'at-rule',
|
|
27
|
+
name: 'media',
|
|
28
|
+
hasBlock: true,
|
|
29
|
+
},
|
|
30
|
+
'rules',
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@d-zero/stylelint-config",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.20",
|
|
4
4
|
"description": "Configurations of Stylelint",
|
|
5
5
|
"repository": "https://github.com/d-zero-dev/linters.git",
|
|
6
6
|
"author": "D-ZERO Co., Ltd.",
|
|
@@ -14,21 +14,22 @@
|
|
|
14
14
|
".": "./index.js",
|
|
15
15
|
"./base": "./base.js",
|
|
16
16
|
"./name": "./name.js",
|
|
17
|
+
"./order": "./order.js",
|
|
18
|
+
"./scss": "./scss.js",
|
|
17
19
|
"./values": "./values.js"
|
|
18
20
|
},
|
|
19
21
|
"files": [
|
|
20
|
-
"
|
|
21
|
-
"index.js",
|
|
22
|
-
"name.js",
|
|
23
|
-
"values.js"
|
|
22
|
+
"*.js"
|
|
24
23
|
],
|
|
25
24
|
"main": "index.js",
|
|
26
25
|
"dependencies": {
|
|
27
|
-
"stylelint": "
|
|
28
|
-
"
|
|
26
|
+
"@d-zero/stylelint-rules": "5.0.0-alpha.20",
|
|
27
|
+
"postcss-scss": "4.0.9",
|
|
28
|
+
"stylelint": "16.2.1",
|
|
29
|
+
"stylelint-config-recess-order": "5.0.0",
|
|
29
30
|
"stylelint-config-standard": "36.0.0",
|
|
30
31
|
"stylelint-order": "6.0.4",
|
|
31
|
-
"stylelint-scss": "6.1
|
|
32
|
+
"stylelint-scss": "6.2.1"
|
|
32
33
|
},
|
|
33
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "6096dc3d998473962dab1f09f4cac4f9dc42600e"
|
|
34
35
|
}
|
package/scss.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
customSyntax: 'postcss-scss',
|
|
3
|
+
plugins: ['stylelint-scss'],
|
|
4
|
+
rules: {
|
|
5
|
+
'at-rule-no-unknown': [
|
|
6
|
+
true,
|
|
7
|
+
{
|
|
8
|
+
ignoreAtRules: ['mixin', 'extend', 'for', 'if', 'include', 'use', 'forward'],
|
|
9
|
+
},
|
|
10
|
+
],
|
|
11
|
+
'function-no-unknown': [
|
|
12
|
+
true,
|
|
13
|
+
{
|
|
14
|
+
ignoreFunctions: ['a', 'lighten', 'darken', 'resolve'],
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
};
|
package/values.js
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @see https://drafts.csswg.org/css-values-4/#viewport-relative-lengths
|
|
3
|
+
*/
|
|
4
|
+
const VIEWPORT_PERCENTAGE_LENGTHS = '[ls]?v(?:w|h|i|d|max|min)';
|
|
5
|
+
|
|
6
|
+
const PERCENTATE_UNITS = `(?:%|${VIEWPORT_PERCENTAGE_LENGTHS})`;
|
|
7
|
+
|
|
1
8
|
module.exports = {
|
|
9
|
+
plugins: ['@d-zero/stylelint-rules'],
|
|
2
10
|
rules: {
|
|
3
11
|
'declaration-property-value-disallowed-list': {
|
|
4
12
|
'/^(?:color|background|background-color|border|border-color|outline|outline-color)$/':
|
|
5
13
|
['/#[0-9a-f]{3}/', '/(?:rgb|hsl)a?\\(.+?\\)/'],
|
|
6
14
|
content: ['/^\\"\\\\[0-9a-fA-F]{1,6}\\"$/'],
|
|
7
|
-
flex: ['/calc/'],
|
|
8
|
-
'/^(?:max-|min-)?(?:width|height)|^flex/': [
|
|
9
|
-
'/[1-9]*\\.[0-9]+(?:%|vw|vh)/',
|
|
10
|
-
'/(?:^|[^0-9])[0-9](?:%|vw|vh)/',
|
|
11
|
-
'/(?:^|[^0-9])[0-9]{2}(?:%|vw|vh)/',
|
|
12
|
-
'/1[0-9][1-9](?:%|vw|vh)/',
|
|
13
|
-
'/1[1-9][0-9](?:%|vw|vh)/',
|
|
14
|
-
'/[2-9][0-9][0-9](?:%|vw|vh)/',
|
|
15
|
-
'/[0-9]{4,}(?:%|vw|vh)/',
|
|
16
|
-
],
|
|
17
15
|
},
|
|
18
16
|
'declaration-property-value-allowed-list': {
|
|
19
17
|
'font-size': [
|
|
@@ -21,10 +19,13 @@ module.exports = {
|
|
|
21
19
|
'$root-font-size',
|
|
22
20
|
'$base-font-size',
|
|
23
21
|
'1em',
|
|
24
|
-
'/^calc\\((?:\\$[a-z_][a-z0-9_-]*|(?:[0-9]*\\.)?[0-9]+) \\/ (?:\\$[a-z_][a-z0-9_-]*|(?:[0-9]*\\.)?[0-9]+) \\* (?:1em|100vw)\\)$/',
|
|
22
|
+
'/^calc\\(\\s*(?:\\$[a-z_][a-z0-9_-]*|(?:[0-9]*\\.)?[0-9]+) \\/ (?:\\$[a-z_][a-z0-9_-]*|(?:[0-9]*\\.)?[0-9]+) \\* (?:1em|100vw)\\s*\\)$/',
|
|
25
23
|
'/^(?:[0-9]*\\.)?[0-9]+rem/',
|
|
26
24
|
'/^clamp\\(/',
|
|
27
25
|
],
|
|
26
|
+
flex: ['/^\\s*[01]\\s+[01]\\s.+/'],
|
|
27
|
+
'flex-grow': ['0', '1'],
|
|
28
|
+
'flex-shrink': ['0', '1'],
|
|
28
29
|
},
|
|
29
30
|
'unit-disallowed-list': [
|
|
30
31
|
'ex',
|
|
@@ -47,5 +48,28 @@ module.exports = {
|
|
|
47
48
|
ignoreProperties: ['/^\\$font-family-/'],
|
|
48
49
|
},
|
|
49
50
|
],
|
|
51
|
+
|
|
52
|
+
'@d-zero/declaration-value-type-disallowed-list': {
|
|
53
|
+
'/^length|percentage$/': {
|
|
54
|
+
ignoreProperties: ['font-size'],
|
|
55
|
+
patterns: [
|
|
56
|
+
// float
|
|
57
|
+
`/[1-9]*\\.[0-9]+${PERCENTATE_UNITS}/`,
|
|
58
|
+
|
|
59
|
+
// 1% - 99%
|
|
60
|
+
`/[1-9][0-9]?${PERCENTATE_UNITS}/`,
|
|
61
|
+
|
|
62
|
+
// 101% - 199%
|
|
63
|
+
`/1[0-9][1-9]${PERCENTATE_UNITS}/`,
|
|
64
|
+
`/1[1-9][0-9]${PERCENTATE_UNITS}/`,
|
|
65
|
+
|
|
66
|
+
// 200% - 999%
|
|
67
|
+
`/[2-9][0-9][0-9]${PERCENTATE_UNITS}/`,
|
|
68
|
+
|
|
69
|
+
// 1000% or larger
|
|
70
|
+
`/[1-9][0-9]{3,}${PERCENTATE_UNITS}/`,
|
|
71
|
+
],
|
|
72
|
+
},
|
|
73
|
+
},
|
|
50
74
|
},
|
|
51
75
|
};
|