@xiaohe01/stylelint-config 0.0.1 → 0.0.2

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
@@ -39,7 +39,7 @@ npm install -D stylelint @xiaohe01/stylelint-config
39
39
  Create `stylelint.config.js` in your project root
40
40
 
41
41
  ```js
42
- import defineConfig from "@xiaohe01/stylelint-config";
42
+ import { defineConfig } from "@xiaohe01/stylelint-config";
43
43
 
44
44
  export default defineConfig();
45
45
  ```
package/dist/index.cjs CHANGED
@@ -111,9 +111,7 @@ function buildRules(options) {
111
111
  }
112
112
  if (enableUniApp) {
113
113
  lodashEs.merge(rules, {
114
- "selector-type-no-unknown": [true, {
115
- ignoreTypes: ["page", "rich-text", "scroll-view"]
116
- }]
114
+ "selector-type-no-unknown": null
117
115
  });
118
116
  }
119
117
  if (!lodashEs.isEmpty(options.rules)) {
@@ -121,6 +119,22 @@ function buildRules(options) {
121
119
  }
122
120
  return rules;
123
121
  }
122
+ function buildOverrides(options) {
123
+ if (!lodashEs.isEmpty(options.overrideOverrides)) {
124
+ return options.overrideOverrides;
125
+ }
126
+ const overrides = [{
127
+ files: ["*.html", "*.vue"],
128
+ customSyntax: "postcss-html"
129
+ }, {
130
+ files: ["*.scss"],
131
+ customSyntax: "postcss-scss"
132
+ }];
133
+ if (!lodashEs.isEmpty(options.overrides)) {
134
+ overrides.push(...lodashEs.castArray(options.overrides));
135
+ }
136
+ return overrides;
137
+ }
124
138
  function defineConfig(options = {}) {
125
139
  const presets = lodashEs.merge({
126
140
  scss: isPkgExists(SCSS_PACKAGES),
@@ -138,10 +152,12 @@ function defineConfig(options = {}) {
138
152
  extends: buildExtends(finalOptions),
139
153
  plugins: buildPlugins(finalOptions),
140
154
  rules: buildRules(finalOptions),
155
+ overrides: buildOverrides(finalOptions),
141
156
  ...lodashEs.omit(options, [
142
157
  "extends",
143
158
  "plugins",
144
- "rules"
159
+ "rules",
160
+ "overrides"
145
161
  ])
146
162
  };
147
163
  }
@@ -149,5 +165,6 @@ function defineConfig(options = {}) {
149
165
  exports.SCSS_PACKAGES = SCSS_PACKAGES;
150
166
  exports.UNIAPP_PACKAGE = UNIAPP_PACKAGE;
151
167
  exports.VUE_PACKAGES = VUE_PACKAGES;
168
+ exports.buildOverrides = buildOverrides;
152
169
  exports.defineConfig = defineConfig;
153
170
  exports.isPkgExists = isPkgExists;
package/dist/index.d.cts CHANGED
@@ -13,6 +13,7 @@ type ConfigRule = ConfigRuleSettings<any, object>;
13
13
  interface ConfigRules {
14
14
  [key: string]: ConfigRule;
15
15
  }
16
+ type ConfigOverrides = Config["overrides"];
16
17
  interface ConfigPresets {
17
18
  scss?: boolean;
18
19
  vue?: boolean;
@@ -22,10 +23,12 @@ interface ConfigOptions extends Config {
22
23
  presets?: ConfigPresets;
23
24
  overrideExtends?: Config["extends"];
24
25
  overridePlugins?: Config["plugins"];
26
+ overrideOverrides?: Config["overrides"];
25
27
  }
26
28
 
29
+ declare function buildOverrides(options: ConfigOptions): ConfigOverrides;
27
30
  declare function defineConfig(options?: ConfigOptions): Config;
28
31
 
29
32
  declare function isPkgExists(pkg: Arrayable<string>): boolean;
30
33
 
31
- export { type Arrayable, type ConfigExtend, type ConfigExtends, type ConfigOptions, type ConfigPlugin, type ConfigPlugins, type ConfigPresets, type ConfigRule, type ConfigRules, SCSS_PACKAGES, UNIAPP_PACKAGE, VUE_PACKAGES, defineConfig, isPkgExists };
34
+ export { type Arrayable, type ConfigExtend, type ConfigExtends, type ConfigOptions, type ConfigOverrides, type ConfigPlugin, type ConfigPlugins, type ConfigPresets, type ConfigRule, type ConfigRules, SCSS_PACKAGES, UNIAPP_PACKAGE, VUE_PACKAGES, buildOverrides, defineConfig, isPkgExists };
package/dist/index.d.mts CHANGED
@@ -13,6 +13,7 @@ type ConfigRule = ConfigRuleSettings<any, object>;
13
13
  interface ConfigRules {
14
14
  [key: string]: ConfigRule;
15
15
  }
16
+ type ConfigOverrides = Config["overrides"];
16
17
  interface ConfigPresets {
17
18
  scss?: boolean;
18
19
  vue?: boolean;
@@ -22,10 +23,12 @@ interface ConfigOptions extends Config {
22
23
  presets?: ConfigPresets;
23
24
  overrideExtends?: Config["extends"];
24
25
  overridePlugins?: Config["plugins"];
26
+ overrideOverrides?: Config["overrides"];
25
27
  }
26
28
 
29
+ declare function buildOverrides(options: ConfigOptions): ConfigOverrides;
27
30
  declare function defineConfig(options?: ConfigOptions): Config;
28
31
 
29
32
  declare function isPkgExists(pkg: Arrayable<string>): boolean;
30
33
 
31
- export { type Arrayable, type ConfigExtend, type ConfigExtends, type ConfigOptions, type ConfigPlugin, type ConfigPlugins, type ConfigPresets, type ConfigRule, type ConfigRules, SCSS_PACKAGES, UNIAPP_PACKAGE, VUE_PACKAGES, defineConfig, isPkgExists };
34
+ export { type Arrayable, type ConfigExtend, type ConfigExtends, type ConfigOptions, type ConfigOverrides, type ConfigPlugin, type ConfigPlugins, type ConfigPresets, type ConfigRule, type ConfigRules, SCSS_PACKAGES, UNIAPP_PACKAGE, VUE_PACKAGES, buildOverrides, defineConfig, isPkgExists };
package/dist/index.d.ts CHANGED
@@ -13,6 +13,7 @@ type ConfigRule = ConfigRuleSettings<any, object>;
13
13
  interface ConfigRules {
14
14
  [key: string]: ConfigRule;
15
15
  }
16
+ type ConfigOverrides = Config["overrides"];
16
17
  interface ConfigPresets {
17
18
  scss?: boolean;
18
19
  vue?: boolean;
@@ -22,10 +23,12 @@ interface ConfigOptions extends Config {
22
23
  presets?: ConfigPresets;
23
24
  overrideExtends?: Config["extends"];
24
25
  overridePlugins?: Config["plugins"];
26
+ overrideOverrides?: Config["overrides"];
25
27
  }
26
28
 
29
+ declare function buildOverrides(options: ConfigOptions): ConfigOverrides;
27
30
  declare function defineConfig(options?: ConfigOptions): Config;
28
31
 
29
32
  declare function isPkgExists(pkg: Arrayable<string>): boolean;
30
33
 
31
- export { type Arrayable, type ConfigExtend, type ConfigExtends, type ConfigOptions, type ConfigPlugin, type ConfigPlugins, type ConfigPresets, type ConfigRule, type ConfigRules, SCSS_PACKAGES, UNIAPP_PACKAGE, VUE_PACKAGES, defineConfig, isPkgExists };
34
+ export { type Arrayable, type ConfigExtend, type ConfigExtends, type ConfigOptions, type ConfigOverrides, type ConfigPlugin, type ConfigPlugins, type ConfigPresets, type ConfigRule, type ConfigRules, SCSS_PACKAGES, UNIAPP_PACKAGE, VUE_PACKAGES, buildOverrides, defineConfig, isPkgExists };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { castArray, merge, omit, isEmpty } from 'lodash-es';
1
+ import { castArray, isEmpty, merge, omit } from 'lodash-es';
2
2
  import { isPackageExists } from 'local-pkg';
3
3
 
4
4
  const SCSS_PACKAGES = [
@@ -109,9 +109,7 @@ function buildRules(options) {
109
109
  }
110
110
  if (enableUniApp) {
111
111
  merge(rules, {
112
- "selector-type-no-unknown": [true, {
113
- ignoreTypes: ["page", "rich-text", "scroll-view"]
114
- }]
112
+ "selector-type-no-unknown": null
115
113
  });
116
114
  }
117
115
  if (!isEmpty(options.rules)) {
@@ -119,6 +117,22 @@ function buildRules(options) {
119
117
  }
120
118
  return rules;
121
119
  }
120
+ function buildOverrides(options) {
121
+ if (!isEmpty(options.overrideOverrides)) {
122
+ return options.overrideOverrides;
123
+ }
124
+ const overrides = [{
125
+ files: ["*.html", "*.vue"],
126
+ customSyntax: "postcss-html"
127
+ }, {
128
+ files: ["*.scss"],
129
+ customSyntax: "postcss-scss"
130
+ }];
131
+ if (!isEmpty(options.overrides)) {
132
+ overrides.push(...castArray(options.overrides));
133
+ }
134
+ return overrides;
135
+ }
122
136
  function defineConfig(options = {}) {
123
137
  const presets = merge({
124
138
  scss: isPkgExists(SCSS_PACKAGES),
@@ -136,12 +150,14 @@ function defineConfig(options = {}) {
136
150
  extends: buildExtends(finalOptions),
137
151
  plugins: buildPlugins(finalOptions),
138
152
  rules: buildRules(finalOptions),
153
+ overrides: buildOverrides(finalOptions),
139
154
  ...omit(options, [
140
155
  "extends",
141
156
  "plugins",
142
- "rules"
157
+ "rules",
158
+ "overrides"
143
159
  ])
144
160
  };
145
161
  }
146
162
 
147
- export { SCSS_PACKAGES, UNIAPP_PACKAGE, VUE_PACKAGES, defineConfig, isPkgExists };
163
+ export { SCSS_PACKAGES, UNIAPP_PACKAGE, VUE_PACKAGES, buildOverrides, defineConfig, isPkgExists };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@xiaohe01/stylelint-config",
3
3
  "type": "module",
4
- "version": "0.0.1",
4
+ "version": "0.0.2",
5
5
  "description": "🤚 Stylelint config preset for xiaohe",
6
6
  "author": "xiaohe0601 <xiaohe0601@outlook.com>",
7
7
  "license": "MIT",
@@ -40,6 +40,8 @@
40
40
  "dependencies": {
41
41
  "local-pkg": "^0.5.0",
42
42
  "lodash-es": "^4.17.21",
43
+ "postcss-html": "^1.7.0",
44
+ "postcss-scss": "^4.0.9",
43
45
  "stylelint-config-html": "^1.1.0",
44
46
  "stylelint-config-recess-order": "^5.1.1",
45
47
  "stylelint-config-recommended": "^14.0.1",