Skip to content

Commit 73f416e

Browse files
committed
cleanup(linter): drop the oxlint extensions plugin option
Oxlint has no extension setting of its own -- no --ext flag, nothing in its config schema -- and the option never reached the binary. It only gated whether a project got an inferred target, so narrowing it deleted targets rather than narrowing what was linted.
1 parent 3a82bec commit 73f416e

2 files changed

Lines changed: 12 additions & 11 deletions

File tree

astro-docs/src/content/docs/technologies/oxlint/introduction.mdoc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,19 +84,21 @@ To change how one project is linted, add arguments to the inferred target in its
8484
}
8585
```
8686

87-
To change it everywhere, pass options to the plugin in `nx.json`. `targetName` overrides the automatic choice described above, and `extensions` controls which files count as lintable:
87+
The plugin itself takes one option, `targetName`. `nx add @nx/oxlint` already writes it into `nx.json` with the name it picked from the list above, so edit that entry when you want a different one:
8888

8989
```json
9090
{
9191
"plugins": [
9292
{
9393
"plugin": "@nx/oxlint",
94-
"options": { "targetName": "oxlint", "extensions": ["ts", "tsx"] }
94+
"options": { "targetName": "oxlint" }
9595
}
9696
]
9797
}
9898
```
9999

100+
Which files Oxlint lints is not an Nx setting. Oxlint selects those itself; narrow them with `ignorePatterns` in `.oxlintrc.json`, or scope individual rules with `overrides`.
101+
100102
## Type-aware linting
101103

102104
The Oxlint type-aware rules need the `oxlint-tsgolint` package, which bundles its own TypeScript compiler. Your workspace's TypeScript version doesn't matter.

packages/oxlint/src/plugins/plugin.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,14 @@ import { OXLINT_CONFIG_FILENAMES } from '../utils/config-file.js';
3232

3333
export interface OxlintPluginOptions {
3434
targetName?: string;
35-
extensions?: string[];
3635
}
3736

38-
/** Source types Oxlint can parse. It does not lint JSON. */
39-
const DEFAULT_EXTENSIONS = [
37+
/**
38+
* Source types Oxlint can parse. It does not lint JSON. Not configurable:
39+
* Oxlint picks the files it lints itself, so this only decides whether a
40+
* project has anything worth inferring a target for.
41+
*/
42+
const LINTABLE_EXTENSIONS = [
4043
'js',
4144
'mjs',
4245
'cjs',
@@ -49,6 +52,7 @@ const DEFAULT_EXTENSIONS = [
4952
'svelte',
5053
'astro',
5154
];
55+
const LINTABLE_FILES_GLOB = `**/*.{${LINTABLE_EXTENSIONS.join(',')}}`;
5256
const PROJECT_CONFIG_FILENAMES = ['project.json', 'package.json'];
5357
const OXLINT_CONFIG_GLOB = combineGlobPatterns([
5458
...OXLINT_CONFIG_FILENAMES.map((f) => `**/${f}`),
@@ -155,7 +159,6 @@ export const createNodes: CreateNodes<OxlintPluginOptions> = [
155159
const getLintableFilesPerProjectRoot = () =>
156160
(lintableFilesPerProjectRoot ??= collectLintableFilesByProjectRoot(
157161
projectRoots,
158-
options,
159162
context
160163
));
161164

@@ -469,13 +472,12 @@ function collectTsconfigChainsByProjectRoot(
469472
*/
470473
async function collectLintableFilesByProjectRoot(
471474
projectRoots: string[],
472-
options: OxlintPluginOptions,
473475
context: CreateNodesContext
474476
): Promise<Map<string, number>> {
475477
const lintableFilesPerProjectRoot = new Map<string, number>();
476478

477479
const lintableFiles = await globWithWorkspaceContext(context.workspaceRoot, [
478-
`**/*.{${options.extensions.join(',')}}`,
480+
LINTABLE_FILES_GLOB,
479481
]);
480482

481483
for (const projectRoot of projectRoots) {
@@ -597,9 +599,6 @@ function getProjectUsingOxlintConfig(
597599
function normalizeOptions(options: OxlintPluginOptions): OxlintPluginOptions {
598600
return {
599601
targetName: options?.targetName ?? 'lint',
600-
extensions: (options?.extensions ?? DEFAULT_EXTENSIONS).map((f) =>
601-
f.replace(/^\.+/, '')
602-
),
603602
};
604603
}
605604

0 commit comments

Comments
 (0)