@d-zero/stylelint-config 5.0.0-alpha.7 → 5.0.0-alpha.71

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023 D-ZERO Co., Ltd.
3
+ Copyright (c) 2024 D-ZERO Co., Ltd.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,4 +1,54 @@
1
1
  # `@d-zero/stylelint-config`
2
2
 
3
- - 使用: 🆗 使用可
4
- - 解説: 🚧 準備中
3
+ ## 個別インストール
4
+
5
+ ```sh
6
+ npm install -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,67 +1,26 @@
1
1
  module.exports = {
2
- extends: ['stylelint-config-standard', 'stylelint-config-recess-order'],
3
- plugins: ['stylelint-scss', 'stylelint-order'],
2
+ plugins: ['stylelint-use-logical', '@d-zero/stylelint-rules'],
3
+ extends: ['stylelint-config-recommended'],
4
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
5
  'at-rule-disallowed-list': null,
33
- 'at-rule-empty-line-before': [
34
- 'always',
35
- {
36
- except: ['blockless-after-same-name-blockless', 'first-nested'],
37
- ignore: ['after-comment'],
38
- },
39
- ],
6
+
40
7
  '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
- ],
8
+ 'at-rule-no-unknown': true,
47
9
  'color-hex-length': 'short',
48
10
  'color-named': 'never',
49
11
  'color-no-invalid-hex': true,
50
12
  'comment-empty-line-before': [
51
13
  'always',
52
14
  {
53
- ignore: ['stylelint-commands'],
15
+ except: ['first-nested'],
54
16
  },
55
17
  ],
56
18
  'comment-no-empty': true,
57
- 'comment-whitespace-inside': 'always',
58
19
  'comment-word-disallowed-list': ['/^TODO:/'],
59
- 'custom-property-empty-line-before': 'never',
60
20
  'declaration-block-no-duplicate-properties': true,
61
21
  'declaration-block-no-redundant-longhand-properties': true,
62
22
  'declaration-block-no-shorthand-property-overrides': true,
63
23
  'declaration-block-single-line-max-declarations': 80,
64
- 'declaration-empty-line-before': 'never',
65
24
  'declaration-no-important': true,
66
25
  'declaration-property-value-disallowed-list': null,
67
26
  'declaration-property-value-allowed-list': null,
@@ -72,15 +31,11 @@ module.exports = {
72
31
  'function-calc-no-unspaced-operator': true,
73
32
  'function-linear-gradient-no-nonstandard-direction': true,
74
33
  'function-name-case': 'lower',
75
- 'function-no-unknown': [
76
- true,
77
- {
78
- ignoreFunctions: ['a', 'lighten', 'darken', 'resolve'],
79
- },
80
- ],
34
+ 'function-no-unknown': true,
81
35
  'function-url-scheme-allowed-list': null,
82
36
  'function-url-no-scheme-relative': true,
83
37
  'function-url-quotes': 'always',
38
+ 'import-notation': 'string',
84
39
  'keyframe-declaration-no-important': true,
85
40
  'length-zero-no-unit': true,
86
41
  'max-nesting-depth': 8,
@@ -102,17 +57,17 @@ module.exports = {
102
57
  },
103
58
  ],
104
59
  'rule-empty-line-before': [
105
- 'always-multi-line',
60
+ 'always',
106
61
  {
107
- except: ['after-single-line-comment', 'first-nested'],
62
+ except: ['first-nested'],
108
63
  ignore: ['after-comment'],
109
64
  },
110
65
  ],
111
66
  'selector-attribute-operator-disallowed-list': null,
112
67
  'selector-attribute-quotes': 'always',
113
68
  'selector-max-compound-selectors': 8,
114
- 'selector-max-specificity': '0,10,10',
115
- 'selector-max-id': 0,
69
+ 'selector-max-specificity': null,
70
+ 'selector-max-id': [0, { message: 'スタイル定義でIDセレクタは使わないでください' }],
116
71
  'selector-max-universal': 1,
117
72
  'selector-no-vendor-prefix': true,
118
73
  'selector-pseudo-class-disallowed-list': ['link'],
@@ -127,15 +82,16 @@ module.exports = {
127
82
  'value-keyword-case': null,
128
83
  'value-no-vendor-prefix': true,
129
84
 
85
+ // Plugin stylelint-use-logical
86
+ 'csstools/use-logical': 'always',
87
+
88
+ // Plugin @d-zero/stylelint-rules
89
+ '@d-zero/prefer-individual-transform-properties': true,
90
+ '@d-zero/shorthand-property-use-logical': true,
91
+
130
92
  // Overwrite stylelint-config-standard
131
93
  'custom-media-pattern': null,
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
- ignoreFiles: [
8
- '__assets/**/*.{js,jsx,ts,tsx,html,pug}',
9
- '__assets/css/_syntax-rules.scss',
10
- 'htdocs/**/*',
11
- 'docs/**/*.md',
12
- ],
10
+ extends: [...base.extends, ...order.extends],
11
+ plugins: [...scss.plugins, ...base.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-id-pattern': '^$',
15
- 'selector-nested-pattern': '^[^.]+.*',
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,34 +1,38 @@
1
1
  {
2
2
  "name": "@d-zero/stylelint-config",
3
- "version": "5.0.0-alpha.7",
3
+ "version": "5.0.0-alpha.71",
4
4
  "description": "Configurations of Stylelint",
5
5
  "repository": "https://github.com/d-zero-dev/linters.git",
6
6
  "author": "D-ZERO Co., Ltd.",
7
7
  "license": "MIT",
8
- "private": false,
9
8
  "publishConfig": {
10
9
  "access": "public"
11
10
  },
11
+ "engines": {
12
+ "node": ">=22.0.0"
13
+ },
12
14
  "type": "commonjs",
13
15
  "exports": {
14
16
  ".": "./index.js",
15
17
  "./base": "./base.js",
16
18
  "./name": "./name.js",
19
+ "./order": "./order.js",
20
+ "./scss": "./scss.js",
17
21
  "./values": "./values.js"
18
22
  },
19
23
  "files": [
20
- "base.js",
21
- "index.js",
22
- "name.js",
23
- "values.js"
24
+ "*.js"
24
25
  ],
25
26
  "main": "index.js",
26
27
  "dependencies": {
27
- "stylelint": "16.2.1",
28
- "stylelint-config-recess-order": "4.4.0",
29
- "stylelint-config-standard": "36.0.0",
30
- "stylelint-order": "6.0.4",
31
- "stylelint-scss": "6.1.0"
28
+ "@d-zero/stylelint-rules": "5.0.0-alpha.71",
29
+ "postcss-scss": "4.0.9",
30
+ "stylelint": "16.23.1",
31
+ "stylelint-config-recess-order": "7.2.0",
32
+ "stylelint-config-standard": "39.0.0",
33
+ "stylelint-order": "7.0.0",
34
+ "stylelint-scss": "6.12.1",
35
+ "stylelint-use-logical": "2.1.2"
32
36
  },
33
- "gitHead": "5bb32f43f5fc901a5fe7d627bf10385c29ee892e"
37
+ "gitHead": "efe77aa6335d2b64c43cf048d074fe9b090d4784"
34
38
  }
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
+ 'no-invalid-position-at-import-rule': [
12
+ true,
13
+ {
14
+ ignoreAtRules: ['use'],
15
+ },
16
+ ],
17
+ },
18
+ };
package/values.js CHANGED
@@ -1,30 +1,36 @@
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
- ['/#[0-9a-f]{3}/', '/(?:rgb|hsl)a?\\(.+?\\)/'],
6
- 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
- ],
13
+ [/#[0-9a-f]{3}/, /(?:rgb|hsl)a?\(.+?\)/],
14
+ content: [/^"\\[0-9a-f]{1,6}"$/i],
17
15
  },
18
16
  'declaration-property-value-allowed-list': {
19
17
  'font-size': [
20
18
  'inherit',
21
- '$root-font-size',
22
- '$base-font-size',
19
+ /^\$[a-z][a-z0-9]*-font-size(?:-[a-z0-9]+)?$/,
23
20
  '1em',
24
- '/^calc\\((?:\\$[a-z_][a-z0-9_-]*|(?:[0-9]*\\.)?[0-9]+) \\/ (?:\\$[a-z_][a-z0-9_-]*|(?:[0-9]*\\.)?[0-9]+) \\* (?:1em|100vw)\\)$/',
25
- '/^(?:[0-9]*\\.)?[0-9]+rem/',
26
- '/^clamp\\(/',
21
+ /^calc\(\s*(?:(?:\d*\.)?\d+|var\(\s*--[a-z][a-z0-9_-]+\s*\))\s*\/\s*(?:(?:\d*\.)?\d+|var\(\s*--[a-z][a-z0-9_-]+\s*\))\s*\*\s*(?:1em|1rem|100vw)\s*\)$/,
22
+ /^(?:\d*\.)?\d+rem/,
23
+ /^clamp\(/,
24
+ // Custom properties
25
+ /^var\(/,
26
+ ],
27
+ flex: [
28
+ /^\s*[01]\s+[01]\s.+/,
29
+ // Custom properties
30
+ /^var\(/,
27
31
  ],
32
+ 'flex-grow': ['0', '1'],
33
+ 'flex-shrink': ['0', '1'],
28
34
  },
29
35
  'unit-disallowed-list': [
30
36
  'ex',
@@ -44,8 +50,31 @@ module.exports = {
44
50
  'value-keyword-case': [
45
51
  'lower',
46
52
  {
47
- ignoreProperties: ['/^\\$font-family-/'],
53
+ ignoreProperties: [/^\$font-family-/],
48
54
  },
49
55
  ],
56
+
57
+ '@d-zero/declaration-value-type-disallowed-list': {
58
+ '/^length|percentage$/': {
59
+ ignoreProperties: ['font-size'],
60
+ patterns: [
61
+ // float
62
+ `/[0-9]*?\\.[0-9]+?${PERCENTATE_UNITS}/`,
63
+
64
+ // 1000% or larger
65
+ `/[1-9][0-9]{3,}?${PERCENTATE_UNITS}/`,
66
+
67
+ // 200% - 999%
68
+ `/[2-9][0-9][0-9]${PERCENTATE_UNITS}/`,
69
+
70
+ // 101% - 199%
71
+ `/1[0-9][1-9]${PERCENTATE_UNITS}/`,
72
+ `/1[1-9][0-9]${PERCENTATE_UNITS}/`,
73
+
74
+ // 1% - 99%
75
+ `/[1-9][0-9]?${PERCENTATE_UNITS}/`,
76
+ ],
77
+ },
78
+ },
50
79
  },
51
80
  };