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).
39 lines
833 B
TypeScript
39 lines
833 B
TypeScript
import assert from "node:assert";
|
|
import type { Plugin, Rule } from "#oxlint/plugins";
|
|
|
|
const unicodeCommentsRule: Rule = {
|
|
create(context) {
|
|
const { sourceCode } = context;
|
|
|
|
for (const comment of sourceCode.getAllComments()) {
|
|
assert(comment.start === comment.range[0]);
|
|
assert(comment.end === comment.range[1]);
|
|
const { start, end } = comment.loc;
|
|
context.report({
|
|
message: JSON.stringify(
|
|
{
|
|
lines: `${start.line},${start.column}-${end.line},${end.column}`,
|
|
value: comment.value,
|
|
},
|
|
null,
|
|
4,
|
|
),
|
|
node: comment,
|
|
});
|
|
}
|
|
|
|
return {};
|
|
},
|
|
};
|
|
|
|
const plugin: Plugin = {
|
|
meta: {
|
|
name: "unicode-comments",
|
|
},
|
|
rules: {
|
|
"unicode-comments": unicodeCommentsRule,
|
|
},
|
|
};
|
|
|
|
export default plugin;
|