@rdjperron/lint 0.1.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.
Files changed (38) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +88 -0
  3. package/dist/anti-slop.d.mts +6 -0
  4. package/dist/anti-slop.mjs +1694 -0
  5. package/dist/anti-slop.mjs.map +1 -0
  6. package/dist/expo.d.mts +5 -0
  7. package/dist/expo.mjs +51 -0
  8. package/dist/expo.mjs.map +1 -0
  9. package/dist/i18n.d.mts +5 -0
  10. package/dist/i18n.mjs +50 -0
  11. package/dist/i18n.mjs.map +1 -0
  12. package/dist/react.d.mts +5 -0
  13. package/dist/react.mjs +73 -0
  14. package/dist/react.mjs.map +1 -0
  15. package/dist/rule-options-DrAXz8BD.mjs +18 -0
  16. package/dist/rule-options-DrAXz8BD.mjs.map +1 -0
  17. package/fixtures/README.md +63 -0
  18. package/fixtures/anti-slop/no-array-filter-map.fixture.ts +4 -0
  19. package/fixtures/anti-slop/no-chained-type-assertions.fixture.ts +7 -0
  20. package/fixtures/anti-slop/no-conditional-empty-object-spread.fixture.ts +4 -0
  21. package/fixtures/anti-slop/no-known-value-widening.fixture.ts +2 -0
  22. package/fixtures/anti-slop/no-module-mocking.fixture.ts +6 -0
  23. package/fixtures/anti-slop/no-object-parameters.fixture.ts +4 -0
  24. package/fixtures/anti-slop/no-reduce-accumulator-copy.fixture.ts +4 -0
  25. package/fixtures/anti-slop/no-reflect-apply.fixture.ts +6 -0
  26. package/fixtures/anti-slop/no-reflect-get.fixture.ts +4 -0
  27. package/fixtures/anti-slop/no-runtime-typeof.fixture.ts +4 -0
  28. package/fixtures/anti-slop/no-shape-in-symbol-names.fixture.ts +2 -0
  29. package/fixtures/anti-slop/no-unknown-parameters.fixture.ts +4 -0
  30. package/fixtures/anti-slop/no-unknown-returns.fixture.ts +4 -0
  31. package/fixtures/anti-slop/no-unknown-type-aliases.fixture.ts +2 -0
  32. package/fixtures/anti-slop/no-unsafe-dictionary-type.fixture.ts +2 -0
  33. package/fixtures/anti-slop/no-widen-then-assert.fixture.ts +9 -0
  34. package/fixtures/anti-slop/require-safety-comment-for-type-assertion.fixture.ts +5 -0
  35. package/fixtures/expo/static-public-env.fixture.ts +4 -0
  36. package/fixtures/i18n/no-hardcoded-jsx-text.fixture.tsx +4 -0
  37. package/fixtures/react/no-use-effect.fixture.tsx +9 -0
  38. package/package.json +50 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Romain Perron
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,88 @@
1
+ # @rdjperron/lint
2
+
3
+ Oxlint JS plugins in four packs. Each pack is one plugin, registered on its own, so a project
4
+ enables only what it wants.
5
+
6
+ | Pack | Plugin name | Rules |
7
+ | ----------- | -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
8
+ | `anti-slop` | `anti-slop` | 17 rules that reject low-evidence patterns: `unknown` contracts, unjustified type assertions, `Reflect` calls, runtime `typeof`, module mocking, and so on. |
9
+ | `react` | `react-policy` | `no-use-effect`: reports every `useEffect` and `useLayoutEffect` call or import. |
10
+ | `i18n` | `i18n` | `no-hardcoded-jsx-text`: reports words written straight into JSX children. |
11
+ | `expo` | `expo` | `static-public-env`: allows only `process.env.NAME` reads, the one form Expo inlines at bundle time. |
12
+
13
+ `anti-slop` is a copy of [dmmulroy/anti-slop](https://github.com/dmmulroy/anti-slop), owned and
14
+ edited here (see `src/anti-slop/VENDORED.md` in the source repo). The plugin name is `react-policy`
15
+ and not `react` because oxlint has a built-in plugin called `react`.
16
+
17
+ ## Install
18
+
19
+ ```bash
20
+ npm install --save-dev --save-exact @rdjperron/lint @oxlint/plugins@<version>
21
+ ```
22
+
23
+ The rules import `defineRule` and the AST types from `@oxlint/plugins`, a peer dependency. Its
24
+ version has to match the plugin API of the linter that loads the rules. Under Vite+ that linter
25
+ is inside the `vp` binary, and the authority is the version `vite-plus` declares, not npm latest
26
+ and not the bundled oxlint version:
27
+
28
+ ```bash
29
+ vp why @oxlint/plugins
30
+ # or: node -p "require('vite-plus/package.json').dependencies['@oxlint/plugins']"
31
+ ```
32
+
33
+ Pin `@oxlint/plugins` exactly to that number. The peer range in this package is a caret so an
34
+ exact pin anywhere in the same major satisfies it. Move the pin every time `vp` moves.
35
+
36
+ ## Register a pack
37
+
38
+ Each pack is a `jsPlugins` entry with its name and its specifier, then rules by `<name>/<rule>`:
39
+
40
+ ```ts
41
+ // vite.config.ts (or .oxlintrc.json, same shape)
42
+ export default defineConfig({
43
+ lint: {
44
+ jsPlugins: [
45
+ { name: "anti-slop", specifier: "@rdjperron/lint/anti-slop" },
46
+ { name: "react-policy", specifier: "@rdjperron/lint/react" },
47
+ { name: "i18n", specifier: "@rdjperron/lint/i18n" },
48
+ { name: "expo", specifier: "@rdjperron/lint/expo" },
49
+ ],
50
+ rules: {
51
+ "anti-slop/no-reflect-get": "error",
52
+ "react-policy/no-use-effect": [
53
+ "error",
54
+ { hint: "The one sanctioned wrapper is useMountEffect." },
55
+ ],
56
+ "i18n/no-hardcoded-jsx-text": "error",
57
+ "expo/static-public-env": "error",
58
+ },
59
+ },
60
+ });
61
+ ```
62
+
63
+ Measure before promoting: land a new rule at `warn`, fix or scope what fires, then move it to
64
+ `error`. The anti-slop severities this package's own repo settled on are in its root
65
+ `vite.config.ts`.
66
+
67
+ ### Rule options
68
+
69
+ - `react-policy/no-use-effect` takes `{ hint?: string }`. The hint is appended to every finding,
70
+ so a project can name its one sanctioned wrapper. Exempt that wrapper's file with an override.
71
+ - `i18n/no-hardcoded-jsx-text` takes `{ pattern?: string }`, a regex source compiled with the
72
+ `u` flag. The default `\p{L}{3,}` says three letters in a row is a word; digits, separators and
73
+ bullets are not. It looks at JSX text and at string literals placed as children, never at
74
+ attribute values.
75
+ - `expo/static-public-env` has no options. It reports destructuring of `process.env`, computed
76
+ access, and `process.env` used as a value (assigned, passed, spread, returned).
77
+
78
+ ## The fixtures ship with the package
79
+
80
+ `fixtures/<pack>/<rule>.fixture.ts(x)` is one deliberately violating file per rule. A rule can
81
+ go silently dead (a linter upgrade, a plugin API skew, an ignore pattern that swallows the wrong
82
+ path), and "reports nothing" looks exactly like "no violations". The consumer's verify script
83
+ lints each fixture directory through its own pipeline and asserts that every rule fired on the
84
+ file named after it. The source repo's `scripts/verify-lint-fixtures.mjs` is the reference
85
+ implementation; copy it and point its suites at
86
+ `node_modules/@rdjperron/lint/fixtures/<pack>`. oxlint skips `node_modules`, so the script lints
87
+ through a symlinked view outside it, and that view must never be gitignored (oxlint honours
88
+ `.gitignore`, and a gitignored view silently disables the whole check).
@@ -0,0 +1,6 @@
1
+ //#region src/anti-slop/index.d.ts
2
+ /** Generic Oxlint rules that reject low-evidence and low-signal implementation patterns. */
3
+ declare const antiSlopPlugin: import("@oxlint/plugins").Plugin;
4
+ //#endregion
5
+ export { antiSlopPlugin as default };
6
+ //# sourceMappingURL=anti-slop.d.mts.map