@alexlit/config-stylelint 44.0.3 → 45.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.
package/README.md CHANGED
@@ -8,22 +8,44 @@ npm i @alexlit/config-stylelint -D
8
8
 
9
9
  ## Connection
10
10
 
11
- ```js
12
- // stylelint.config.js
13
- import config from '@alexlit/config-stylelint';
14
-
15
- export default {
16
- extends: [
17
- '@alexlit/config-stylelint',
18
-
19
- /* optional */
20
- '@alexlit/config-stylelint/plugins/optional/gamut',
21
- '@alexlit/config-stylelint/plugins/optional/no-indistinguishable-colors',
22
- '@alexlit/config-stylelint/plugins/optional/logical-css',
23
- ],
24
- ignoreFiles: [...config.ignoreFiles],
25
- };
26
- ```
11
+ - Default
12
+ ([see plugins enabled by default](https://github.com/alex-lit/lint-kit/blob/master/packages/config-stylelint/index.js#L62))
13
+
14
+ ```js
15
+ // stylelint.config.js
16
+ import { createConfig } from '@alexlit/config-stylelint';
17
+
18
+ export default createConfig();
19
+ ```
20
+
21
+ - Custom
22
+
23
+ ```js
24
+ // stylelint.config.js
25
+ import { createConfig } from '@alexlit/config-stylelint';
26
+
27
+ export default createConfig(
28
+ {
29
+ // disable some default plugins
30
+ 'no-nested-media': false,
31
+
32
+ // enable some optional plugins
33
+ gamut: true,
34
+ 'logical-css': true,
35
+ },
36
+ {
37
+ // add custom rules
38
+ rules: {
39
+ 'custom-property-empty-line-before': [
40
+ 'always',
41
+ {
42
+ except: ['after-comment', 'after-custom-property', 'first-nested'],
43
+ },
44
+ ],
45
+ },
46
+ },
47
+ );
48
+ ```
27
49
 
28
50
  ## Development
29
51
 
package/index.js CHANGED
@@ -1,150 +1,112 @@
1
- /* eslint-disable sonarjs/no-duplicate-string, unicorn/no-null */
2
- export default {
1
+ /* eslint-disable no-console, import/extensions */
2
+
3
+ import { config } from './config.js';
4
+
5
+ const ADDITIONAL_PLUGINS = {
6
+ /** @see [stylelint-a11y](https://github.com/double-great/stylelint-a11y) */
7
+ a11y: true,
8
+
9
+ /** @see [stylelint-at-rule-no-children](https://github.com/adityavm/stylelint-at-rule-no-children) */
10
+ 'at-rule-no-children': true,
11
+
12
+ /** @see [stylelint-color-format](https://github.com/filipekiss/stylelint-color-format) */
13
+ 'color-format': true,
14
+
15
+ /** @see [stylelint-declaration-block-no-ignored-properties](https://github.com/kristerkari/stylelint-declaration-block-no-ignored-properties) */
16
+ 'declaration-block-no-ignored-properties': true,
17
+
18
+ /** @see [stylelint-high-performance-animation](https://github.com/kristerkari/stylelint-high-performance-animation) */
19
+ 'high-performance-animation': true,
20
+
21
+ /** @see [stylelint-no-nested-media](https://github.com/dkrnl/stylelint-no-nested-media) */
22
+ 'no-nested-media': true,
23
+
24
+ /** @see [stylelint-no-unresolved-module](https://github.com/niksy/stylelint-no-unresolved-module) */
25
+ 'no-unresolved-module': true,
26
+
27
+ /** @see [stylelint-no-unsupported-browser-features](https://github.com/ismay/stylelint-no-unsupported-browser-features) */
28
+ 'no-unsupported-browser-features': true,
29
+
30
+ /** @see [stylelint-order](https://github.com/hudochenkov/stylelint-order) */
31
+ order: true,
32
+
33
+ /** @see [stylelint-scss](https://github.com/kristerkari/stylelint-scss) */
34
+ scss: true,
35
+
36
+ /** @see [stylelint-selector-no-empty](https://github.com/ssivanatarajan/stylelint-selector-no-empty) */
37
+ 'selector-no-empty': true,
38
+
39
+ /** @see [stylelint-use-nesting](https://github.com/csstools/stylelint-use-nesting) */
40
+ 'use-nesting': true,
41
+
42
+ /** @see [stylelint-config-recommended-vue](https://github.com/ota-meshi/stylelint-config-recommended-vue) */
43
+ vue: true,
44
+ };
45
+
46
+ const OPTIONAL_PLUGINS = {
47
+ /** @see [stylelint-gamut](https://github.com/fpetrakov/stylelint-gamut) */
48
+ gamut: false,
49
+
50
+ /** @see [stylelint-plugin-logical-css](https://github.com/yuschick/stylelint-plugin-logical-css) */
51
+ 'logical-css': false,
52
+
53
+ /** @see [stylelint-no-indistinguishable-colors](https://github.com/ierhyna/stylelint-no-indistinguishable-colors) */
54
+ 'no-indistinguishable-colors': false,
55
+ };
56
+
57
+ const PRETTIER_PLUGINS = {
58
+ /** @see [stylelint-prettier](https://github.com/prettier/stylelint-prettier) */
59
+ prettier: true,
60
+ };
61
+
62
+ const PLUGINS = {
63
+ ...ADDITIONAL_PLUGINS,
64
+ ...OPTIONAL_PLUGINS,
65
+ ...PRETTIER_PLUGINS,
66
+ };
67
+
68
+ /**
69
+ * Create "extends" field
70
+ *
71
+ * @param {PLUGINS} incomingPlugins Plugins
72
+ */
73
+ const connectPlugins = (incomingPlugins = {}) => {
74
+ const extendsPlugins = [];
75
+
76
+ Object.entries({ ...PLUGINS, ...incomingPlugins })?.forEach(
77
+ ([name, isActive]) => {
78
+ if (isActive) {
79
+ extendsPlugins.push(`@alexlit/config-stylelint/plugins/${name}`);
80
+ }
81
+ },
82
+ );
83
+
84
+ return extendsPlugins;
85
+ };
86
+
87
+ /**
88
+ * Create stylelint config
89
+ *
90
+ * @param {PLUGINS} incomingPlugins Plugins
91
+ * @param {import('stylelint').Config} incomingConfig Stylelint config
92
+ */
93
+ const createConfig = (incomingPlugins = {}, incomingConfig = {}) => ({
94
+ ...incomingConfig,
95
+
3
96
  extends: [
4
97
  'stylelint-config-standard',
5
-
6
- './plugins/a11y',
7
- './plugins/at-rule-no-children',
8
- './plugins/color-format',
9
- './plugins/declaration-block-no-ignored-properties',
10
- './plugins/high-performance-animation',
11
- './plugins/no-nested-media',
12
- './plugins/no-unresolved-module',
13
- './plugins/no-unsupported-browser-features',
14
- './plugins/order',
15
- './plugins/scss',
16
- './plugins/selector-no-empty',
17
- // './plugins/use-nesting',
18
- './plugins/vue',
19
-
20
- './plugins/prettier',
21
-
22
- // optional
23
- // './plugins/optional/gamut',
24
- // './plugins/optional/no-indistinguishable-colors',
25
- // './plugins/optional/logical-css',
98
+ ...connectPlugins(incomingPlugins),
99
+ ...(incomingConfig.extends ?? []),
26
100
  ],
27
101
 
28
102
  ignoreFiles: [
29
- '.*/**',
30
- 'build/**',
31
- 'dist/**',
32
- 'docs/**',
33
- 'node_modules/**',
34
- 'storybook-*/**',
103
+ ...(config.ignoreFiles ?? []),
104
+ ...(incomingConfig.ignoreFiles ?? []),
35
105
  ],
36
106
 
37
- rules: {
38
- 'alpha-value-notation': 'number',
39
- 'annotation-no-unknown': [true, { ignoreAnnotations: ['default'] }],
40
- 'at-rule-disallowed-list': ['debug'],
41
-
42
- 'at-rule-empty-line-before': [
43
- 'always',
44
- {
45
- except: ['blockless-after-same-name-blockless', 'first-nested'],
46
- ignoreAtRules: ['else'],
47
- },
48
- ],
49
-
50
- 'at-rule-no-unknown': null,
51
- 'at-rule-no-vendor-prefix': true,
52
- 'block-no-empty': null,
53
- 'color-function-notation': 'modern',
54
- 'color-hex-length': 'short',
55
- 'color-no-hex': true,
56
- 'color-no-invalid-hex': true,
57
-
58
- 'custom-property-empty-line-before': [
59
- 'always',
60
- {
61
- except: ['after-comment', 'after-custom-property', 'first-nested'],
62
- },
63
- ],
64
-
65
- 'custom-property-pattern': '^_?[a-z]+([a-z0-9-]+[a-z0-9]+)?$',
66
- 'declaration-block-no-redundant-longhand-properties': null,
67
-
68
- 'declaration-property-value-no-unknown': [
69
- true,
70
- {
71
- ignoreProperties: {
72
- '/.+/': /^(v-(bind|deep|global|slotted)|theme|view)|\$/,
73
- },
74
- },
75
- ],
76
-
77
- 'font-family-name-quotes': 'always-unless-keyword',
78
- 'function-no-unknown': null, // delegate to scss/function-no-unknown
79
- 'function-url-quotes': 'always',
80
- 'function-url-scheme-disallowed-list': ['/^data/', 'ftp', '/^http/'],
81
- 'hue-degree-notation': 'angle',
82
- 'keyframes-name-pattern': '^[a-z]+(-[a-z]+)*$',
83
-
84
- 'max-nesting-depth': [
85
- 6,
86
- {
87
- ignoreAtRules: ['each', 'media', 'supports', 'include'],
88
- },
89
- ],
90
-
91
- 'media-feature-name-no-unknown': [
92
- true,
93
- { ignoreMediaFeatureNames: ['screen'] },
94
- ],
95
-
96
- 'media-feature-name-no-vendor-prefix': true,
97
- 'no-descending-specificity': null,
98
- 'no-empty-source': null,
99
- 'no-unknown-animations': true,
100
- 'number-max-precision': 3,
101
-
102
- 'property-no-unknown': [
103
- true,
104
- { ignoreProperties: ['align-tracks', 'animation-timeline'] },
105
- ],
106
-
107
- 'property-no-vendor-prefix': true,
108
-
109
- 'rule-empty-line-before': [
110
- 'always',
111
- {
112
- except: ['first-nested'],
113
- ignore: [],
114
- },
115
- ],
116
-
117
- 'selector-class-pattern': [
118
- '^[a-z]([a-z0-9-]+)?(__([a-z0-9]+-?)+)?(--([a-z0-9]+-?)+){0,2}$',
119
- {
120
- message:
121
- 'Selector should be written as BEM "block__element--modifier--value" (selector-class-pattern)',
122
- },
123
- ],
124
-
125
- 'selector-combinator-disallowed-list': ['>>>', '/deep/'],
126
-
127
- 'selector-max-compound-selectors': 6,
128
- 'selector-max-id': 0,
129
- 'selector-no-qualifying-type': null,
130
- 'selector-no-vendor-prefix': true,
131
- 'selector-pseudo-element-disallowed-list': ['shadow'],
132
-
133
- 'selector-pseudo-element-no-unknown': [
134
- true,
135
- { ignorePseudoElements: ['v-deep', 'file-selector-button'] },
136
- ],
137
-
138
- 'selector-type-no-unknown': [true, { ignoreTypes: ['ymaps'] }],
139
- 'shorthand-property-no-redundant-values': true,
140
- 'string-no-newline': null,
141
- 'time-min-milliseconds': 16,
142
-
143
- 'value-keyword-case': [
144
- 'lower',
145
- { camelCaseSvgKeywords: true, ignoreFunctions: ['v-bind'] },
146
- ],
147
-
148
- 'value-no-vendor-prefix': true,
149
- },
150
- };
107
+ plugins: [...(config.plugins ?? []), ...(incomingConfig.plugins ?? [])],
108
+
109
+ rules: { ...config.rules, ...incomingConfig.rules },
110
+ });
111
+
112
+ export { createConfig };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alexlit/config-stylelint",
3
- "version": "44.0.3",
3
+ "version": "45.0.0",
4
4
  "private": false,
5
5
  "description": "Stylelint config",
6
6
  "keywords": [
package/plugins/a11y.js CHANGED
@@ -1,4 +1,3 @@
1
- /** @see [stylelint-a11y](https://github.com/double-great/stylelint-a11y) */
2
1
  export default {
3
2
  plugins: ['@double-great/stylelint-a11y'],
4
3
 
@@ -1,4 +1,3 @@
1
- /** @see [stylelint-at-rule-no-children](https://github.com/adityavm/stylelint-at-rule-no-children) */
2
1
  export default {
3
2
  plugins: ['stylelint-at-rule-no-children'],
4
3
 
@@ -1,4 +1,3 @@
1
- /** @see [stylelint-color-format](https://github.com/filipekiss/stylelint-color-format) */
2
1
  export default {
3
2
  plugins: ['stylelint-color-format'],
4
3
 
@@ -1,4 +1,3 @@
1
- /** @see [stylelint-declaration-block-no-ignored-properties](https://github.com/kristerkari/stylelint-declaration-block-no-ignored-properties) */
2
1
  export default {
3
2
  plugins: ['stylelint-declaration-block-no-ignored-properties'],
4
3
 
@@ -1,4 +1,3 @@
1
- /** @see [stylelint-gamut](https://github.com/fpetrakov/stylelint-gamut) */
2
1
  export default {
3
2
  plugins: ['stylelint-gamut'],
4
3
 
@@ -1,4 +1,3 @@
1
- /** @see [stylelint-high-performance-animation](https://github.com/kristerkari/stylelint-high-performance-animation) */
2
1
  export default {
3
2
  plugins: ['stylelint-high-performance-animation'],
4
3
 
@@ -1,4 +1,3 @@
1
- /** @see [stylelint-plugin-logical-css](https://github.com/yuschick/stylelint-plugin-logical-css) */
2
1
  export default {
3
2
  plugins: ['stylelint-plugin-logical-css'],
4
3
 
@@ -1,4 +1,3 @@
1
- /** @see [stylelint-no-indistinguishable-colors](https://github.com/ierhyna/stylelint-no-indistinguishable-colors) */
2
1
  export default {
3
2
  plugins: ['stylelint-no-indistinguishable-colors'],
4
3
 
@@ -1,4 +1,3 @@
1
- /** @see [stylelint-no-nested-media](https://github.com/dkrnl/stylelint-no-nested-media) */
2
1
  export default {
3
2
  plugins: ['stylelint-no-nested-media'],
4
3
 
@@ -1,4 +1,3 @@
1
- /** @see [stylelint-no-unresolved-module](https://github.com/niksy/stylelint-no-unresolved-module) */
2
1
  export default {
3
2
  plugins: ['stylelint-no-unresolved-module'],
4
3
 
@@ -1,4 +1,3 @@
1
- /** @see [stylelint-no-unsupported-browser-features](https://github.com/ismay/stylelint-no-unsupported-browser-features) */
2
1
  export default {
3
2
  plugins: ['stylelint-no-unsupported-browser-features'],
4
3
 
package/plugins/order.js CHANGED
@@ -1,4 +1,3 @@
1
- /** @see [stylelint-order](https://github.com/hudochenkov/stylelint-order) */
2
1
  export default {
3
2
  plugins: ['stylelint-order'],
4
3
 
@@ -1,4 +1,3 @@
1
- /** @see [stylelint-prettier](https://github.com/prettier/stylelint-prettier) */
2
1
  export default {
3
2
  plugins: ['stylelint-prettier'],
4
3
 
package/plugins/scss.js CHANGED
@@ -1,7 +1,6 @@
1
1
  /* eslint-disable unicorn/no-null */
2
2
  const KEBAB_CASE_PATTERN = '^[a-z]+([a-z0-9-]+[a-z0-9]+)?$';
3
3
 
4
- /** @see [stylelint-scss](https://github.com/kristerkari/stylelint-scss) */
5
4
  export default {
6
5
  extends: ['stylelint-config-standard-scss'],
7
6
 
@@ -1,4 +1,3 @@
1
- /** @see [stylelint-selector-no-empty](https://github.com/ssivanatarajan/stylelint-selector-no-empty) */
2
1
  export default {
3
2
  plugins: ['stylelint-selector-no-empty'],
4
3
 
@@ -1,4 +1,3 @@
1
- /** @see [stylelint-use-nesting](https://github.com/csstools/stylelint-use-nesting) */
2
1
  export default {
3
2
  plugins: ['stylelint-use-nesting'],
4
3
 
package/plugins/vue.js CHANGED
@@ -1,5 +1,3 @@
1
- /** @see [stylelint-config-recommended-vue](https://github.com/ota-meshi/stylelint-config-recommended-vue) */
2
-
3
1
  export default {
4
2
  extends: 'stylelint-config-recommended-vue',
5
3
  };