@4mbl/lint 0.0.0-alpha.098038f

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