@jeremybarbet/oxlint-plugin 0.1.0 → 0.2.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.
package/README.md
CHANGED
|
@@ -22,13 +22,6 @@ export default defineConfig({
|
|
|
22
22
|
});
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
Rules are prefixed `op/` by default. To use a different prefix — for instance to keep configs that
|
|
26
|
-
already say `local/*` working unchanged — use oxlint's alias form:
|
|
27
|
-
|
|
28
|
-
```ts
|
|
29
|
-
jsPlugins: [{ name: 'local', specifier: '@jeremybarbet/oxlint-plugin' }],
|
|
30
|
-
```
|
|
31
|
-
|
|
32
25
|
## Rules
|
|
33
26
|
|
|
34
27
|
### `no-unused-modules`
|
|
@@ -52,13 +45,18 @@ Not reported:
|
|
|
52
45
|
| `unusedExports` | `true` | Report exports nothing imports. |
|
|
53
46
|
| `missingExports` | `false` | Report files with no exports. Noisy — every spec and mock qualifies. |
|
|
54
47
|
| `ignoreExports` | `[]` | Globs whose exports are never reported. Put your entry points here. |
|
|
48
|
+
| `ignoreDefaultExports` | `false` | Never report `export default`. Pass globs to scope it — a file-based router like expo-router loads its routes by path, so their default export is an entry point, never an import. |
|
|
55
49
|
|
|
56
50
|
```ts
|
|
57
51
|
'op/no-unused-modules': ['error', {
|
|
58
52
|
ignoreExports: ['scripts/**'],
|
|
53
|
+
ignoreDefaultExports: ['app/**'], // expo-router loads routes by path
|
|
59
54
|
}],
|
|
60
55
|
```
|
|
61
56
|
|
|
57
|
+
`ignoreDefaultExports` is the narrow version of `ignoreExports`: listing `app/**` there would also
|
|
58
|
+
silence the named exports in those files, so a route that grew a dead helper would go unreported.
|
|
59
|
+
|
|
62
60
|
### `no-unused-class-members`
|
|
63
61
|
|
|
64
62
|
Reports public class members that nothing outside the declaring file references.
|
|
@@ -32,6 +32,9 @@ const rule = {
|
|
|
32
32
|
unusedExports: { type: 'boolean' },
|
|
33
33
|
missingExports: { type: 'boolean' },
|
|
34
34
|
ignoreExports: { type: 'array', items: { type: 'string' } },
|
|
35
|
+
ignoreDefaultExports: {
|
|
36
|
+
oneOf: [{ type: 'boolean' }, { type: 'array', items: { type: 'string' } }],
|
|
37
|
+
},
|
|
35
38
|
},
|
|
36
39
|
additionalProperties: false,
|
|
37
40
|
},
|
|
@@ -42,6 +45,7 @@ const rule = {
|
|
|
42
45
|
const unusedExports = raw.unusedExports ?? true;
|
|
43
46
|
const missingExports = raw.missingExports ?? false;
|
|
44
47
|
const ignoreExports = [...ALWAYS_IGNORED_EXPORTS, ...(raw.ignoreExports ?? [])];
|
|
48
|
+
const ignoreDefaultExports = raw.ignoreDefaultExports ?? false;
|
|
45
49
|
const index = getProjectIndex(context.cwd, readProjectSettings(context));
|
|
46
50
|
const self = context.filename;
|
|
47
51
|
const file = index.files.get(self);
|
|
@@ -52,6 +56,9 @@ const rule = {
|
|
|
52
56
|
if (matchesGlob(relativePath, ignoreExports)) {
|
|
53
57
|
return {};
|
|
54
58
|
}
|
|
59
|
+
// Resolved once rather than per node: the glob only ever depends on the file being linted.
|
|
60
|
+
const defaultIgnored = ignoreDefaultExports === true ||
|
|
61
|
+
(Array.isArray(ignoreDefaultExports) && matchesGlob(relativePath, ignoreDefaultExports));
|
|
55
62
|
const importers = index.importedFrom.get(self);
|
|
56
63
|
// A namespace import (`import * as x`) or a bare `import './x'` re-export pulls in everything,
|
|
57
64
|
// so no individual export can be called unused.
|
|
@@ -80,8 +87,11 @@ const rule = {
|
|
|
80
87
|
return;
|
|
81
88
|
}
|
|
82
89
|
for (const specifier of (node.specifiers ?? [])) {
|
|
83
|
-
|
|
84
|
-
|
|
90
|
+
const name = specifier.exported?.name;
|
|
91
|
+
// `export { Screen as default }` is the same export as `export default`, so the option
|
|
92
|
+
// has to cover it too.
|
|
93
|
+
if (name && !(defaultIgnored && name === 'default')) {
|
|
94
|
+
report(specifier.exported, name);
|
|
85
95
|
}
|
|
86
96
|
}
|
|
87
97
|
const declaration = node.declaration;
|
|
@@ -99,7 +109,7 @@ const rule = {
|
|
|
99
109
|
}
|
|
100
110
|
},
|
|
101
111
|
ExportDefaultDeclaration(node) {
|
|
102
|
-
if (unusedExports) {
|
|
112
|
+
if (unusedExports && !defaultIgnored) {
|
|
103
113
|
report(node, 'default');
|
|
104
114
|
}
|
|
105
115
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-unused-modules.mjs","sourceRoot":"","sources":["../../src/rules/no-unused-modules.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAoD,MAAM,cAAc,CAAC;AAEhF;;;;;;;GAOG;AAEH;;;GAGG;AACH,MAAM,sBAAsB,GAAG,CAAC,eAAe,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"no-unused-modules.mjs","sourceRoot":"","sources":["../../src/rules/no-unused-modules.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAoD,MAAM,cAAc,CAAC;AAEhF;;;;;;;GAOG;AAEH;;;GAGG;AACH,MAAM,sBAAsB,GAAG,CAAC,eAAe,CAAC,CAAC;AAgBjD,MAAM,IAAI,GAAS;IACjB,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EAAE,oEAAoE;SAClF;QACD,QAAQ,EAAE;YACR,MAAM,EAAE,4CAA4C;YACpD,OAAO,EAAE,2BAA2B;SACrC;QACD,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,QAAQ;gBACd,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K,CAAC,EAAE,CAAC;oBAC9C,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,CAAC;gBACjD,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jeremybarbet/oxlint-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Shared oxlint JS plugin: dead-code rules that oxlint, tsc and knip each miss, plus a few house rules.",
|
|
5
5
|
"author": "Jérémy Barbet <jeremgraph@gmail.com> (https://github.com/jeremybarbet)",
|
|
6
6
|
"repository": "https://github.com/jeremybarbet/oxlint-plugin",
|