@configg/oxc 0.1.6 → 0.1.8

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 (3) hide show
  1. package/README.md +15 -5
  2. package/package.json +1 -1
  3. package/src/lint.ts +29 -23
package/README.md CHANGED
@@ -40,16 +40,26 @@ export default defineConfig(configs.client)
40
40
  - `client`: browser env, type-aware, with rules relaxed for component code. Its `**/*.spec.{ts,tsx}` override enables the Vitest env and Testing Library rules, so it needs `eslint-plugin-testing-library`.
41
41
  - `scripts`: Node env, type-aware, for tooling and config files.
42
42
 
43
- Both Oxlint presets include all 18 rules from the vendored [anti-slop](https://github.com/dmmulroy/anti-slop) plugin.
44
- See [UPSTREAM.md](./src/anti-slop/UPSTREAM.md) for its source and update policy.
45
- `unicorn/prefer-reflect-apply` is off because anti-slop forbids `Reflect.apply`.
46
- The plugin ships as TypeScript, so run oxlint under Bun (`bunx --bun oxlint`): Node refuses to strip types from files in `node_modules`.
43
+ The Oxlint presets don't enable anti-slop. `antiSlop` from `@configg/oxc/lint` is an opt-in set with the plugin and all 18 rules as errors; `unicorn/prefer-reflect-apply` is off. See [UPSTREAM.md](./src/anti-slop/UPSTREAM.md) for its source and update policy.
44
+
45
+ ```ts
46
+ import { antiSlop, configs } from '@configg/oxc/lint'
47
+
48
+ export default defineConfig({
49
+ ...configs.client,
50
+ jsPlugins: [...antiSlop.jsPlugins],
51
+ rules: { ...configs.client.rules, ...antiSlop.rules },
52
+ })
53
+ ```
54
+
55
+ If your config has its own `jsPlugins`, keep the anti-slop entry in that array. The plugin ships as TypeScript, so run oxlint under Bun (`bunx --bun oxlint`): Node refuses to strip types from files in `node_modules`.
47
56
 
48
57
  Both presets allow up to two classes per file, allow `reduce()`, allow `process.exit()` (CLI scripts and
49
58
  shutdown handlers exit with a status code on purpose) and allow short identifiers (`eslint/id-length` is off). They turn `import/prefer-default-export` off, since named
50
59
  exports are the convention (it matters once a config adds the `import` plugin), and `unicorn/number-literal-case`
51
60
  off, since oxfmt and Prettier write hex digits in lowercase. `async`/`await` is allowed (`oxc/no-async-await` is
52
- off), and functions may run to 100 lines (blank lines and comments not counted) and 30 statements. Template expressions
61
+ off), `continue` is allowed (`eslint/no-continue` is off), and functions may run to 100 lines (blank lines and comments
62
+ not counted) and 30 statements. Template expressions
53
63
  allow booleans, numbers, nullish values and `never`; other types follow Oxlint's defaults.
54
64
 
