cd to a temp dir, run:
npm install --save-dev eslint typescript typescript-eslint \
oxlint oxlint-tsgolint
npx tsc --init
create eslint.config.mjs:
import { defineConfig } from "eslint/config"
import tseslint from "typescript-eslint"
export default defineConfig({
files: ["test.ts"],
extends: [tseslint.configs.base],
rules: {
"@typescript-eslint/non-nullable-type-assertion-style": "error",
},
languageOptions: {
parserOptions: {
projectService: true,
},
},
})
create .oxlintrc.json:
create test.ts:
const href = (document.querySelector(".anchor") as HTMLAnchorElement).href
npx eslint ; npx oxlint
# Both prompt "Use a ! assertion to more succinctly remove null and undefined from the type."
Both npx eslint --fix and npx oxlint --fix apply the same fix:
-const href = (document.querySelector(".anchor") as HTMLAnchorElement).href
+const href = (document.querySelector(".anchor")!).href
The issue is in typescript-eslint repo labelled "external" "wontfix" "working as intended"
typescript-eslint/typescript-eslint#528 (comment)
typescript-eslint/typescript-eslint#9007 (comment)
Maybe at least for oxlint the auto-fix can be marked as "dangerous fix"?
cd to a temp dir, run:
npm install --save-dev eslint typescript typescript-eslint \ oxlint oxlint-tsgolint npx tsc --initcreate
eslint.config.mjs:create
.oxlintrc.json:{ "options": { "typeAware": true }, "categories": { "correctness": "off" }, "rules": { "typescript/non-nullable-type-assertion-style": "error" } }create
test.ts:Both
npx eslint --fixandnpx oxlint --fixapply the same fix:The issue is in typescript-eslint repo labelled "external" "wontfix" "working as intended"
Maybe at least for oxlint the auto-fix can be marked as "dangerous fix"?