@bhsd/common 0.9.5 → 0.10.1

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,7 @@ import type { PublicApi, Warning } from 'stylelint';
4
4
  * @param stylelint Stylelint实例
5
5
  * @param code CSS代码
6
6
  * @param additionalRules 额外的规则
7
+ * @param fix 是否修正
7
8
  */
8
- export declare const styleLint: (stylelint: PublicApi, code: string, additionalRules?: Record<string, unknown>) => Promise<Warning[]>;
9
+ export declare function styleLint(stylelint: PublicApi, code: string, additionalRules?: Record<string, unknown>, fix: true): Promise<string>;
10
+ export declare function styleLint(stylelint: PublicApi, code: string, additionalRules?: Record<string, unknown>): Promise<Warning[]>;
package/dist/stylelint.js CHANGED
@@ -22,10 +22,14 @@ __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
+ async function styleLint(stylelint, code, additionalRules, fix) {
26
26
  const config = {
27
- rules: { ...import_stylelint_config_recommended.rules, ...additionalRules }
27
+ rules: { ...import_stylelint_config_recommended.rules, ...additionalRules },
28
+ computeEditInfo: true,
29
+ fix: fix || false
28
30
  };
29
- delete config.rules["selector-type-no-unknown"];
31
+ if (fix) {
32
+ return (await stylelint.lint({ code, config })).code;
33
+ }
30
34
  return (await stylelint.lint({ code, config })).results.flatMap(({ warnings }) => warnings).filter(({ text }) => !text.startsWith("Unknown rule "));
31
- };
35
+ }
@@ -1,11 +1,15 @@
1
1
  import { rules } from "stylelint-config-recommended";
2
- const styleLint = async (stylelint, code, additionalRules) => {
2
+ async function styleLint(stylelint, code, additionalRules, fix) {
3
3
  const config = {
4
- rules: { ...rules, ...additionalRules }
4
+ rules: { ...rules, ...additionalRules },
5
+ computeEditInfo: true,
6
+ fix: fix || false
5
7
  };
6
- delete config.rules["selector-type-no-unknown"];
8
+ if (fix) {
9
+ return (await stylelint.lint({ code, config })).code;
10
+ }
7
11
  return (await stylelint.lint({ code, config })).results.flatMap(({ warnings }) => warnings).filter(({ text }) => !text.startsWith("Unknown rule "));
8
- };
12
+ }
9
13
  export {
10
14
  styleLint
11
15
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bhsd/common",
3
- "version": "0.9.5",
3
+ "version": "0.10.1",
4
4
  "license": "MIT",
5
5
  "author": "Bhsd",
6
6
  "files": [
@@ -63,6 +63,6 @@
63
63
  "mocha": "^11.1.0",
64
64
  "stylelint": "^16.19.1",
65
65
  "typescript": "^5.8.2",
66
- "wikiparser-node": "^1.20.2"
66
+ "wikiparser-node": "^1.20.3"
67
67
  }
68
68
  }