55
65
  ## Peer dependencies
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@configg/oxc",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "oxfmt and oxlint presets",
5
5
  "keywords": [
6
6
  "config",
package/src/lint.ts CHANGED
@@ -1,30 +1,13 @@
1
1
  import type { OxlintConfig } from 'oxlint'
2
2
 
3
- const antiSlop = { name: 'anti-slop', specifier: `${import.meta.dirname}/anti-slop/index.ts` }
3
+ const antiSlopPlugin = { name: 'anti-slop', specifier: `${import.meta.dirname}/anti-slop/index.ts` }
4
4
 
5
5
  const sharedRules = {
6
- 'anti-slop/no-array-filter-map': 'error',
7
- 'anti-slop/no-chained-type-assertions': 'error',
8
- 'anti-slop/no-conditional-empty-object-spread': 'error',
9
- 'anti-slop/no-known-value-widening': 'error',
10
- 'anti-slop/no-module-mocking': 'error',
11
- 'anti-slop/no-object-parameters': 'error',
12
- 'anti-slop/no-reduce-accumulator-copy': 'error',
13
- 'anti-slop/no-reflect-apply': 'error',
14
- 'anti-slop/no-reflect-get': 'error',
15
- 'anti-slop/no-runtime-typeof': 'error',
16
- 'anti-slop/no-shape-in-symbol-names': 'error',
17
- 'anti-slop/no-unknown-parameters': 'error',
18
- 'anti-slop/no-unknown-returns': 'error',
19
- 'anti-slop/no-unknown-type-aliases': 'error',
20
- 'anti-slop/no-unsafe-dictionary-type': 'error',
21
- 'anti-slop/no-widen-then-assert': 'error',
22
- 'anti-slop/require-readable-spacing': 'error',
23
- 'anti-slop/require-safety-comment-for-type-assertion': 'error',
24
6
  'eslint/id-length': 'off',
25
7
  'eslint/max-classes-per-file': ['warn', { max: 2 }],
26
8
  'eslint/max-lines-per-function': ['warn', { max: 100, skipBlankLines: true, skipComments: true }],
27
9
  'eslint/max-statements': ['warn', { max: 30 }],
10
+ 'eslint/no-continue': 'off',
28
11
  'import/prefer-default-export': 'off',
29
12
  'oxc/no-async-await': 'off',
30
13
  'typescript/restrict-template-expressions': [
@@ -40,10 +23,35 @@ const sharedRules = {
40
23
  'unicorn/no-process-exit': 'off',
41
24
  // Oxfmt and Prettier write hex digits in lowercase; this rule wants uppercase and takes no option.
42
25
  'unicorn/number-literal-case': 'off',
43
- // This pushes toward Reflect.apply, which anti-slop/no-reflect-apply forbids.
44
- 'unicorn/prefer-reflect-apply': 'off',
45
26
  } as const satisfies OxlintConfig['rules']
46
27
 
28
+ /** Opt in by spreading into a preset. The plugin ships as TypeScript, so run oxlint under Bun. */
29
+ export const antiSlop = {
30
+ jsPlugins: [antiSlopPlugin],
31
+ rules: {
32
+ 'anti-slop/no-array-filter-map': 'error',
33
+ 'anti-slop/no-chained-type-assertions': 'error',
34
+ 'anti-slop/no-conditional-empty-object-spread': 'error',
35
+ 'anti-slop/no-known-value-widening': 'error',
36
+ 'anti-slop/no-module-mocking': 'error',
37
+ 'anti-slop/no-object-parameters': 'error',
38
+ 'anti-slop/no-reduce-accumulator-copy': 'error',
39
+ 'anti-slop/no-reflect-apply': 'error',
40
+ 'anti-slop/no-reflect-get': 'error',
41
+ 'anti-slop/no-runtime-typeof': 'error',
42
+ 'anti-slop/no-shape-in-symbol-names': 'error',
43
+ 'anti-slop/no-unknown-parameters': 'error',
44
+ 'anti-slop/no-unknown-returns': 'error',
45
+ 'anti-slop/no-unknown-type-aliases': 'error',
46
+ 'anti-slop/no-unsafe-dictionary-type': 'error',
47
+ 'anti-slop/no-widen-then-assert': 'error',
48
+ 'anti-slop/require-readable-spacing': 'error',
49
+ 'anti-slop/require-safety-comment-for-type-assertion': 'error',
50
+ // This pushes toward Reflect.apply, which anti-slop/no-reflect-apply forbids.
51
+ 'unicorn/prefer-reflect-apply': 'off',
52
+ },
53
+ } as const satisfies OxlintConfig
54
+
47
55
  export const configs = {
48
56
  client: {
49
57
  categories: {
@@ -59,7 +67,6 @@ export const configs = {
59
67
  browser: true,
60
68
  builtin: true,
61
69
  },
62
- jsPlugins: [antiSlop],
63
70
  options: {
64
71
  typeAware: true,
65
72
  typeCheck: true,
@@ -167,7 +174,6 @@ export const configs = {
167
174
  builtin: true,
168
175
  node: true,
169
176
  },
170
- jsPlugins: [antiSlop],
171
177
  options: {
172
178
  typeAware: true,
173
179
  typeCheck: true,