@4mbl/lint 0.0.0-alpha.007a287

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/CHANGELOG.md ADDED
@@ -0,0 +1,202 @@
1
+ # @4mbl/lint
2
+
3
+ ## 1.0.0-beta.9
4
+
5
+ ### Minor Changes
6
+
7
+ - 491164e: Add --help flag to cli
8
+ - 491164e: Fallback to Oxlint config lookup if no preset is passed to CLI and Oxlint config exists within working directory.
9
+
10
+ ## 1.0.0-beta.8
11
+
12
+ ### Minor Changes
13
+
14
+ - a78f42b: Configure rules to reduce noise
15
+
16
+ ## 1.0.0-beta.7
17
+
18
+ ### Minor Changes
19
+
20
+ - 7c82f22: Upgrade dependencies
21
+
22
+ ## 1.0.0-beta.6
23
+
24
+ ### Minor Changes
25
+
26
+ - 0422e86: Upgrade dependencies
27
+
28
+ ## 1.0.0-beta.5
29
+
30
+ ### Minor Changes
31
+
32
+ - 125b851: Enable most rule categories
33
+ - 473bad0: Upgrade dependencies
34
+
35
+ ## 1.0.0-beta.4
36
+
37
+ ### Minor Changes
38
+
39
+ - 10abc93: Upgrade dependencies
40
+
41
+ ## 1.0.0-beta.3
42
+
43
+ ### Minor Changes
44
+
45
+ - dd91a0d: Allow direct preset usage with default exports
46
+ - dd91a0d: Add `--preset` argument to use any preset directly from the CLI
47
+
48
+ ### Patch Changes
49
+
50
+ - 51c5a6a: Resolve uiPath from cwd in next preset
51
+
52
+ ## 1.0.0-beta.2
53
+
54
+ ### Minor Changes
55
+
56
+ - ba4500a: Use named exports for config templates
57
+ - ba4500a: Re-export oxlint defineConfig
58
+
59
+ ### Patch Changes
60
+
61
+ - 2b77e08: Transpile configs to support usage from node_modules
62
+
63
+ ## 1.0.0-beta.1
64
+
65
+ ### Patch Changes
66
+
67
+ - 2c338b1: Re-export `OxlintConfig` to make config portable
68
+
69
+ ## 1.0.0-beta.0
70
+
71
+ ### Major Changes
72
+
73
+ - c65e34e: Add CLI to allow default arguments and easier tool migration in the future
74
+ - c65e34e: Migrate from eslint to oxlint
75
+
76
+ ## 0.16.0
77
+
78
+ ### Minor Changes
79
+
80
+ - 6878a35: Upgrade config dependencies
81
+
82
+ ## 0.15.0
83
+
84
+ ### Minor Changes
85
+
86
+ - 5040323: Upgrade config dependencies
87
+
88
+ ## 0.14.0
89
+
90
+ ### Minor Changes
91
+
92
+ - 794dbfb: Upgrade config dependencies
93
+ - e6a08fd: Upgrade to ESLint 10
94
+
95
+ ## 0.13.0
96
+
97
+ ### Minor Changes
98
+
99
+ - ac23f1d: Upgrade config dependencies
100
+
101
+ ## 0.12.0
102
+
103
+ ### Minor Changes
104
+
105
+ - dd16619: Upgrade config dependencies
106
+
107
+ ## 0.11.0
108
+
109
+ ### Minor Changes
110
+
111
+ - e011cd6: Upgrade config dependencies
112
+
113
+ ## 0.10.0
114
+
115
+ ### Minor Changes
116
+
117
+ - 774cb2a: Upgrade config dependencies
118
+
119
+ ## 0.9.0
120
+
121
+ ### Minor Changes
122
+
123
+ - aee78b7: Upgrade config dependencies
124
+
125
+ ## 0.8.0
126
+
127
+ ### Minor Changes
128
+
129
+ - 152396b: Upgrade config dependencies
130
+
131
+ ## 0.7.0
132
+
133
+ ### Minor Changes
134
+
135
+ - 8e46d6b: Upgrade config dependencies
136
+
137
+ ### Patch Changes
138
+
139
+ - 8e46d6b: Re-export types with type-keyword to fix verbatimModuleSyntax
140
+
141
+ ## 0.6.0
142
+
143
+ ### Minor Changes
144
+
145
+ - 46d0443: Upgrade config dependencies
146
+
147
+ ## 0.5.0
148
+
149
+ ### Minor Changes
150
+
151
+ - 55c3db6: Export `defineConfig` from eslint
152
+ - f7d30bb: Upgrade config dependencies
153
+
154
+ ## 0.4.0
155
+
156
+ ### Minor Changes
157
+
158
+ - 00cfefd: Add node template
159
+
160
+ ## 0.3.2
161
+
162
+ ### Patch Changes
163
+
164
+ - df1c48b: Re-export eslint Config type from react template
165
+
166
+ ## 0.3.1
167
+
168
+ ### Patch Changes
169
+
170
+ - d17fc69: Fix react template export
171
+
172
+ ## 0.3.0
173
+
174
+ ### Minor Changes
175
+
176
+ - 6d969e6: Add react template
177
+ - 6d969e6: Upgrade eslint and config dependencies
178
+
179
+ ## 0.2.1
180
+
181
+ ### Patch Changes
182
+
183
+ - 3a223fe: Use flat config version of eslint-plugin-react-hooks
184
+
185
+ ## 0.2.0
186
+
187
+ ### Minor Changes
188
+
189
+ - c4e49f3: Add eslint-plugin-react-hooks
190
+ - c4e49f3: Add eslint-config-prettier
191
+
192
+ ## 0.1.1
193
+
194
+ ### Patch Changes
195
+
196
+ - 2c91355: Move dependencies not to be dev-only
197
+
198
+ ## 0.1.0
199
+
200
+ ### Minor Changes
201
+
202
+ - 66bbf26: Initial release
package/README.md ADDED
@@ -0,0 +1,132 @@
1
+ # @4mbl/lint
2
+
3
+ > Linting configuration for various environments.
4
+
5
+ - [Installation](#installation)
6
+ - [Usage](#usage)
7
+ - [Using `lint` CLI](#using-lint-cli)
8
+ - [Setting up the `lint` CLI](#setting-up-the-lint-cli)
9
+ - [Choosing presets](#choosing-presets)
10
+ - [Beyond presets](#beyond-presets)
11
+ - [CLI default arguments](#cli-default-arguments)
12
+ - [Using `oxlint` directly](#using-oxlint-directly)
13
+ - [Oxlint CLI](#oxlint-cli)
14
+ - [Configuring oxlint](#configuring-oxlint)
15
+ - [Available presets](#available-presets)
16
+ - [Versioning](#versioning)
17
+
18
+ ---
19
+
20
+ > [!NOTE]
21
+ > This package currently uses [oxlint](https://www.npmjs.com/package/oxlint) as the underlying linting tool. This may change in a future major release.
22
+
23
+ ## Installation
24
+
25
+ Install the [`@4mbl/lint`](https://www.npmjs.com/package/@4mbl/lint) package.
26
+
27
+ ```shell
28
+ npm install -D @4mbl/lint
29
+ ```
30
+
31
+ ## Usage
32
+
33
+ This package supports two ways of running the linting tool.
34
+
35
+ ### Using `lint` CLI
36
+
37
+ Using the provided `lint` CLI is the recommended approach, as it abstracts away the underlying linting tool and allows it to be changed in the future with minimal impact on consumers.
38
+
39
+ While we aim to keep the CLI stable across tooling changes, some breaking changes may be unavoidable if the underlying tool changes.
40
+
41
+ #### Setting up the `lint` CLI
42
+
43
+ To use the provided CLI, simply call `lint` in your scripts.
44
+
45
+ ```shell
46
+ npm pkg set scripts.lint="lint"
47
+ ```
48
+
49
+ #### Choosing presets
50
+
51
+ The CLI uses the environment-agnostic `base` preset by default. To use a different preset, pass the `--preset` argument with the preset name.
52
+
53
+ ```shell
54
+ npm pkg set scripts.lint="lint --preset node"
55
+ ```
56
+
57
+ _See the [available presets](#available-presets) section for a list of available presets._
58
+
59
+ #### Beyond presets
60
+
61
+ In some cases, the provided presets may not be sufficient for your use case. You can create an `oxlint.config.ts` file and pass it to the oxlint CLI directly.
62
+
63
+ ```shell
64
+ npm pkg set scripts.lint="lint -- --config oxlint.config.ts"
65
+ ```
66
+
67
+ You can use the provided presets as a base for your custom configuration, as shown in the [Configuring oxlint](#configuring-oxlint) section.
68
+
69
+ #### CLI default arguments
70
+
71
+ By default, the CLI targets the `src` directory and uses the following oxlint arguments:
72
+
73
+ - `--max-warnings=0`
74
+ - `--report-unused-disable-directives`
75
+
76
+ You can override these arguments or pass additional arguments to the underlying oxlint tool.
77
+
78
+ ```shell
79
+ npm pkg set scripts.lint="lint -- --max-warnings=10 --fix"
80
+ ```
81
+
82
+ ### Using `oxlint` directly
83
+
84
+ For full control over the linting setup, you can use oxlint directly.
85
+
86
+ #### Oxlint CLI
87
+
88
+ Set the `lint` script in your `package.json` to use the `oxlint` binary.
89
+
90
+ ```shell
91
+ npm pkg set scripts.lint="oxlint src"
92
+ ```
93
+
94
+ You may need to explicitly allow the underlying linting packages to be used by your scripts.
95
+
96
+ For example, when using pnpm, set `publicHoistPattern` in your `pnpm-workspace.yaml`.
97
+
98
+ #### Configuring oxlint
99
+
100
+ Create an `oxlint.config.ts` file in your package with the desired preset.
101
+
102
+ ```js
103
+ import nodeConfig from '@4mbl/lint/node';
104
+
105
+ export default nodeConfig();
106
+ ```
107
+
108
+ Some presets may accept additional options. For example, the `next` preset accepts a `uiPath` option.
109
+
110
+ _See the [available presets](#available-presets) section for a list of available presets._
111
+
112
+ ```yaml
113
+ publicHoistPattern:
114
+ - oxlint
115
+ ```
116
+
117
+ ## Available presets
118
+
119
+ The following presets are currently available:
120
+
121
+ - **Base** – Environment-agnostic linting rules.
122
+ - **Next** – Additional linting rules for Next.js.
123
+ - **Node** – Additional linting rules for Node.js.
124
+ - **React** – Additional linting rules for React.
125
+
126
+ ## Versioning
127
+
128
+ The package follows the versioning scheme `X.Y.Z`:
129
+
130
+ - `X` – Reserved for linting provider changes, as these may introduce broader compatibility issues.
131
+ - `Y` – New linting rules. Rules are initially introduced as warnings and may be promoted to errors in a subsequent minor release.
132
+ - `Z` – Fixes for issues that made the previous release unusable.
package/bin/cli.js ADDED
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { spawnSync } from 'node:child_process';
4
+ import { existsSync } from 'node:fs';
5
+ import path from 'node:path';
6
+ import { fileURLToPath } from 'node:url';
7
+
8
+ const __filename = fileURLToPath(import.meta.url);
9
+ const __dirname = path.dirname(__filename);
10
+
11
+ const rawArgs = process.argv.slice(2);
12
+
13
+ const separatorIndex = rawArgs.indexOf('--');
14
+
15
+ const wrapperArgs =
16
+ separatorIndex === -1 ? rawArgs : rawArgs.slice(0, separatorIndex);
17
+ const toolArgs = separatorIndex === -1 ? [] : rawArgs.slice(separatorIndex + 1);
18
+
19
+ if (wrapperArgs.includes('--help') || rawArgs.includes('-h')) {
20
+ console.log(`
21
+ Usage:
22
+ lint [options] -- [oxlint options]
23
+
24
+ Options:
25
+ --preset <name> Use a preset config (default: base if no config within cwd)
26
+
27
+ Examples:
28
+ lint
29
+ lint --preset node
30
+ lint -- src --fix
31
+
32
+ Notes:
33
+ Everything after "--" is passed directly to oxlint.
34
+ `);
35
+
36
+ process.exit(0);
37
+ }
38
+
39
+ const presetArgIndex = wrapperArgs.findIndex((a) => a === '--preset');
40
+
41
+ const presetName =
42
+ presetArgIndex !== -1
43
+ ? wrapperArgs[presetArgIndex + 1]
44
+ : !existsSync('./oxlint.config.ts') && !existsSync('./.oxlintrc.json')
45
+ ? 'base'
46
+ : undefined;
47
+
48
+ const configPath = presetName
49
+ ? path.resolve(__dirname, `../dist/${presetName}.js`)
50
+ : undefined;
51
+
52
+ const hasPath = toolArgs.some((a) => !a.startsWith('-'));
53
+ const hasMaxWarn = toolArgs.some((a) => a.startsWith('--max-warnings'));
54
+ const hasReportUnused = toolArgs.some((a) =>
55
+ a.startsWith('--report-unused-disable-directives'),
56
+ );
57
+
58
+ const finalArgs = [
59
+ configPath ? '--config' : undefined,
60
+ configPath,
61
+ hasPath ? undefined : 'src',
62
+ hasMaxWarn ? undefined : '--max-warnings=0',
63
+ hasReportUnused ? undefined : '--report-unused-disable-directives',
64
+ ...toolArgs,
65
+ ].filter((a) => a !== undefined);
66
+
67
+ const result = spawnSync('oxlint', finalArgs, {
68
+ stdio: 'inherit',
69
+ shell: true,
70
+ });
71
+
72
+ process.exit(result.status ?? 1);