@genesislcap/eslint-stylelint-builder 14.441.0 → 14.443.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.
package/README.md CHANGED
@@ -1,7 +1,23 @@
1
- # ESLint & Stylelint builder
1
+ # ESLint, Oxlint, Oxfmt & Stylelint builder
2
2
 
3
- Builder wrapping [ESLint](https://eslint.org/) and [Stylelint](https://stylelint.io/).
3
+ Builder used by **`genx lint`**. It runs **ESLint**, **Prettier**, and **Stylelint** by default (legacy pipeline). Use `-l ox` to opt in to the faster **Oxlint → Oxfmt → Stylelint** pipeline.
4
4
 
5
+ ## Default pipeline (`genx lint` / `npm run lint`)
6
+
7
+ Legacy (backward-compatible):
8
+
9
+ 1. **ESLint** — `eslint "./**/*.{ts,js,tsx,jsx}"`.
10
+ 2. **Prettier** — via `eslint-plugin-prettier`.
11
+ 3. **Stylelint** — `*.styles.ts` under the current working directory.
12
+
13
+ ## Opt-in pipelines
14
+
15
+ - **`-l ox`** — **Oxlint → Oxfmt → Stylelint** (fast; use for day-to-day local linting).
16
+ - **`-l ci`** — **Oxlint → ESLint → Oxfmt → Stylelint** (adds `import/no-extraneous-dependencies` via ESLint; used in CI).
17
+ - **`-l eslint`** — ESLint only (use `--profile` for `TIMING=1` rule timings).
18
+ - **Other flags:** `-l oxfmt`, `-l oxlint`, `-l stylelint`.
19
+
20
+ Configs: [`@genesislcap/oxlint-config`](../oxlint-config/), root **`.oxfmtrc.json`** for Oxfmt, root **`eslint.config.mjs`** (flat config) for ESLint, and **`@genesislcap/stylelint-config`** for Stylelint.
5
21
 
6
22
  ## Installation
7
23
 
@@ -28,4 +44,4 @@ To enable this module in your application, follow the steps below.
28
44
  Note: this project provides front-end dependencies and uses licensed components listed in the next section; thus, licenses for those components are required during development. Contact [Genesis Global](https://genesis.global/contact-us/) for more details.
29
45
 
30
46
  ### Licensed components
31
- Genesis low-code platform
47
+ Genesis low-code platform
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;yBAIrC,KAAK,YAAY;AAAvC,wBAuCE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;yBAuFrC,KAAK,YAAY;AAAvC,wBAyDE"}
package/dist/index.js CHANGED
@@ -1,37 +1,129 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
+ const os_1 = tslib_1.__importDefault(require("os"));
4
5
  const build_kit_1 = require("@genesislcap/build-kit");
5
6
  const consola_1 = tslib_1.__importDefault(require("consola"));
6
- const os_1 = tslib_1.__importDefault(require("os"));
7
+ /** ESLint file glob; Oxlint scope is aligned via `OXLINT_CLI_IGNORE_PATTERNS` (extensions + `.genx`). */
8
+ const ESLINT_TS_JS_GLOB = '"./**/*.{ts,js,tsx,jsx}"';
9
+ /**
10
+ * Oxlint only accepts directory/file PATHs, not ESLint-style brace globs. Lint `.` and ignore other
11
+ * extensions Oxlint supports so scope matches `ESLINT_TS_JS_GLOB` (plain `.ts` / `.js` only).
12
+ */
13
+ /** CLI flags: Oxlint does not reliably apply `ignorePatterns` from extended configs for dot-directories like `.genx`. */
14
+ const OXLINT_CLI_IGNORE_PATTERNS = [
15
+ '**/.genx/**',
16
+ '**/*.mjs',
17
+ '**/*.cjs',
18
+ '**/*.mts',
19
+ '**/*.cts',
20
+ '**/*.vue',
21
+ '**/*.svelte',
22
+ '**/*.astro',
23
+ ]
24
+ .map((pattern) => ` --ignore-pattern="${pattern}"`)
25
+ .join('');
26
+ /**
27
+ * TODO: https://github.com/oxc-project/oxc/issues/1117 - Swap `ci` pipeline to `ox` once import/no-extraneous-dependencies lands in oxlint.
28
+ */
29
+ function runOxlintStep(cwd, oxlintFixArg) {
30
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
31
+ consola_1.default.info('Running Oxlint...');
32
+ const oxlint = yield (0, build_kit_1.resolveBin)('oxlint');
33
+ const oxlintCmd = `${oxlint} .${OXLINT_CLI_IGNORE_PATTERNS}${oxlintFixArg}`;
34
+ consola_1.default.info(`Executing: ${oxlintCmd}`);
35
+ (0, build_kit_1.run)(cwd, oxlintCmd);
36
+ consola_1.default.success('Oxlint completed');
37
+ });
38
+ }
39
+ function runEslintStep(cwd_1, fixArg_1, profile_1, concurrency_1) {
40
+ return tslib_1.__awaiter(this, arguments, void 0, function* (cwd, fixArg, profile, concurrency, disablePrettierNoise = false) {
41
+ consola_1.default.info('Running ESLint...');
42
+ if (profile) {
43
+ process.env.TIMING = '1';
44
+ }
45
+ const eslint = yield (0, build_kit_1.resolveBin)('eslint');
46
+ let concurrencyArg = '';
47
+ if (concurrency) {
48
+ concurrencyArg = ` --concurrency ${concurrency}`;
49
+ }
50
+ else if (!process.env.CI) {
51
+ const defaultConcurrency = Math.max(1, Math.floor(os_1.default.cpus().length / 2));
52
+ concurrencyArg = ` --concurrency ${defaultConcurrency}`;
53
+ }
54
+ const formattingNoiseArg = disablePrettierNoise
55
+ ? [
56
+ ' --rule "prettier/prettier: off"',
57
+ ' --rule "max-len: off"',
58
+ ' --rule "eol-last: off"',
59
+ ' --rule "jsx-quotes: off"',
60
+ ' --rule "spaced-comment: off"',
61
+ ].join('')
62
+ : '';
63
+ const command = `${eslint} ${ESLINT_TS_JS_GLOB} ${fixArg}${concurrencyArg}${formattingNoiseArg}`;
64
+ consola_1.default.info(`Executing: ${command}`);
65
+ (0, build_kit_1.run)(cwd, command);
66
+ consola_1.default.success('ESLint completed');
67
+ });
68
+ }
69
+ function runOxfmtStep(cwd, fix) {
70
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
71
+ consola_1.default.info('Running Oxfmt...');
72
+ const oxfmt = yield (0, build_kit_1.resolveBin)('oxfmt');
73
+ const oxfmtCmd = fix ? `${oxfmt} .` : `${oxfmt} --check .`;
74
+ consola_1.default.info(`Executing: ${oxfmtCmd}`);
75
+ (0, build_kit_1.run)(cwd, oxfmtCmd);
76
+ consola_1.default.success('Oxfmt completed');
77
+ });
78
+ }
79
+ function runStylelintStep(cwd, fixArg) {
80
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
81
+ consola_1.default.info('Running Stylelint...');
82
+ const stylelint = yield (0, build_kit_1.resolveBin)('stylelint');
83
+ (0, build_kit_1.run)(cwd, `${stylelint} "./**/*.styles.ts" ${fixArg} --allow-empty-input`);
84
+ consola_1.default.success('Stylelint completed');
85
+ });
86
+ }
7
87
  exports.default = (ctx) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
