Description
I want to write custom rules and then tests for my custom Oxlint rule, and currently cannot do that out-of-the-box with vite-plus.
This doesn't work, and no sub-exports exist for the lint path at all.
Suggested solution
// oxlint-plugin/rules/no-record-string-unknown.js
import { defineRule } from "vite-plus/lint/plugins";
export const noRecordStringUnknown = defineRule({
meta: {
type: "suggestion",
docs: { description: "Cool rule" }
},
createOnce(context) {
return {
console.log('foo');
}
},
});
// oxlint-plugin/index.js
import { definePlugin } from "vite-plus/lint/plugins";
import { noRecordStringUnknown } from "./rules/no-record-string-unknown.js";
export default definePlugin({
meta: { name: "test-app" },
rules: { "no-record-string-unknown": noRecordStringUnknown },
});
import { RuleTester } from "vite-plus/lint/plugins-dev";
import { describe, it } from "vite-plus/test";
import { noRecordStringUnknown } from "./no-record-string-unknown.js";
// This is admittedly jank but seemingly the intended way to do it.
RuleTester.describe = describe;
RuleTester.it = it;
const ruleTester = new RuleTester();
ruleTester.run("no-record-string-unknown", noRecordStringUnknown, {
valid: [
{ code: "let goodCode = true;" },
],
invalid: [
{
code: "let badCode = true;",
filename: "a.ts",
errors: [{ messageId: "noRecordStringUnknown" }],
},
],
});
Alternative
No response
Additional context
No response
Validations
Description
I want to write custom rules and then tests for my custom Oxlint rule, and currently cannot do that out-of-the-box with vite-plus.
This doesn't work, and no sub-exports exist for the lint path at all.
Suggested solution
Alternative
No response
Additional context
No response
Validations