@4mbl/lint 0.0.0-alpha.0422e86

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,177 @@
1
+ # @4mbl/lint
2
+
3
+ ## 1.0.0-beta.5
4
+
5
+ ### Minor Changes
6
+
7
+ - 125b851: Enable most rule categories
8
+ - 473bad0: Upgrade dependencies
9
+
10
+ ## 1.0.0-beta.4
11
+
12
+ ### Minor Changes
13
+
14
+ - 10abc93: Upgrade dependencies
15
+
16
+ ## 1.0.0-beta.3
17
+
18
+ ### Minor Changes
19
+
20
+ - dd91a0d: Allow direct preset usage with default exports
21
+ - dd91a0d: Add `--preset` argument to use any preset directly from the CLI
22
+
23
+ ### Patch Changes
24
+
25
+ - 51c5a6a: Resolve uiPath from cwd in next preset
26
+
27
+ ## 1.0.0-beta.2
28
+
29
+ ### Minor Changes
30
+
31
+ - ba4500a: Use named exports for config templates
32
+ - ba4500a: Re-export oxlint defineConfig
33
+
34
+ ### Patch Changes
35
+
36
+ - 2b77e08: Transpile configs to support usage from node_modules
37
+
38
+ ## 1.0.0-beta.1
39
+
40
+ ### Patch Changes
41
+
42
+ - 2c338b1: Re-export `OxlintConfig` to make config portable
43
+
44
+ ## 1.0.0-beta.0
45
+
46
+ ### Major Changes
47
+
48
+ - c65e34e: Add CLI to allow default arguments and easier tool migration in the future
49
+ - c65e34e: Migrate from eslint to oxlint
50
+
51
+ ## 0.16.0
52
+
53
+ ### Minor Changes
54
+
55
+ - 6878a35: Upgrade config dependencies
56
+
57
+ ## 0.15.0
58
+
59
+ ### Minor Changes
60
+
61
+ - 5040323: Upgrade config dependencies
62
+
63
+ ## 0.14.0
64
+
65
+ ### Minor Changes
66
+
67
+ - 794dbfb: Upgrade config dependencies
68
+ - e6a08fd: Upgrade to ESLint 10
69
+
70
+ ## 0.13.0
71
+
72
+ ### Minor Changes
73
+
74
+ - ac23f1d: Upgrade config dependencies
75
+
76
+ ## 0.12.0
77
+
78
+ ### Minor Changes
79
+
80
+ - dd16619: Upgrade config dependencies
81
+
82
+ ## 0.11.0
83
+
84
+ ### Minor Changes
85
+
86
+ - e011cd6: Upgrade config dependencies
87
+
88
+ ## 0.10.0
89
+
90
+ ### Minor Changes
91
+
92
+ - 774cb2a: Upgrade config dependencies
93
+
94
+ ## 0.9.0
95
+
96
+ ### Minor Changes
97
+
98
+ - aee78b7: Upgrade config dependencies
99
+
100
+ ## 0.8.0
101
+
102
+ ### Minor Changes
103
+
104
+ - 152396b: Upgrade config dependencies
105
+
106
+ ## 0.7.0
107
+
108
+ ### Minor Changes
109
+
110
+ - 8e46d6b: Upgrade config dependencies
111
+
112
+ ### Patch Changes
113
+
114
+ - 8e46d6b: Re-export types with type-keyword to fix verbatimModuleSyntax
115
+
116
+ ## 0.6.0
117
+
118
+ ### Minor Changes
119
+
120
+ - 46d0443: Upgrade config dependencies
121
+
122
+ ## 0.5.0
123
+
124
+ ### Minor Changes
125
+
126
+ - 55c3db6: Export `defineConfig` from eslint
127
+ - f7d30bb: Upgrade config dependencies
128
+
129
+ ## 0.4.0
130
+
131
+ ### Minor Changes
132
+
133
+ - 00cfefd: Add node template
134
+
135
+ ## 0.3.2
136
+
137
+ ### Patch Changes
138
+
139
+ - df1c48b: Re-export eslint Config type from react template
140
+
141
+ ## 0.3.1
142
+
143
+ ### Patch Changes
144
+
145
+ - d17fc69: Fix react template export
146
+
147
+ ## 0.3.0
148
+
149
+ ### Minor Changes
150
+
151
+ - 6d969e6: Add react template
152
+ - 6d969e6: Upgrade eslint and config dependencies
153
+
154
+ ## 0.2.1
155
+
156
+ ### Patch Changes
157
+
158
+ - 3a223fe: Use flat config version of eslint-plugin-react-hooks
159
+
160
+ ## 0.2.0
161
+
162
+ ### Minor Changes
163
+
164
+ - c4e49f3: Add eslint-plugin-react-hooks
165
+ - c4e49f3: Add eslint-config-prettier
166
+
167
+ ## 0.1.1
168
+
169
+ ### Patch Changes
170
+
171
+ - 2c91355: Move dependencies not to be dev-only
172
+
173
+ ## 0.1.0
174
+
175
+ ### Minor Changes
176
+
177
+ - 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,44 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { spawnSync } from 'node:child_process';
4
+ import path from 'node:path';
5
+ import { fileURLToPath } from 'node:url';
6
+
7
+ const __filename = fileURLToPath(import.meta.url);
8
+ const __dirname = path.dirname(__filename);
9
+
10
+ const rawArgs = process.argv.slice(2);
11
+
12
+ const separatorIndex = rawArgs.indexOf('--');
13
+
14
+ const wrapperArgs =
15
+ separatorIndex === -1 ? rawArgs : rawArgs.slice(0, separatorIndex);
16
+ const toolArgs = separatorIndex === -1 ? [] : rawArgs.slice(separatorIndex + 1);
17
+
18
+ const presetArgIndex = wrapperArgs.findIndex((a) => a === '--preset');
19
+ const presetName =
20
+ presetArgIndex !== -1 ? wrapperArgs[presetArgIndex + 1] : 'base';
21
+
22
+ const configPath = path.resolve(__dirname, `../dist/${presetName}.js`);
23
+
24
+ const hasPath = toolArgs.some((a) => !a.startsWith('-'));
25
+ const hasMaxWarn = toolArgs.some((a) => a.startsWith('--max-warnings'));
26
+ const hasReportUnused = toolArgs.some((a) =>
27
+ a.startsWith('--report-unused-disable-directives'),
28
+ );
29
+
30
+ const finalArgs = [
31
+ '--config',
32
+ configPath,
33
+ hasPath ? undefined : 'src',
34
+ hasMaxWarn ? undefined : '--max-warnings=0',
35
+ hasReportUnused ? undefined : '--report-unused-disable-directives',
36
+ ...toolArgs,
37
+ ].filter((a) => a !== undefined);
38
+
39
+ const result = spawnSync('oxlint', finalArgs, {
40
+ stdio: 'inherit',
41
+ shell: true,
42
+ });
43
+
44
+ process.exit(result.status ?? 1);
package/dist/base.d.ts ADDED
@@ -0,0 +1,255 @@
1
+ import { defineConfig, type OxlintConfig } from 'oxlint';
2
+ type BaseOptions = {};
3
+ declare function baseConfig(_options?: Partial<BaseOptions>): {
4
+ plugins: ("unicorn" | "typescript")[];
5
+ jsPlugins: never[];
6
+ categories: {
7
+ correctness: "error";
8
+ suspicious: "warn";
9
+ pedantic: "off";
10
+ perf: "warn";
11
+ style: "warn";
12
+ restriction: "warn";
13
+ nursery: "off";
14
+ };
15
+ env: {
16
+ builtin: true;
17
+ };
18
+ options: {
19
+ typeAware: true;
20
+ };
21
+ rules: {
22
+ 'constructor-super': "error";
23
+ 'for-direction': "error";
24
+ 'getter-return': "error";
25
+ 'no-async-promise-executor': "error";
26
+ 'no-case-declarations': "error";
27
+ 'no-class-assign': "error";
28
+ 'no-compare-neg-zero': "error";
29
+ 'no-cond-assign': "error";
30
+ 'no-const-assign': "error";
31
+ 'no-constant-binary-expression': "error";
32
+ 'no-constant-condition': "error";
33
+ 'no-control-regex': "error";
34
+ 'no-debugger': "error";
35
+ 'no-delete-var': "error";
36
+ 'no-dupe-class-members': "error";
37
+ 'no-dupe-else-if': "error";
38
+ 'no-dupe-keys': "error";
39
+ 'no-duplicate-case': "error";
40
+ 'no-empty': "error";
41
+ 'no-empty-character-class': "error";
42
+ 'no-empty-pattern': "error";
43
+ 'no-empty-static-block': "error";
44
+ 'no-ex-assign': "error";
45
+ 'no-extra-boolean-cast': "error";
46
+ 'no-fallthrough': "error";
47
+ 'no-func-assign': "error";
48
+ 'no-global-assign': "error";
49
+ 'no-import-assign': "error";
50
+ 'no-invalid-regexp': "error";
51
+ 'no-irregular-whitespace': "error";
52
+ 'no-loss-of-precision': "error";
53
+ 'no-misleading-character-class': "error";
54
+ 'no-new-native-nonconstructor': "error";
55
+ 'no-nonoctal-decimal-escape': "error";
56
+ 'no-obj-calls': "error";
57
+ 'no-prototype-builtins': "error";
58
+ 'no-redeclare': "error";
59
+ 'no-regex-spaces': "error";
60
+ 'no-self-assign': "error";
61
+ 'no-setter-return': "error";
62
+ 'no-shadow-restricted-names': "error";
63
+ 'no-sparse-arrays': "error";
64
+ 'no-this-before-super': "error";
65
+ 'no-undef': "error";
66
+ 'no-unexpected-multiline': "error";
67
+ 'no-unreachable': "error";
68
+ 'no-unsafe-finally': "error";
69
+ 'no-unsafe-negation': "error";
70
+ 'no-unsafe-optional-chaining': "error";
71
+ 'no-unused-labels': "error";
72
+ 'no-unused-private-class-members': "error";
73
+ 'no-unused-vars': "warn";
74
+ 'no-useless-backreference': "error";
75
+ 'no-useless-catch': "error";
76
+ 'no-useless-escape': "error";
77
+ 'no-with': "error";
78
+ 'require-yield': "error";
79
+ 'use-isnan': "error";
80
+ 'valid-typeof': "error";
81
+ '@typescript-eslint/ban-ts-comment': "error";
82
+ 'no-array-constructor': "error";
83
+ '@typescript-eslint/no-duplicate-enum-values': "error";
84
+ '@typescript-eslint/no-empty-object-type': "error";
85
+ '@typescript-eslint/no-explicit-any': "error";
86
+ '@typescript-eslint/no-extra-non-null-assertion': "error";
87
+ '@typescript-eslint/no-misused-new': "error";
88
+ '@typescript-eslint/no-namespace': "error";
89
+ '@typescript-eslint/no-non-null-asserted-optional-chain': "error";
90
+ '@typescript-eslint/no-require-imports': "error";
91
+ '@typescript-eslint/no-this-alias': "error";
92
+ '@typescript-eslint/no-unnecessary-type-constraint': "error";
93
+ '@typescript-eslint/no-unsafe-declaration-merging': "error";
94
+ '@typescript-eslint/no-unsafe-function-type': "error";
95
+ 'no-unused-expressions': "warn";
96
+ '@typescript-eslint/no-wrapper-object-types': "error";
97
+ '@typescript-eslint/prefer-as-const': "error";
98
+ '@typescript-eslint/prefer-namespace-keyword': "error";
99
+ '@typescript-eslint/triple-slash-reference': "error";
100
+ };
101
+ overrides: {
102
+ files: string[];
103
+ rules: {
104
+ 'constructor-super': "off";
105
+ 'getter-return': "off";
106
+ 'no-class-assign': "off";
107
+ 'no-const-assign': "off";
108
+ 'no-dupe-class-members': "off";
109
+ 'no-dupe-keys': "off";
110
+ 'no-func-assign': "off";
111
+ 'no-import-assign': "off";
112
+ 'no-new-native-nonconstructor': "off";
113
+ 'no-obj-calls': "off";
114
+ 'no-redeclare': "off";
115
+ 'no-setter-return': "off";
116
+ 'no-this-before-super': "off";
117
+ 'no-undef': "off";
118
+ 'no-unreachable': "off";
119
+ 'no-unsafe-negation': "off";
120
+ 'no-var': "error";
121
+ 'no-with': "off";
122
+ 'prefer-const': "error";
123
+ 'prefer-rest-params': "error";
124
+ 'prefer-spread': "error";
125
+ };
126
+ }[];
127
+ };
128
+ export { type OxlintConfig, defineConfig, baseConfig };
129
+ declare const _default: {
130
+ plugins: ("unicorn" | "typescript")[];
131
+ jsPlugins: never[];
132
+ categories: {
133
+ correctness: "error";
134
+ suspicious: "warn";
135
+ pedantic: "off";
136
+ perf: "warn";
137
+ style: "warn";
138
+ restriction: "warn";
139
+ nursery: "off";
140
+ };
141
+ env: {
142
+ builtin: true;
143
+ };
144
+ options: {
145
+ typeAware: true;
146
+ };
147
+ rules: {
148
+ 'constructor-super': "error";
149
+ 'for-direction': "error";
150
+ 'getter-return': "error";
151
+ 'no-async-promise-executor': "error";
152
+ 'no-case-declarations': "error";
153
+ 'no-class-assign': "error";
154
+ 'no-compare-neg-zero': "error";
155
+ 'no-cond-assign': "error";
156
+ 'no-const-assign': "error";
157
+ 'no-constant-binary-expression': "error";
158
+ 'no-constant-condition': "error";
159
+ 'no-control-regex': "error";
160
+ 'no-debugger': "error";
161
+ 'no-delete-var': "error";
162
+ 'no-dupe-class-members': "error";
163
+ 'no-dupe-else-if': "error";
164
+ 'no-dupe-keys': "error";
165
+ 'no-duplicate-case': "error";
166
+ 'no-empty': "error";
167
+ 'no-empty-character-class': "error";
168
+ 'no-empty-pattern': "error";
169
+ 'no-empty-static-block': "error";
170
+ 'no-ex-assign': "error";
171
+ 'no-extra-boolean-cast': "error";
172
+ 'no-fallthrough': "error";
173
+ 'no-func-assign': "error";
174
+ 'no-global-assign': "error";
175
+ 'no-import-assign': "error";
176
+ 'no-invalid-regexp': "error";
177
+ 'no-irregular-whitespace': "error";
178
+ 'no-loss-of-precision': "error";
179
+ 'no-misleading-character-class': "error";
180
+ 'no-new-native-nonconstructor': "error";
181
+ 'no-nonoctal-decimal-escape': "error";
182
+ 'no-obj-calls': "error";
183
+ 'no-prototype-builtins': "error";
184
+ 'no-redeclare': "error";
185
+ 'no-regex-spaces': "error";
186
+ 'no-self-assign': "error";
187
+ 'no-setter-return': "error";
188
+ 'no-shadow-restricted-names': "error";
189
+ 'no-sparse-arrays': "error";
190
+ 'no-this-before-super': "error";
191
+ 'no-undef': "error";
192
+ 'no-unexpected-multiline': "error";
193
+ 'no-unreachable': "error";
194
+ 'no-unsafe-finally': "error";
195
+ 'no-unsafe-negation': "error";
196
+ 'no-unsafe-optional-chaining': "error";
197
+ 'no-unused-labels': "error";
198
+ 'no-unused-private-class-members': "error";
199
+ 'no-unused-vars': "warn";
200
+ 'no-useless-backreference': "error";
201
+ 'no-useless-catch': "error";
202
+ 'no-useless-escape': "error";
203
+ 'no-with': "error";
204
+ 'require-yield': "error";
205
+ 'use-isnan': "error";
206
+ 'valid-typeof': "error";
207
+ '@typescript-eslint/ban-ts-comment': "error";
208
+ 'no-array-constructor': "error";
209
+ '@typescript-eslint/no-duplicate-enum-values': "error";
210
+ '@typescript-eslint/no-empty-object-type': "error";
211
+ '@typescript-eslint/no-explicit-any': "error";
212
+ '@typescript-eslint/no-extra-non-null-assertion': "error";
213
+ '@typescript-eslint/no-misused-new': "error";
214
+ '@typescript-eslint/no-namespace': "error";
215
+ '@typescript-eslint/no-non-null-asserted-optional-chain': "error";
216
+ '@typescript-eslint/no-require-imports': "error";
217
+ '@typescript-eslint/no-this-alias': "error";
218
+ '@typescript-eslint/no-unnecessary-type-constraint': "error";
219
+ '@typescript-eslint/no-unsafe-declaration-merging': "error";
220
+ '@typescript-eslint/no-unsafe-function-type': "error";
221
+ 'no-unused-expressions': "warn";
222
+ '@typescript-eslint/no-wrapper-object-types': "error";
223
+ '@typescript-eslint/prefer-as-const': "error";
224
+ '@typescript-eslint/prefer-namespace-keyword': "error";
225
+ '@typescript-eslint/triple-slash-reference': "error";
226
+ };
227
+ overrides: {
228
+ files: string[];
229
+ rules: {
230
+ 'constructor-super': "off";
231
+ 'getter-return': "off";
232
+ 'no-class-assign': "off";
233
+ 'no-const-assign': "off";
234
+ 'no-dupe-class-members': "off";
235
+ 'no-dupe-keys': "off";
236
+ 'no-func-assign': "off";
237
+ 'no-import-assign': "off";
238
+ 'no-new-native-nonconstructor': "off";
239
+ 'no-obj-calls': "off";
240
+ 'no-redeclare': "off";
241
+ 'no-setter-return': "off";
242
+ 'no-this-before-super': "off";
243
+ 'no-undef': "off";
244
+ 'no-unreachable': "off";
245
+ 'no-unsafe-negation': "off";
246
+ 'no-var': "error";
247
+ 'no-with': "off";
248
+ 'prefer-const': "error";
249
+ 'prefer-rest-params': "error";
250
+ 'prefer-spread': "error";
251
+ };
252
+ }[];
253
+ };
254
+ export default _default;
255
+ //# sourceMappingURL=base.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../src/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEzD,KAAK,WAAW,GAAG,EAAE,CAAC;AAItB,iBAAS,UAAU,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkIlD;AAED,OAAO,EAAE,KAAK,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEvD,wBAA4B"}