mirror of
https://github.com/oxc-project/oxc.git
synced 2026-09-14 19:36:11 +08:00
9de9385fd1
Part of #18610. Our intent is to move `definePlugin`, `defineRule`, and `eslintCompatPlugin` to a separate package `@oxlint/plugins` (plural to avoid confusion with naming convention for plugins `oxlint-plugin-xxx`). So rename the current entry point which exports these functions from `oxlint/plugin` to `oxlint/plugins` (plural).
48 lines
887 B
TypeScript
48 lines
887 B
TypeScript
import type { Node, Plugin, Rule } from "#oxlint/plugins";
|
|
|
|
const SPAN: Node = {
|
|
start: 0,
|
|
end: 0,
|
|
range: [0, 0],
|
|
loc: {
|
|
start: { line: 0, column: 0 },
|
|
end: { line: 0, column: 0 },
|
|
},
|
|
};
|
|
|
|
const rule: Rule = {
|
|
create(context) {
|
|
const { settings } = context;
|
|
|
|
// Report each setting key and value
|
|
Object.keys(settings).forEach((key) => {
|
|
const value = settings[key];
|
|
context.report({
|
|
message: `setting ${key}: ${JSON.stringify(value)}`,
|
|
node: SPAN,
|
|
});
|
|
});
|
|
|
|
// Also report if settings object is empty
|
|
if (Object.keys(settings).length === 0) {
|
|
context.report({
|
|
message: "settings is empty",
|
|
node: SPAN,
|
|
});
|
|
}
|
|
|
|
return {};
|
|
},
|
|
};
|
|
|
|
const plugin: Plugin = {
|
|
meta: {
|
|
name: "context-settings-plugin",
|
|
},
|
|
rules: {
|
|
"log-settings": rule,
|
|
},
|
|
};
|
|
|
|
export default plugin;
|