@averay/codeformat 0.2.9 → 0.2.11

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.
Files changed (50) hide show
  1. package/README.md +12 -2
  2. package/dist/bin/tools/knip.js +3 -2
  3. package/dist/bin/tools/knip.js.map +1 -1
  4. package/dist/rulesets/eslint/ruleset-shared.d.ts +1 -1
  5. package/dist/rulesets/eslint/ruleset-shared.js +1 -2
  6. package/dist/rulesets/eslint/ruleset-shared.js.map +1 -1
  7. package/dist/src/index.d.ts +1 -0
  8. package/dist/src/index.js +1 -0
  9. package/dist/src/index.js.map +1 -1
  10. package/dist/src/makePrettierConfig.d.ts +12 -0
  11. package/dist/src/makePrettierConfig.js +24 -0
  12. package/dist/src/makePrettierConfig.js.map +1 -0
  13. package/package.json +13 -11
  14. package/.php-cs-fixer.cache +0 -1
  15. package/.php-cs-fixer.php +0 -9
  16. package/.prettierrc.json +0 -8
  17. package/.stylelintignore +0 -3
  18. package/CODE_OF_CONDUCT.md +0 -83
  19. package/bin/codeformat.ts +0 -27
  20. package/bin/tools/eslint.ts +0 -17
  21. package/bin/tools/index.ts +0 -6
  22. package/bin/tools/knip.ts +0 -21
  23. package/bin/tools/phpCsFixer.ts +0 -16
  24. package/bin/tools/prettier.ts +0 -20
  25. package/bin/tools/stylelint.ts +0 -16
  26. package/bin/tools/tsc.ts +0 -12
  27. package/bin/utils/Cli.ts +0 -80
  28. package/bin/utils/Output.ts +0 -30
  29. package/bin/utils/ToolRunner.ts +0 -64
  30. package/bin/utils/filesystem.ts +0 -22
  31. package/bin/utils/runners.ts +0 -10
  32. package/bin/utils/types.ts +0 -24
  33. package/composer.json +0 -6
  34. package/composer.lock +0 -3507
  35. package/eslint.config.js +0 -34
  36. package/knip.config.ts +0 -18
  37. package/lib/convertWarnsToErrors.ts +0 -43
  38. package/lib/cssPatterns.ts +0 -20
  39. package/rulesets/eslint/ruleset-shared.ts +0 -362
  40. package/rulesets/eslint/ruleset-typescript.ts +0 -239
  41. package/rulesets/php/ruleset-php-cs-fixer.php +0 -93
  42. package/rulesets/stylelint/ruleset-css.ts +0 -39
  43. package/rulesets/stylelint/ruleset-scss.ts +0 -47
  44. package/src/extensions.ts +0 -7
  45. package/src/index.ts +0 -4
  46. package/src/makeEslintConfig.ts +0 -97
  47. package/src/makeStylelintConfig.ts +0 -46
  48. package/stylelint.config.js +0 -7
  49. package/tsconfig.build.json +0 -13
  50. /package/{src → dist/src}/php/PhpCsFixerConfig.php +0 -0
