What version of Oxlint are you using?
1.36.0
What command did you run?
N/A
What does your .oxlintrc.json config file look like?
What happened?
Basically, when a file is a node script with a #!/usr/bin/env node as the first line, applying the quick fix for "disable rule for whole file" creates an invalid file. If we have a hashbang line, we should apply the oxlint-disable on the second line of the file.
I have a reproduction repro here: https://github.com/connorshea/oxlint-disable-directive-issue-repro
Reproduction steps:
git clone https://github.com/connorshea/oxlint-disable-directive-issue-repro
cd oxlint-disable-directive-issue-repro
npm install
- Open the repo in VS Code (or another LSP-based editor that supports quick fixes)
- Open
index.js, which looks like this:
#!/usr/bin/env node
// If I try to apply the "disable rule for whole file" fix here,
// it will go to the top of the file. I want to keep the
// `#!/usr/bin/env node` line as the first thing in the file
// so the file is valid.
console.log("this isn't allowed :)");
On the console.log line, there is a diagnostic which can be quick-fixed:
If you fix it by applying the "disable no-console for this whole file" quick fix, the result is this code, which is invalid:
// oxlint-disable no-console
#!/usr/bin/env node
// If I try to apply the "disable rule for whole file" fix here,
// it will go to the top of the file. I want to keep the
// `#!/usr/bin/env node` line as the first thing in the file
// so the file is valid.
console.log("this isn't allowed :)");
What version of Oxlint are you using?
1.36.0
What command did you run?
N/A
What does your
.oxlintrc.jsonconfig file look like?{ "$schema": "./node_modules/oxlint/configuration_schema.json", "plugins": [ "eslint" ], "categories": { "correctness": "off" }, "rules": { "no-console": "error" } }What happened?
Basically, when a file is a node script with a
#!/usr/bin/env nodeas the first line, applying the quick fix for "disable rule for whole file" creates an invalid file. If we have a hashbang line, we should apply theoxlint-disableon the second line of the file.I have a reproduction repro here: https://github.com/connorshea/oxlint-disable-directive-issue-repro
Reproduction steps:
git clone https://github.com/connorshea/oxlint-disable-directive-issue-reprocd oxlint-disable-directive-issue-repronpm installindex.js, which looks like this:On the
console.logline, there is a diagnostic which can be quick-fixed:If you fix it by applying the "disable no-console for this whole file" quick fix, the result is this code, which is invalid: