@averay/codeformat 0.2.2 → 0.2.3
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/dist/bin/codeformat.d.ts +2 -0
- package/dist/bin/codeformat.js +22 -0
- package/dist/bin/codeformat.js.map +1 -0
- package/dist/bin/tools/eslint.d.ts +13 -0
- package/dist/bin/tools/eslint.js +15 -0
- package/dist/bin/tools/eslint.js.map +1 -0
- package/dist/bin/tools/index.d.ts +5 -0
- package/dist/bin/tools/index.js +6 -0
- package/dist/bin/tools/index.js.map +1 -0
- package/dist/bin/tools/phpCsFixer.d.ts +16 -0
- package/dist/bin/tools/phpCsFixer.js +16 -0
- package/dist/bin/tools/phpCsFixer.js.map +1 -0
- package/dist/bin/tools/prettier.d.ts +13 -0
- package/dist/bin/tools/prettier.js +19 -0
- package/dist/bin/tools/prettier.js.map +1 -0
- package/dist/bin/tools/stylelint.d.ts +13 -0
- package/dist/bin/tools/stylelint.js +15 -0
- package/dist/bin/tools/stylelint.js.map +1 -0
- package/dist/bin/tools/tsc.d.ts +10 -0
- package/dist/bin/tools/tsc.js +11 -0
- package/dist/bin/tools/tsc.js.map +1 -0
- package/dist/bin/utils/Cli.d.ts +20 -0
- package/dist/bin/utils/Cli.js +58 -0
- package/dist/bin/utils/Cli.js.map +1 -0
- package/dist/bin/utils/Output.d.ts +9 -0
- package/dist/bin/utils/Output.js +29 -0
- package/dist/bin/utils/Output.js.map +1 -0
- package/dist/bin/utils/ToolRunner.d.ts +10 -0
- package/dist/bin/utils/ToolRunner.js +49 -0
- package/dist/bin/utils/ToolRunner.js.map +1 -0
- package/dist/bin/utils/filesystem.d.ts +2 -0
- package/dist/bin/utils/filesystem.js +15 -0
- package/dist/bin/utils/filesystem.js.map +1 -0
- package/dist/bin/utils/runners.d.ts +5 -0
- package/dist/bin/utils/runners.js +9 -0
- package/dist/bin/utils/runners.js.map +1 -0
- package/dist/bin/utils/types.d.ts +18 -0
- package/dist/bin/utils/types.js +2 -0
- package/dist/bin/utils/types.js.map +1 -0
- package/dist/lib/convertWarnsToErrors.d.ts +22 -0
- package/dist/lib/convertWarnsToErrors.js +34 -0
- package/dist/lib/convertWarnsToErrors.js.map +1 -0
- package/dist/lib/cssPatterns.d.ts +8 -0
- package/dist/lib/cssPatterns.js +17 -0
- package/dist/lib/cssPatterns.js.map +1 -0
- package/dist/rulesets/eslint/ruleset-shared.d.ts +356 -0
- package/dist/rulesets/eslint/ruleset-shared.js +340 -0
- package/dist/rulesets/eslint/ruleset-shared.js.map +1 -0
- package/dist/rulesets/eslint/ruleset-typescript.d.ts +5 -0
- package/dist/rulesets/eslint/ruleset-typescript.js +232 -0
- package/dist/rulesets/eslint/ruleset-typescript.js.map +1 -0
- package/dist/rulesets/stylelint/ruleset-css.d.ts +20 -0
- package/dist/rulesets/stylelint/ruleset-css.js +34 -0
- package/dist/rulesets/stylelint/ruleset-css.js.map +1 -0
- package/dist/rulesets/stylelint/ruleset-scss.d.ts +27 -0
- package/dist/rulesets/stylelint/ruleset-scss.js +42 -0
- package/dist/rulesets/stylelint/ruleset-scss.js.map +1 -0
- package/dist/src/extensions.d.ts +7 -0
- package/dist/src/extensions.js +7 -0
- package/dist/src/extensions.js.map +1 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.js +5 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/makeEslintConfig.d.ts +13 -0
- package/dist/src/makeEslintConfig.js +80 -0
- package/dist/src/makeEslintConfig.js.map +1 -0
- package/dist/src/makeStylelintConfig.d.ts +64 -0
- package/dist/src/makeStylelintConfig.js +39 -0
- package/dist/src/makeStylelintConfig.js.map +1 -0
- package/lib/cssPatterns.ts +15 -2
- package/package.json +17 -12
- package/rulesets/stylelint/ruleset-css.ts +1 -0
- package/rulesets/stylelint/ruleset-scss.ts +20 -5
- package/src/makeStylelintConfig.ts +2 -1
- package/tsconfig.build.json +13 -0
- package/tsconfig.json +1 -0
- package/types.d.ts +6 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
import { eslint, phpCsFixer, prettier, stylelint, tsc } from "./tools/index.js";
|
|
3
|
+
import Cli from "./utils/Cli.js";
|
|
4
|
+
import ToolRunner from "./utils/ToolRunner.js";
|
|
5
|
+
const { cli, selectedAction, selectedTool } = Cli.createFromArgs(Bun.argv);
|
|
6
|
+
const runner = new ToolRunner(cli, {
|
|
7
|
+
// Common
|
|
8
|
+
prettier,
|
|
9
|
+
// JavaScript/TypeScript
|
|
10
|
+
tsc,
|
|
11
|
+
eslint,
|
|
12
|
+
// Other languages
|
|
13
|
+
stylelint,
|
|
14
|
+
phpCsFixer,
|
|
15
|
+
});
|
|
16
|
+
try {
|
|
17
|
+
await runner.run(selectedAction, selectedTool);
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
cli.output.error('Error:', [error]);
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=codeformat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codeformat.js","sourceRoot":"","sources":["../../bin/codeformat.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAChF,OAAO,GAAG,MAAM,gBAAgB,CAAC;AACjC,OAAO,UAAU,MAAM,uBAAuB,CAAC;AAE/C,MAAM,EAAE,GAAG,EAAE,cAAc,EAAE,YAAY,EAAE,GAAG,GAAG,CAAC,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAE3E,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,GAAG,EAAE;IACjC,SAAS;IACT,QAAQ;IAER,wBAAwB;IACxB,GAAG;IACH,MAAM;IAEN,kBAAkB;IAClB,SAAS;IACT,UAAU;CACX,CAAC,CAAC;AAEH,IAAI,CAAC;IACH,MAAM,MAAM,CAAC,GAAG,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC;AACjD,CAAC;AAAC,OAAO,KAAK,EAAE,CAAC;IACf,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
exec: (cli: import("../utils/Cli.ts").default, { command, args, env }: import("../utils/types.ts").Command) => Promise<void>;
|
|
3
|
+
command: string;
|
|
4
|
+
actions: (configPath: string) => {
|
|
5
|
+
check: string[];
|
|
6
|
+
fix: string[];
|
|
7
|
+
};
|
|
8
|
+
args: {
|
|
9
|
+
debug: string[];
|
|
10
|
+
};
|
|
11
|
+
configFiles: string[];
|
|
12
|
+
};
|
|
13
|
+
export default _default;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { withExts } from "../utils/filesystem.js";
|
|
2
|
+
import runners from "../utils/runners.js";
|
|
3
|
+
export default {
|
|
4
|
+
exec: runners.bun,
|
|
5
|
+
command: 'eslint',
|
|
6
|
+
actions: (configPath) => ({
|
|
7
|
+
check: ['--config', configPath, '.'],
|
|
8
|
+
fix: ['--fix', '--config', configPath, '.'],
|
|
9
|
+
}),
|
|
10
|
+
args: {
|
|
11
|
+
debug: ['-vvv'],
|
|
12
|
+
},
|
|
13
|
+
configFiles: withExts('eslint.config', ['js', 'mjs', 'cjs', 'ts', 'mts', 'cts']),
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=eslint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eslint.js","sourceRoot":"","sources":["../../../bin/tools/eslint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,OAAO,MAAM,qBAAqB,CAAC;AAG1C,eAAe;IACb,IAAI,EAAE,OAAO,CAAC,GAAG;IACjB,OAAO,EAAE,QAAQ;IACjB,OAAO,EAAE,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;QACxB,KAAK,EAAE,CAAC,UAAU,EAAE,UAAU,EAAE,GAAG,CAAC;QACpC,GAAG,EAAE,CAAC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,CAAC;KAC5C,CAAC;IACF,IAAI,EAAE;QACJ,KAAK,EAAE,CAAC,MAAM,CAAC;KAChB;IACD,WAAW,EAAE,QAAQ,CAAC,eAAe,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;CAClE,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as eslint } from "./eslint.js";
|
|
2
|
+
export { default as phpCsFixer } from "./phpCsFixer.js";
|
|
3
|
+
export { default as prettier } from "./prettier.js";
|
|
4
|
+
export { default as stylelint } from "./stylelint.js";
|
|
5
|
+
export { default as tsc } from "./tsc.js";
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../bin/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
exec: (cli: import("../utils/Cli.ts").default, { command, args, env }: import("../utils/types.ts").Command) => Promise<void>;
|
|
3
|
+
command: string;
|
|
4
|
+
actions: (configPath: string) => {
|
|
5
|
+
check: string[];
|
|
6
|
+
fix: string[];
|
|
7
|
+
};
|
|
8
|
+
args: {
|
|
9
|
+
debug: string[];
|
|
10
|
+
};
|
|
11
|
+
env: {
|
|
12
|
+
PHP_CS_FIXER_IGNORE_ENV: string;
|
|
13
|
+
};
|
|
14
|
+
configFiles: string[];
|
|
15
|
+
};
|
|
16
|
+
export default _default;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { withExts } from "../utils/filesystem.js";
|
|
2
|
+
import runners from "../utils/runners.js";
|
|
3
|
+
export default {
|
|
4
|
+
exec: runners.composer,
|
|
5
|
+
command: 'php-cs-fixer',
|
|
6
|
+
actions: (configPath) => ({
|
|
7
|
+
check: ['check', '--config', configPath, '-vv'],
|
|
8
|
+
fix: ['fix', '--config', configPath, '-vv'],
|
|
9
|
+
}),
|
|
10
|
+
args: {
|
|
11
|
+
debug: ['--verbose'],
|
|
12
|
+
},
|
|
13
|
+
env: { PHP_CS_FIXER_IGNORE_ENV: '1' },
|
|
14
|
+
configFiles: withExts('.php-cs-fixer', ['dist.php', 'php']),
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=phpCsFixer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phpCsFixer.js","sourceRoot":"","sources":["../../../bin/tools/phpCsFixer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,OAAO,MAAM,qBAAqB,CAAC;AAG1C,eAAe;IACb,IAAI,EAAE,OAAO,CAAC,QAAQ;IACtB,OAAO,EAAE,cAAc;IACvB,OAAO,EAAE,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;QACxB,KAAK,EAAE,CAAC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,KAAK,CAAC;QAC/C,GAAG,EAAE,CAAC,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,KAAK,CAAC;KAC5C,CAAC;IACF,IAAI,EAAE;QACJ,KAAK,EAAE,CAAC,WAAW,CAAC;KACrB;IACD,GAAG,EAAE,EAAE,uBAAuB,EAAE,GAAG,EAAE;IACrC,WAAW,EAAE,QAAQ,CAAC,eAAe,EAAE,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;CAC7C,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
exec: (cli: import("../utils/Cli.ts").default, { command, args, env }: import("../utils/types.ts").Command) => Promise<void>;
|
|
3
|
+
command: string;
|
|
4
|
+
actions: (configPath: string) => {
|
|
5
|
+
check: string[];
|
|
6
|
+
fix: string[];
|
|
7
|
+
};
|
|
8
|
+
args: {
|
|
9
|
+
debug: string[];
|
|
10
|
+
};
|
|
11
|
+
configFiles: string[];
|
|
12
|
+
};
|
|
13
|
+
export default _default;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { withExts } from "../utils/filesystem.js";
|
|
2
|
+
import runners from "../utils/runners.js";
|
|
3
|
+
export default {
|
|
4
|
+
exec: runners.bun,
|
|
5
|
+
command: 'prettier',
|
|
6
|
+
actions: (configPath) => ({
|
|
7
|
+
check: ['--check', '--config', configPath, '.'],
|
|
8
|
+
fix: ['--write', '--config', configPath, '.'],
|
|
9
|
+
}),
|
|
10
|
+
args: {
|
|
11
|
+
debug: ['--log-level', 'debug'],
|
|
12
|
+
},
|
|
13
|
+
configFiles: [
|
|
14
|
+
'.prettierrc',
|
|
15
|
+
...withExts('prettier.config', ['js', 'ts', 'mjs', 'mts', 'cjs', 'cts']),
|
|
16
|
+
...withExts('.prettierrc', ['json', 'yml', 'yaml', 'json5', 'js', 'ts', 'mjs', 'mts', 'cjs', 'cts', 'toml']),
|
|
17
|
+
],
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=prettier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prettier.js","sourceRoot":"","sources":["../../../bin/tools/prettier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,OAAO,MAAM,qBAAqB,CAAC;AAG1C,eAAe;IACb,IAAI,EAAE,OAAO,CAAC,GAAG;IACjB,OAAO,EAAE,UAAU;IACnB,OAAO,EAAE,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;QACxB,KAAK,EAAE,CAAC,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,CAAC;QAC/C,GAAG,EAAE,CAAC,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,CAAC;KAC9C,CAAC;IACF,IAAI,EAAE;QACJ,KAAK,EAAE,CAAC,aAAa,EAAE,OAAO,CAAC;KAChC;IACD,WAAW,EAAE;QACX,aAAa;QACb,GAAG,QAAQ,CAAC,iBAAiB,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;QACxE,GAAG,QAAQ,CAAC,aAAa,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;KAC7G;CACa,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
exec: (cli: import("../utils/Cli.ts").default, { command, args, env }: import("../utils/types.ts").Command) => Promise<void>;
|
|
3
|
+
command: string;
|
|
4
|
+
actions: (configPath: string) => {
|
|
5
|
+
check: string[];
|
|
6
|
+
fix: string[];
|
|
7
|
+
};
|
|
8
|
+
args: {
|
|
9
|
+
debug: string[];
|
|
10
|
+
};
|
|
11
|
+
configFiles: string[];
|
|
12
|
+
};
|
|
13
|
+
export default _default;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { withExts } from "../utils/filesystem.js";
|
|
2
|
+
import runners from "../utils/runners.js";
|
|
3
|
+
export default {
|
|
4
|
+
exec: runners.bun,
|
|
5
|
+
command: 'stylelint',
|
|
6
|
+
actions: (configPath) => ({
|
|
7
|
+
check: ['--allow-empty-input', '--config', configPath, `**/*.{css,sass,scss}`],
|
|
8
|
+
fix: ['--fix', '--allow-empty-input', '--config', configPath, `**/*.{css,sass,scss}`],
|
|
9
|
+
}),
|
|
10
|
+
args: {
|
|
11
|
+
debug: ['--formatter', 'verbose'],
|
|
12
|
+
},
|
|
13
|
+
configFiles: withExts('stylelint.config', ['cjs', 'mjs', 'js']),
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=stylelint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stylelint.js","sourceRoot":"","sources":["../../../bin/tools/stylelint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,OAAO,MAAM,qBAAqB,CAAC;AAG1C,eAAe;IACb,IAAI,EAAE,OAAO,CAAC,GAAG;IACjB,OAAO,EAAE,WAAW;IACpB,OAAO,EAAE,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;QACxB,KAAK,EAAE,CAAC,qBAAqB,EAAE,UAAU,EAAE,UAAU,EAAE,sBAAsB,CAAC;QAC9E,GAAG,EAAE,CAAC,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,UAAU,EAAE,sBAAsB,CAAC;KACtF,CAAC;IACF,IAAI,EAAE;QACJ,KAAK,EAAE,CAAC,aAAa,EAAE,SAAS,CAAC;KAClC;IACD,WAAW,EAAE,QAAQ,CAAC,kBAAkB,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;CACjD,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
exec: (cli: import("../utils/Cli.ts").default, { command, args, env }: import("../utils/types.ts").Command) => Promise<void>;
|
|
3
|
+
command: string;
|
|
4
|
+
actions: (configPath: string) => {
|
|
5
|
+
check: string[];
|
|
6
|
+
fix: string[];
|
|
7
|
+
};
|
|
8
|
+
configFiles: string[];
|
|
9
|
+
};
|
|
10
|
+
export default _default;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import runners from "../utils/runners.js";
|
|
2
|
+
export default {
|
|
3
|
+
exec: runners.bun,
|
|
4
|
+
command: 'tsc',
|
|
5
|
+
actions: (configPath) => ({
|
|
6
|
+
check: ['--noEmit', '--project', configPath],
|
|
7
|
+
fix: ['--project', configPath],
|
|
8
|
+
}),
|
|
9
|
+
configFiles: ['tsconfig.json'],
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=tsc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tsc.js","sourceRoot":"","sources":["../../../bin/tools/tsc.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,qBAAqB,CAAC;AAG1C,eAAe;IACb,IAAI,EAAE,OAAO,CAAC,GAAG;IACjB,OAAO,EAAE,KAAK;IACd,OAAO,EAAE,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;QACxB,KAAK,EAAE,CAAC,UAAU,EAAE,WAAW,EAAE,UAAU,CAAC;QAC5C,GAAG,EAAE,CAAC,WAAW,EAAE,UAAU,CAAC;KAC/B,CAAC;IACF,WAAW,EAAE,CAAC,eAAe,CAAC;CAChB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import Output from './Output.ts';
|
|
2
|
+
import { type ToolAction } from './types.ts';
|
|
3
|
+
interface Flags {
|
|
4
|
+
verbose: boolean;
|
|
5
|
+
debug: boolean;
|
|
6
|
+
help: boolean;
|
|
7
|
+
}
|
|
8
|
+
export default class Cli {
|
|
9
|
+
readonly directory: string;
|
|
10
|
+
readonly options: Flags;
|
|
11
|
+
readonly output: Output;
|
|
12
|
+
constructor(scriptName: string, directory: string, options: Flags);
|
|
13
|
+
runSubprocess(args: string[], env?: Record<string, string>): Promise<void>;
|
|
14
|
+
static createFromArgs(argv: string[]): {
|
|
15
|
+
cli: Cli;
|
|
16
|
+
selectedAction: ToolAction;
|
|
17
|
+
selectedTool?: string;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { parseArgs } from 'node:util';
|
|
2
|
+
import { spawn } from 'bun';
|
|
3
|
+
import Output from "./Output.js";
|
|
4
|
+
export default class Cli {
|
|
5
|
+
directory;
|
|
6
|
+
options;
|
|
7
|
+
output;
|
|
8
|
+
constructor(scriptName, directory, options) {
|
|
9
|
+
this.directory = directory;
|
|
10
|
+
this.options = options;
|
|
11
|
+
this.output = new Output(scriptName, options);
|
|
12
|
+
}
|
|
13
|
+
async runSubprocess(args, env = {}) {
|
|
14
|
+
this.output.verbose('Running command:', args);
|
|
15
|
+
const proc = spawn(args, {
|
|
16
|
+
env: { ...process.env, ...env },
|
|
17
|
+
cwd: this.directory,
|
|
18
|
+
stdio: ['inherit', 'inherit', 'inherit'],
|
|
19
|
+
});
|
|
20
|
+
const exitCode = await proc.exited;
|
|
21
|
+
if (exitCode !== 0) {
|
|
22
|
+
process.exit(exitCode);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
static createFromArgs(argv) {
|
|
26
|
+
// Parse input
|
|
27
|
+
const { values: options, positionals } = parseArgs({
|
|
28
|
+
args: argv,
|
|
29
|
+
options: {
|
|
30
|
+
dir: { type: 'string', short: 'd', default: process.cwd() },
|
|
31
|
+
tool: { type: 'string', short: 't', default: undefined },
|
|
32
|
+
verbose: { type: 'boolean', default: false },
|
|
33
|
+
debug: { type: 'boolean', default: false },
|
|
34
|
+
help: { type: 'boolean', default: false },
|
|
35
|
+
},
|
|
36
|
+
strict: true,
|
|
37
|
+
allowPositionals: true,
|
|
38
|
+
});
|
|
39
|
+
const { dir, tool, ...flags } = options;
|
|
40
|
+
const [, scriptName, selectedAction, ...undefinedArgs] = positionals;
|
|
41
|
+
const cli = new Cli(scriptName, dir, flags);
|
|
42
|
+
if (options.help || selectedAction == null) {
|
|
43
|
+
cli.output.usage();
|
|
44
|
+
}
|
|
45
|
+
if (undefinedArgs.length > 0) {
|
|
46
|
+
cli.output.error('Unexpected additional arguments.', [undefinedArgs]);
|
|
47
|
+
}
|
|
48
|
+
if (!['check', 'fix'].includes(selectedAction)) {
|
|
49
|
+
cli.output.error(`Unknown action "${selectedAction}".`, [undefinedArgs]);
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
cli,
|
|
53
|
+
selectedAction: selectedAction, // Validated above
|
|
54
|
+
selectedTool: tool,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=Cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Cli.js","sourceRoot":"","sources":["../../../bin/utils/Cli.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export default class Output {
|
|
2
|
+
private readonly scriptName;
|
|
3
|
+
private readonly options;
|
|
4
|
+
constructor(scriptName: string, options: Record<'debug' | 'verbose', boolean>);
|
|
5
|
+
usage(exitCode?: number): never;
|
|
6
|
+
debug(message: string, additionalValues?: unknown[]): void;
|
|
7
|
+
verbose(message: string, additionalValues?: unknown[]): void;
|
|
8
|
+
error(message: string, additionalValues?: unknown[], exitCode?: number): never;
|
|
9
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export default class Output {
|
|
2
|
+
scriptName;
|
|
3
|
+
options;
|
|
4
|
+
constructor(scriptName, options) {
|
|
5
|
+
this.scriptName = scriptName;
|
|
6
|
+
this.options = options;
|
|
7
|
+
}
|
|
8
|
+
usage(exitCode = 0) {
|
|
9
|
+
console.error(`Usage:
|
|
10
|
+
${this.scriptName} check [root-path]
|
|
11
|
+
${this.scriptName} fix [root-path]`);
|
|
12
|
+
process.exit(exitCode);
|
|
13
|
+
}
|
|
14
|
+
debug(message, additionalValues = []) {
|
|
15
|
+
if (this.options.debug) {
|
|
16
|
+
console.debug(message, ...additionalValues);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
verbose(message, additionalValues = []) {
|
|
20
|
+
if (this.options.verbose) {
|
|
21
|
+
console.debug(message, ...additionalValues);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
error(message, additionalValues = [], exitCode = 1) {
|
|
25
|
+
console.error(message, ...additionalValues);
|
|
26
|
+
process.exit(exitCode);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=Output.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Output.js","sourceRoot":"","sources":["../../../bin/utils/Output.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,OAAO,MAAM;IAEN;IACA;IAFnB,YACmB,UAAkB,EAClB,OAA6C;QAD7C,eAAU,GAAV,UAAU,CAAQ;QAClB,YAAO,GAAP,OAAO,CAAsC;IAC7D,CAAC;IAEG,KAAK,CAAC,WAAmB,CAAC;QAC/B,OAAO,CAAC,KAAK,CAAC;MACZ,IAAI,CAAC,UAAU;MACf,IAAI,CAAC,UAAU,kBAAkB,CAAC,CAAC;QACrC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACzB,CAAC;IAEM,KAAK,CAAC,OAAe,EAAE,mBAA8B,EAAE;QAC5D,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;YACvB,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,gBAAgB,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC;IAEM,OAAO,CAAC,OAAe,EAAE,mBAA8B,EAAE;QAC9D,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;YACzB,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,gBAAgB,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,OAAe,EAAE,mBAA8B,EAAE,EAAE,WAAmB,CAAC;QAClF,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,gBAAgB,CAAC,CAAC;QAC5C,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACzB,CAAC;CACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type Cli from './Cli.ts';
|
|
2
|
+
import { type Tool, type ToolAction } from './types.ts';
|
|
3
|
+
export default class ToolRunner<TToolName extends string> {
|
|
4
|
+
private readonly cli;
|
|
5
|
+
private readonly tools;
|
|
6
|
+
constructor(cli: Cli, tools: Record<TToolName, Tool>);
|
|
7
|
+
run(action: ToolAction, toolName?: string): Promise<void>;
|
|
8
|
+
private loadConfigPath;
|
|
9
|
+
private runTool;
|
|
10
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { findFirstFile } from "./filesystem.js";
|
|
2
|
+
export default class ToolRunner {
|
|
3
|
+
cli;
|
|
4
|
+
tools;
|
|
5
|
+
constructor(cli, tools) {
|
|
6
|
+
this.cli = cli;
|
|
7
|
+
this.tools = tools;
|
|
8
|
+
}
|
|
9
|
+
async run(action, toolName) {
|
|
10
|
+
// Run single tool
|
|
11
|
+
if (toolName != null) {
|
|
12
|
+
const tool = this.tools[toolName];
|
|
13
|
+
if (tool == null) {
|
|
14
|
+
this.cli.output.error(`Unknown tool "${toolName}".`);
|
|
15
|
+
}
|
|
16
|
+
return this.runTool(toolName, tool, action);
|
|
17
|
+
}
|
|
18
|
+
// Run all tools
|
|
19
|
+
for (const [thisToolName, thisTool] of Object.entries(this.tools)) {
|
|
20
|
+
// eslint-disable-next-line no-await-in-loop -- Must be run in series
|
|
21
|
+
await this.runTool(thisToolName, thisTool, action);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
loadConfigPath(toolName, configFiles) {
|
|
25
|
+
const filePath = findFirstFile(this.cli.directory, configFiles);
|
|
26
|
+
if (filePath == null) {
|
|
27
|
+
this.cli.output.debug(`Could not find config file for tool "${toolName}".`);
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
this.cli.output.debug('Found config file:', [filePath]);
|
|
31
|
+
return filePath;
|
|
32
|
+
}
|
|
33
|
+
async runTool(toolName, { command, exec, actions, args: additionalArgs, env, configFiles }, action) {
|
|
34
|
+
const configPath = this.loadConfigPath(toolName, configFiles);
|
|
35
|
+
if (configPath == null) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const actionArgs = actions(configPath)[action];
|
|
39
|
+
if (actionArgs == null) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
let args = [...actionArgs];
|
|
43
|
+
if (this.cli.options.debug) {
|
|
44
|
+
args = [...args, ...(additionalArgs?.debug ?? [])];
|
|
45
|
+
}
|
|
46
|
+
await exec(this.cli, { command, args, env });
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=ToolRunner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolRunner.js","sourceRoot":"","sources":["../../../bin/utils/ToolRunner.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD,MAAM,CAAC,OAAO,OAAO,UAAU;IAEV;IACA;IAFnB,YACmB,GAAQ,EACR,KAA8B;QAD9B,QAAG,GAAH,GAAG,CAAK;QACR,UAAK,GAAL,KAAK,CAAyB;IAC9C,CAAC;IAEG,KAAK,CAAC,GAAG,CAAC,MAAkB,EAAE,QAAiB;QACpD,kBAAkB;QAClB,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC;YACrB,MAAM,IAAI,GAAI,IAAI,CAAC,KAA8B,CAAC,QAAQ,CAAC,CAAC;YAC5D,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;gBACjB,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,iBAAiB,QAAQ,IAAI,CAAC,CAAC;YACvD,CAAC;YACD,OAAO,IAAI,CAAC,OAAO,CAAC,QAAqB,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QAC3D,CAAC;QAED,gBAAgB;QAChB,KAAK,MAAM,CAAC,YAAY,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAwB,EAAE,CAAC;YACzF,qEAAqE;YACrE,MAAM,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;QACrD,CAAC;IACH,CAAC;IAEO,cAAc,CAAC,QAAmB,EAAE,WAAqB;QAC/D,MAAM,QAAQ,GAAG,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;QAChE,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC;YACrB,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,wCAAwC,QAAQ,IAAI,CAAC,CAAC;YAC5E,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,oBAAoB,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;QACxD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAEO,KAAK,CAAC,OAAO,CACnB,QAAmB,EACnB,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,GAAG,EAAE,WAAW,EAAQ,EACxE,MAAkB;QAElB,MAAM,UAAU,GAAG,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;QAC9D,IAAI,UAAU,IAAI,IAAI,EAAE,CAAC;YACvB,OAAO;QACT,CAAC;QAED,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC;QAC/C,IAAI,UAAU,IAAI,IAAI,EAAE,CAAC;YACvB,OAAO;QACT,CAAC;QAED,IAAI,IAAI,GAAG,CAAC,GAAG,UAAU,CAAC,CAAC;QAC3B,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;YAC3B,IAAI,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,CAAC,cAAc,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC;QACrD,CAAC;QACD,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC;IAC/C,CAAC;CACF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
export function withExts(base, exts) {
|
|
4
|
+
return exts.map((ext) => `${base}.${ext}`);
|
|
5
|
+
}
|
|
6
|
+
export function findFirstFile(root, suffixes) {
|
|
7
|
+
for (const suffix of suffixes) {
|
|
8
|
+
const filePath = path.join(root, suffix);
|
|
9
|
+
if (existsSync(filePath)) {
|
|
10
|
+
return path.isAbsolute(root) ? path.relative(root, filePath) : filePath;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=filesystem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filesystem.js","sourceRoot":"","sources":["../../../bin/utils/filesystem.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,MAAM,UAAU,QAAQ,CAAC,IAAY,EAAE,IAAc;IACnD,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,IAAI,IAAI,GAAG,EAAE,CAAC,CAAC;AAC7C,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,IAAY,EAAE,QAAkB;IAC5D,KAAK,MAAM,MAAM,IAAI,QAAQ,EAAE,CAAC;QAC9B,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACzC,IAAI,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;YACzB,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;QAC1E,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
bun(cli: import("./Cli.ts").default, { command, args, env }: import("./types.ts").Command): Promise<void>;
|
|
3
|
+
composer(cli: import("./Cli.ts").default, { command, args, env }: import("./types.ts").Command): Promise<void>;
|
|
4
|
+
};
|
|
5
|
+
export default _default;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
async bun(cli, { command, args, env = {} }) {
|
|
3
|
+
return cli.runSubprocess(['bun', '--bun', 'x', command, ...args], env);
|
|
4
|
+
},
|
|
5
|
+
async composer(cli, { command, args, env = {} }) {
|
|
6
|
+
return cli.runSubprocess(['composer', 'exec', command, '--', ...args], env);
|
|
7
|
+
},
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=runners.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runners.js","sourceRoot":"","sources":["../../../bin/utils/runners.ts"],"names":[],"mappings":"AAEA,eAAe;IACb,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,GAAG,EAAE,EAAE;QACxC,OAAO,GAAG,CAAC,aAAa,CAAC,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;IACzE,CAAC;IACD,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,GAAG,EAAE,EAAE;QAC7C,OAAO,GAAG,CAAC,aAAa,CAAC,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;IAC9E,CAAC;CACiC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type Cli from './Cli.ts';
|
|
2
|
+
export interface Command {
|
|
3
|
+
command: string;
|
|
4
|
+
args: string[];
|
|
5
|
+
env?: Record<string, string>;
|
|
6
|
+
}
|
|
7
|
+
export type ToolExec = (cli: Cli, command: Command) => Promise<void>;
|
|
8
|
+
export type ToolAction = 'check' | 'fix';
|
|
9
|
+
export interface Tool {
|
|
10
|
+
exec: ToolExec;
|
|
11
|
+
command: string;
|
|
12
|
+
actions: (configPath: string) => Partial<Record<ToolAction, string[]>>;
|
|
13
|
+
args?: Partial<{
|
|
14
|
+
debug: string[];
|
|
15
|
+
}>;
|
|
16
|
+
env?: Command['env'];
|
|
17
|
+
configFiles: string[];
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../bin/utils/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
type Converted<T> = {
|
|
2
|
+
[key in keyof T]: T[key] extends 'warn' | 1 ? 'error' : T[key] extends ['warn' | 1, ...infer Rest] ? ['error', ...Rest] : T[key];
|
|
3
|
+
};
|
|
4
|
+
/**
|
|
5
|
+
* Replaces any `warn` values in the provided object with `error` (including those within arrays with configs), preserving all other values.
|
|
6
|
+
*
|
|
7
|
+
* @param ruleset The original ruleset to process.
|
|
8
|
+
* @returns The processed ruleset with warnings replaced with errors.
|
|
9
|
+
* @example
|
|
10
|
+
* convertWarnsToErrors({
|
|
11
|
+
* rule1: 'warn',
|
|
12
|
+
* rule2: ['warn', { foo: 'bar' }],
|
|
13
|
+
* rule3: 'off',
|
|
14
|
+
* })
|
|
15
|
+
* // {
|
|
16
|
+
* // rule1: 'error',
|
|
17
|
+
* // rule2: ['error', { foo: 'bar' }],
|
|
18
|
+
* // rule3: 'off',
|
|
19
|
+
* // }
|
|
20
|
+
*/
|
|
21
|
+
export default function convertWarnsToErrors<T extends Record<string, unknown>>(ruleset: T): Converted<T>;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const isWarning = (value) => value === 'warn' || value === 1;
|
|
2
|
+
/**
|
|
3
|
+
* Replaces any `warn` values in the provided object with `error` (including those within arrays with configs), preserving all other values.
|
|
4
|
+
*
|
|
5
|
+
* @param ruleset The original ruleset to process.
|
|
6
|
+
* @returns The processed ruleset with warnings replaced with errors.
|
|
7
|
+
* @example
|
|
8
|
+
* convertWarnsToErrors({
|
|
9
|
+
* rule1: 'warn',
|
|
10
|
+
* rule2: ['warn', { foo: 'bar' }],
|
|
11
|
+
* rule3: 'off',
|
|
12
|
+
* })
|
|
13
|
+
* // {
|
|
14
|
+
* // rule1: 'error',
|
|
15
|
+
* // rule2: ['error', { foo: 'bar' }],
|
|
16
|
+
* // rule3: 'off',
|
|
17
|
+
* // }
|
|
18
|
+
*/
|
|
19
|
+
export default function convertWarnsToErrors(ruleset) {
|
|
20
|
+
const rulesetProcessed = {};
|
|
21
|
+
for (const [key, value] of Object.entries(ruleset)) {
|
|
22
|
+
let processedValue;
|
|
23
|
+
if (Array.isArray(value)) {
|
|
24
|
+
processedValue = [...value];
|
|
25
|
+
processedValue[0] = isWarning(processedValue[0]) ? 'error' : processedValue[0];
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
processedValue = isWarning(value) ? 'error' : value;
|
|
29
|
+
}
|
|
30
|
+
rulesetProcessed[key] = processedValue;
|
|
31
|
+
}
|
|
32
|
+
return rulesetProcessed;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=convertWarnsToErrors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convertWarnsToErrors.js","sourceRoot":"","sources":["../../lib/convertWarnsToErrors.ts"],"names":[],"mappings":"AAUA,MAAM,SAAS,GAAG,CAAC,KAAc,EAAuB,EAAE,CAAC,KAAK,KAAK,MAAM,IAAI,KAAK,KAAK,CAAC,CAAC;AAE3F;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAoC,OAAU;IACxF,MAAM,gBAAgB,GAAG,EAAkB,CAAC;IAC5C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAgB,EAAE,CAAC;QAClE,IAAI,cAAc,CAAC;QACnB,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,cAAc,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC;YAC5B,cAAc,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;QACjF,CAAC;aAAM,CAAC;YACN,cAAc,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;QACtD,CAAC;QACD,gBAAgB,CAAC,GAAG,CAAC,GAAG,cAA0C,CAAC;IACrE,CAAC;IACD,OAAO,gBAAgB,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
declare const patterns: {
|
|
2
|
+
readonly bem: string;
|
|
3
|
+
readonly bemWithOptionalSingleUnderscorePrefix: string;
|
|
4
|
+
readonly bemWithOptionalUnderscoresPrefix: string;
|
|
5
|
+
readonly kebab: string;
|
|
6
|
+
};
|
|
7
|
+
export declare function patternOrScssInterpolation(pattern: string): string;
|
|
8
|
+
export default patterns;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/* eslint require-unicode-regexp: 'off' -- Expressions are passed to Stylelint as strings so cannot use any flags in order to match their behaviour. */
|
|
2
|
+
const patterns = {
|
|
3
|
+
bem: /^[a-z]+(?:(?:-|--|__)[a-z]+)*$/.source,
|
|
4
|
+
bemWithOptionalSingleUnderscorePrefix: /^_?[a-z]+(?:(?:-|--|__)[a-z]+)*$/.source,
|
|
5
|
+
bemWithOptionalUnderscoresPrefix: /^(?:__)?[a-z]+(?:(?:-|--|__)[a-z]+)*$/.source,
|
|
6
|
+
kebab: /^[a-z]+(?:-[a-z]+)*$/.source,
|
|
7
|
+
};
|
|
8
|
+
export function patternOrScssInterpolation(pattern) {
|
|
9
|
+
// Remove anchors
|
|
10
|
+
if (!pattern.startsWith('^') || !pattern.endsWith('$')) {
|
|
11
|
+
throw new Error('Pattern must use both start & end anchors.');
|
|
12
|
+
}
|
|
13
|
+
pattern = pattern.slice(1, -1);
|
|
14
|
+
return new RegExp(`^(?:#{[^}]+}|${pattern})$`).source;
|
|
15
|
+
}
|
|
16
|
+
export default patterns;
|
|
17
|
+
//# sourceMappingURL=cssPatterns.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cssPatterns.js","sourceRoot":"","sources":["../../lib/cssPatterns.ts"],"names":[],"mappings":"AAAA,uJAAuJ;AAEvJ,MAAM,QAAQ,GAAG;IACf,GAAG,EAAE,gCAAgC,CAAC,MAAM;IAC5C,qCAAqC,EAAE,kCAAkC,CAAC,MAAM;IAChF,gCAAgC,EAAE,uCAAuC,CAAC,MAAM;IAChF,KAAK,EAAE,sBAAsB,CAAC,MAAM;CACK,CAAC;AAE5C,MAAM,UAAU,0BAA0B,CAAC,OAAe;IACxD,iBAAiB;IACjB,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACvD,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAChE,CAAC;IACD,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAE/B,OAAO,IAAI,MAAM,CAAC,gBAAgB,OAAO,IAAI,CAAC,CAAC,MAAM,CAAC;AACxD,CAAC;AAED,eAAe,QAAQ,CAAC"}
|