mirror of
https://github.com/oxc-project/oxc.git
synced 2026-09-14 19:36:11 +08:00
1193c9dbaf
dogfood
40 lines
1.0 KiB
TypeScript
40 lines
1.0 KiB
TypeScript
import type { Plugin } from "#oxlint/plugins";
|
|
|
|
const plugin: Plugin = {
|
|
meta: {
|
|
name: "parents",
|
|
},
|
|
rules: {
|
|
check: {
|
|
create(context) {
|
|
function reportAncestry(node: any) {
|
|
context.report({
|
|
message:
|
|
`${node.type}:\n`
|
|
+ `parent: ${node.parent?.type}\n`
|
|
+ `ancestors: [ ${context.sourceCode
|
|
.getAncestors(node)
|
|
// @ts-expect-error - TODO: Shouldn't be an error. We need to fix our types.
|
|
.map((node) => node.type)
|
|
.join(", ")} ]`,
|
|
node,
|
|
});
|
|
}
|
|
|
|
return {
|
|
Program: reportAncestry,
|
|
VariableDeclaration: reportAncestry,
|
|
VariableDeclarator: reportAncestry,
|
|
Identifier: reportAncestry,
|
|
ObjectExpression: reportAncestry,
|
|
Property: reportAncestry,
|
|
ArrayExpression: reportAncestry,
|
|
SpreadElement: reportAncestry,
|
|
};
|
|
},
|
|
},
|
|
},
|
|
};
|
|
|
|
export default plugin;
|