@@ -1,64 +0,0 @@
1
- import type Cli from './Cli.ts';
2
- import { findFirstFile } from './filesystem.ts';
3
- import type { Tool, ToolAction } from './types.ts';
4
-
5
- export default class ToolRunner<TToolName extends string> {
6
- constructor(
7
- private readonly cli: Cli,
8
- private readonly tools: Record<TToolName, Tool>,
9
- ) {}
10
-
11
- public async run(action: ToolAction, toolName?: string): Promise<void> {
12
- // Run single tool
13
- if (toolName != null) {
14
- const tool = (this.tools as Record<string, Tool>)[toolName];
15
- if (tool == null) {
16
- this.cli.output.error(`Unknown tool "${toolName}".`);
17
- }
18
- return this.runTool(toolName as TToolName, tool, action);
19
- }
20
-
21
- // Run all tools
22
- for (const [thisToolName, thisTool] of Object.entries(this.tools) as [TToolName, Tool][]) {
23
- // eslint-disable-next-line no-await-in-loop -- Must be run in series
24
- await this.runTool(thisToolName, thisTool, action);
25
- }
26
- }
27
-
28
- private loadConfigPath(toolName: TToolName, configFiles: string[]): string | undefined {
29
- const filePath = findFirstFile(this.cli.directory, configFiles);
30
- if (filePath == null) {
31
- this.cli.output.debug(`Could not find config file for tool "${toolName}".`);
32
- return undefined;
33
- }
34
-
35
- this.cli.output.debug('Found config file:', [filePath]);
36
- return filePath;
37
- }
38
-
39
- private async runTool(
40
- toolName: TToolName,
41
- { command, exec, actions, args: additionalArgs = {}, env, configFiles }: Tool,
42
- action: ToolAction,
43
- ): Promise<void> {
44
- const configPath = this.loadConfigPath(toolName, configFiles);
45
- if (configPath == null) {
46
- return;
47
- }
48
-
49
- const actionArgs = actions(configPath)[action];
50
- if (actionArgs == null) {
51
- return;
52
- }
53
-
54
- const args = [...actionArgs];
55
- if (this.cli.options.debug) {
56
- args.push(...(additionalArgs.debug ?? []));
57
- }
58
- if (this.cli.options.cache) {
59
- const toolCacheDir = `${this.cli.options.cacheDir}/${toolName}`;
60
- args.push(...(additionalArgs.cache?.(toolCacheDir) ?? []));
61
- }
62
- await exec(this.cli, { command, args, env });
63
- }
64
- }
@@ -1,22 +0,0 @@
1
- import { existsSync } from 'node:fs';
2
- import path from 'node:path';
3
-
4
- export const commonExts = {
5
- js: ['js', 'mjs', 'cjs'],
6
- ts: ['ts', 'mts', 'cts'],
7
- yaml: ['yaml', 'yml'],
8
- };
9
-
10
- export function withExts(base: string, exts: string[]): string[] {
11
- return exts.map((ext) => `${base}.${ext}`);
12
- }
13
-
14
- export function findFirstFile(root: string, suffixes: string[]): string | undefined {
15
- for (const suffix of suffixes) {
16
- const filePath = path.join(root, suffix);
17
- if (existsSync(filePath)) {
18
- return path.isAbsolute(root) ? path.relative(root, filePath) : filePath;
19
- }
20
- }
21
- return undefined;
22
- }
@@ -1,10 +0,0 @@
1
- import type { ToolExec } from './types.ts';
2
-
3
- export default {
4
- async bun(cli, { command, args, env = {} }) {
5
- return cli.runSubprocess(['bun', '--bun', 'x', command, ...args], env);
6
- },
7
- async composer(cli, { command, args, env = {} }) {
8
- return cli.runSubprocess(['composer', 'exec', command, '--', ...args], env);
9
- },
10
- } satisfies Record<string, ToolExec>;
@@ -1,24 +0,0 @@
1
- import type Cli from './Cli.ts';
2
-
3
- // Must be exported as `tsc` fails with "Default export of the module has or is using private name" error if not
4
- export interface Command {
5
- command: string;
6
- args: string[];
7
- env?: Record<string, string>;
8
- }
9
-
10
- export type ToolExec = (cli: Cli, command: Command) => Promise<void>;
11
-
12
- export type ToolAction = 'check' | 'fix';
13
-
14
- export interface Tool {
15
- exec: ToolExec;
16
- command: string;
17
- actions: (configPath: string) => Partial<Record<ToolAction, string[]>>;
18
- args?: Partial<{
19
- debug: string[];
20
- cache: (cacheDir: string) => string[];
21
- }>;
22
- env?: Command['env'];
23
- configFiles: string[];
24
- }
package/composer.json DELETED
@@ -1,6 +0,0 @@
1
- {
2
- "require-dev": {
3
- "friendsofphp/php-cs-fixer": "^3.82",
4
- "roave/security-advisories": "dev-latest"
5
- }
6
- }