8
88
  const { dirs: { cwd }, cli: { isLint, options: { profile, linter, fix, concurrency }, }, } = ctx;
9
89
  if (isLint) {
10
90
  const fixArg = fix ? ' --fix' : '';
11
- if (!linter || linter === 'eslint' || linter === 'all') {
12
- consola_1.default.info('Running ESLint...');
13
- if (profile) {
14
- process.env.TIMING = '1';
15
- }
16
- const eslint = yield (0, build_kit_1.resolveBin)('eslint');
17
- let concurrencyArg = '';
18
- if (concurrency) {
19
- concurrencyArg = ` --concurrency ${concurrency}`;
20
- }
21
- else if (!process.env.CI) {
22
- const defaultConcurrency = Math.max(1, Math.floor(os_1.default.cpus().length / 2));
23
- concurrencyArg = ` --concurrency ${defaultConcurrency}`;
24
- }
25
- const command = `${eslint} "./**/*.{ts,tsx,js,jsx}" ${fixArg}${concurrencyArg}`;
26
- consola_1.default.info(`Executing: ${command}`);
27
- (0, build_kit_1.run)(cwd, command);
28
- consola_1.default.success('ESLint completed');
29
- }
30
- if (!linter || linter === 'stylelint' || linter === 'all') {
31
- consola_1.default.info('Running Stylelint...');
32
- const stylelint = yield (0, build_kit_1.resolveBin)('stylelint');
33
- (0, build_kit_1.run)(cwd, `${stylelint} "./**/*.styles.ts" ${fixArg} --allow-empty-input`);
34
- consola_1.default.success('Stylelint completed');
91
+ const oxlintFixArg = fix ? ' --fix' : '';
92
+ // ox pipeline: Oxlint → Oxfmt → Stylelint.
93
+ if (linter === 'ox') {
94
+ yield runOxlintStep(cwd, oxlintFixArg);
95
+ yield runOxfmtStep(cwd, fix);
96
+ yield runStylelintStep(cwd, fixArg);
97
+ return;
98
+ }
99
+ // CI pipeline: Oxlint → ESLint → Oxfmt → Stylelint.
100
+ // Keeps ESLint for rules not yet in Oxlint (e.g. import/no-extraneous-dependencies).
101
+ // Once Oxlint covers all CI rules, swap to `linter === 'ox'`.
102
+ if (linter === 'ci') {
103
+ yield runOxlintStep(cwd, oxlintFixArg);
104
+ yield runEslintStep(cwd, fixArg, profile, concurrency, true);
105
+ yield runOxfmtStep(cwd, fix);
106
+ yield runStylelintStep(cwd, fixArg);
107
+ return;
108
+ }
109
+ // Default and `-l all`: ESLint + Prettier + Stylelint (legacy, backward-compatible).
110
+ // Use `genx lint -l ox` for the new Oxlint/Oxfmt stack.
111
+ const runAll = !linter || linter === 'all';
112
+ const runOxfmt = linter === 'oxfmt';
113
+ const runOxlint = linter === 'oxlint';
114
+ const runEslint = runAll || linter === 'eslint';
115
+ const runStylelint = runAll || linter === 'stylelint';
116
+ if (runOxlint) {
117
+ yield runOxlintStep(cwd, oxlintFixArg);
118
+ }
119
+ if (runOxfmt) {
120
+ yield runOxfmtStep(cwd, fix);
121
+ }
122
+ if (runEslint) {
123
+ yield runEslintStep(cwd, fixArg, profile, concurrency, false);
124
+ }
125
+ if (runStylelint) {
126
+ yield runStylelintStep(cwd, fixArg);
35
127
  }
36
128
  }
37
129
  else {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@genesislcap/eslint-stylelint-builder",
3
3
  "description": "ESLint/Stylelint builder",
4
- "version": "14.441.0",
4
+ "version": "14.443.0",
5
5
  "license": "SEE LICENSE IN license.txt",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -12,13 +12,15 @@
12
12
  "build": "npm run clean && tsc -b ./tsconfig.json",
13
13
  "clean": "rimraf dist temp tsconfig.tsbuildinfo",
14
14
  "dev": "tsc -b ./tsconfig.json -w",
15
- "lint": "genx lint --profile",
16
- "lint:fix": "genx lint --fix"
15
+ "lint": "genx lint -l ox",
16
+ "lint:fix": "genx lint -l ox --fix"
17
17
  },
18
18
  "dependencies": {
19
- "@genesislcap/build-kit": "14.441.0",
19
+ "@genesislcap/build-kit": "14.443.0",
20
20
  "consola": "^3.0.2",
21
21
  "eslint": "^9.34.0",
22
+ "oxfmt": "^0.44.0",
23
+ "oxlint": "^1.59.0",
22
24
  "stylelint": "^14.0.0"
23
25
  },
24
26
  "repository": {
@@ -29,5 +31,5 @@
29
31
  "publishConfig": {
30
32
  "access": "public"
31
33
  },
32
- "gitHead": "7aa35983955df48854be7f8e1ea6d56eff71c3b5"
34
+ "gitHead": "057cb7a0d06f339094c8634a413e4a6e1aa95659"
33
35
  }
package/src/index.ts CHANGED
@@ -1,7 +1,90 @@
1
- import { run, resolveBin } from '@genesislcap/build-kit';
1
+ import os from 'os';
2
2
  import type { BuildContext } from '@genesislcap/build-kit';
3
+ import { run, resolveBin } from '@genesislcap/build-kit';
3
4
  import consola from 'consola';
4
- import os from 'os';
5
+
6
+ /** ESLint file glob; Oxlint scope is aligned via `OXLINT_CLI_IGNORE_PATTERNS` (extensions + `.genx`). */
7
+ const ESLINT_TS_JS_GLOB = '"./**/*.{ts,js,tsx,jsx}"';
8
+
9
+ /**
10
+ * Oxlint only accepts directory/file PATHs, not ESLint-style brace globs. Lint `.` and ignore other
11
+ * extensions Oxlint supports so scope matches `ESLINT_TS_JS_GLOB` (plain `.ts` / `.js` only).
12
+ */
13
+ /** CLI flags: Oxlint does not reliably apply `ignorePatterns` from extended configs for dot-directories like `.genx`. */
14
+ const OXLINT_CLI_IGNORE_PATTERNS = [
15
+ '**/.genx/**',
16
+ '**/*.mjs',
17
+ '**/*.cjs',
18
+ '**/*.mts',
19
+ '**/*.cts',
20
+ '**/*.vue',
21
+ '**/*.svelte',
22
+ '**/*.astro',
23
+ ]
24
+ .map((pattern) => ` --ignore-pattern="${pattern}"`)
25
+ .join('');
26
+
27
+ /**
28
+ * TODO: https://github.com/oxc-project/oxc/issues/1117 - Swap `ci` pipeline to `ox` once import/no-extraneous-dependencies lands in oxlint.
29
+ */
30
+ async function runOxlintStep(cwd: string, oxlintFixArg: string): Promise<void> {
31
+ consola.info('Running Oxlint...');
32
+ const oxlint = await resolveBin('oxlint');
33
+ const oxlintCmd = `${oxlint} .${OXLINT_CLI_IGNORE_PATTERNS}${oxlintFixArg}`;
34
+ consola.info(`Executing: ${oxlintCmd}`);
35
+ run(cwd, oxlintCmd);
36
+ consola.success('Oxlint completed');
37
+ }
38
+
39
+ async function runEslintStep(
40
+ cwd: string,
41
+ fixArg: string,
42
+ profile: boolean | undefined,
43
+ concurrency: string | number | undefined,
44
+ disablePrettierNoise = false,
45
+ ): Promise<void> {
46
+ consola.info('Running ESLint...');
47
+ if (profile) {
48
+ process.env.TIMING = '1';
49
+ }
50
+ const eslint = await resolveBin('eslint');
51
+ let concurrencyArg = '';
52
+ if (concurrency) {
53
+ concurrencyArg = ` --concurrency ${concurrency}`;
54
+ } else if (!process.env.CI) {
55
+ const defaultConcurrency = Math.max(1, Math.floor(os.cpus().length / 2));
56
+ concurrencyArg = ` --concurrency ${defaultConcurrency}`;
57
+ }
58
+ const formattingNoiseArg = disablePrettierNoise
59
+ ? [
60
+ ' --rule "prettier/prettier: off"',
61
+ ' --rule "max-len: off"',
62
+ ' --rule "eol-last: off"',
63
+ ' --rule "jsx-quotes: off"',
64
+ ' --rule "spaced-comment: off"',
65
+ ].join('')
66
+ : '';
67
+ const command = `${eslint} ${ESLINT_TS_JS_GLOB} ${fixArg}${concurrencyArg}${formattingNoiseArg}`;
68
+ consola.info(`Executing: ${command}`);
69
+ run(cwd, command);
70
+ consola.success('ESLint completed');
71
+ }
72
+
73
+ async function runOxfmtStep(cwd: string, fix: boolean | undefined): Promise<void> {
74
+ consola.info('Running Oxfmt...');
75
+ const oxfmt = await resolveBin('oxfmt');
76
+ const oxfmtCmd = fix ? `${oxfmt} .` : `${oxfmt} --check .`;
77
+ consola.info(`Executing: ${oxfmtCmd}`);
78
+ run(cwd, oxfmtCmd);
79
+ consola.success('Oxfmt completed');
80
+ }
81
+
82
+ async function runStylelintStep(cwd: string, fixArg: string): Promise<void> {
83
+ consola.info('Running Stylelint...');
84
+ const stylelint = await resolveBin('stylelint');
85
+ run(cwd, `${stylelint} "./**/*.styles.ts" ${fixArg} --allow-empty-input`);
86
+ consola.success('Stylelint completed');
87
+ }
5
88
 
6
89
  export default async (ctx: BuildContext) => {
7
90
  const {
@@ -13,31 +96,49 @@ export default async (ctx: BuildContext) => {
13
96
  } = ctx;
14
97
  if (isLint) {
15
98
  const fixArg = fix ? ' --fix' : '';
99
+ const oxlintFixArg = fix ? ' --fix' : '';
100
+
101
+ // ox pipeline: Oxlint → Oxfmt → Stylelint.
102
+ if (linter === 'ox') {
103
+ await runOxlintStep(cwd, oxlintFixArg);
104
+ await runOxfmtStep(cwd, fix);
105
+ await runStylelintStep(cwd, fixArg);
106
+ return;
107
+ }
108
+
109
+ // CI pipeline: Oxlint → ESLint → Oxfmt → Stylelint.
110
+ // Keeps ESLint for rules not yet in Oxlint (e.g. import/no-extraneous-dependencies).
111
+ // Once Oxlint covers all CI rules, swap to `linter === 'ox'`.
112
+ if (linter === 'ci') {
113
+ await runOxlintStep(cwd, oxlintFixArg);
114
+ await runEslintStep(cwd, fixArg, profile, concurrency, true);
115
+ await runOxfmtStep(cwd, fix);
116
+ await runStylelintStep(cwd, fixArg);
117
+ return;
118
+ }
119
+
120
+ // Default and `-l all`: ESLint + Prettier + Stylelint (legacy, backward-compatible).
121
+ // Use `genx lint -l ox` for the new Oxlint/Oxfmt stack.
122
+ const runAll = !linter || linter === 'all';
123
+ const runOxfmt = linter === 'oxfmt';
124
+ const runOxlint = linter === 'oxlint';
125
+ const runEslint = runAll || linter === 'eslint';
126
+ const runStylelint = runAll || linter === 'stylelint';
127
+
128
+ if (runOxlint) {
129
+ await runOxlintStep(cwd, oxlintFixArg);
130
+ }
131
+
132
+ if (runOxfmt) {
133
+ await runOxfmtStep(cwd, fix);
134
+ }
16
135
 
17
- if (!linter || linter === 'eslint' || linter === 'all') {
18
- consola.info('Running ESLint...');
19
- if (profile) {
20
- process.env.TIMING = '1';
21
- }
22
- const eslint = await resolveBin('eslint');
23
- let concurrencyArg = '';
24
- if (concurrency) {
25
- concurrencyArg = ` --concurrency ${concurrency}`;
26
- } else if (!process.env.CI) {
27
- const defaultConcurrency = Math.max(1, Math.floor(os.cpus().length / 2));
28
- concurrencyArg = ` --concurrency ${defaultConcurrency}`;
29
- }
30
- const command = `${eslint} "./**/*.{ts,tsx,js,jsx}" ${fixArg}${concurrencyArg}`;
31
- consola.info(`Executing: ${command}`);
32
- run(cwd, command);
33
- consola.success('ESLint completed');
136
+ if (runEslint) {
137
+ await runEslintStep(cwd, fixArg, profile, concurrency, false);
34
138
  }
35
139
 
36
- if (!linter || linter === 'stylelint' || linter === 'all') {
37
- consola.info('Running Stylelint...');
38
- const stylelint = await resolveBin('stylelint');
39
- run(cwd, `${stylelint} "./**/*.styles.ts" ${fixArg} --allow-empty-input`);
40
- consola.success('Stylelint completed');
140
+ if (runStylelint) {
141
+ await runStylelintStep(cwd, fixArg);
41
142
  }
42
143
  } else {
43
144
  throw new Error(`Unrecognized command: ${JSON.stringify(ctx.cli.options)}`);
package/tsconfig.json CHANGED
@@ -2,17 +2,10 @@
2
2
  "extends": "../../../../tsconfig.json",
3
3
  "compilerOptions": {
4
4
  "declarationDir": "./dist",
5
- "lib": [
6
- "ES2015",
7
- "ES2016",
8
- "ES2017",
9
- "ES2019",
10
- ],
5
+ "lib": ["ES2015", "ES2016", "ES2017", "ES2019"],
11
6
  "module": "commonjs",
12
7
  "outDir": "./dist",
13
- "rootDir": "./src",
8
+ "rootDir": "./src"
14
9
  },
15
- "include": [
16
- "src/**/*"
17
- ]
10
+ "include": ["src/**/*"]
18
11
  }