@bhsd/common 0.9.5 → 0.10.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.
@@ -4,5 +4,6 @@ import type { PublicApi, Warning } from 'stylelint';
4
4
  * @param stylelint Stylelint实例
5
5
  * @param code CSS代码
6
6
  * @param additionalRules 额外的规则
7
+ * @param browser 是否为浏览器环境
7
8
  */
8
- export declare const styleLint: (stylelint: PublicApi, code: string, additionalRules?: Record<string, unknown>) => Promise<Warning[]>;
9
+ export declare const styleLint: (stylelint: PublicApi, code: string, additionalRules?: Record<string, unknown>, browser?: boolean) => Promise<Warning[]>;
package/dist/stylelint.js CHANGED
@@ -22,10 +22,12 @@ __export(stylelint_exports, {
22
22
  });
23
23
  module.exports = __toCommonJS(stylelint_exports);
24
24
  var import_stylelint_config_recommended = require("stylelint-config-recommended");
25
- const styleLint = async (stylelint, code, additionalRules) => {
25
+ const styleLint = async (stylelint, code, additionalRules, browser) => {
26
26
  const config = {
27
27
  rules: { ...import_stylelint_config_recommended.rules, ...additionalRules }
28
28
  };
29
- delete config.rules["selector-type-no-unknown"];
29
+ if (browser) {
30
+ delete config.rules["selector-type-no-unknown"];
31
+ }
30
32
  return (await stylelint.lint({ code, config })).results.flatMap(({ warnings }) => warnings).filter(({ text }) => !text.startsWith("Unknown rule "));
31
33
  };
@@ -1,9 +1,11 @@
1
1
  import { rules } from "stylelint-config-recommended";
2
- const styleLint = async (stylelint, code, additionalRules) => {
2
+ const styleLint = async (stylelint, code, additionalRules, browser) => {
3
3
  const config = {
4
4
  rules: { ...rules, ...additionalRules }
5
5
  };
6
- delete config.rules["selector-type-no-unknown"];
6
+ if (browser) {
7
+ delete config.rules["selector-type-no-unknown"];
8
+ }
7
9
  return (await stylelint.lint({ code, config })).results.flatMap(({ warnings }) => warnings).filter(({ text }) => !text.startsWith("Unknown rule "));
8
10
  };
9
11
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bhsd/common",
3
- "version": "0.9.5",
3
+ "version": "0.10.0",
4
4
  "license": "MIT",
5
5
  "author": "Bhsd",
6
6
  "files": [