| 1 | import type { CreateRule, Visitor } from "@oxlint/plugins" |
| 2 | |
| 3 | const rule: CreateRule = { |
| 4 | meta: { |
| 5 | type: "problem", |
| 6 | docs: { description: "Disallow bigint literals" }, |
| 7 | fixable: "code" |
| 8 | }, |
| 9 | create(context) { |
| 10 | return { |
| 11 | Literal(node) { |
| 12 | if (typeof node.value === "bigint") { |
| 13 | const fixedSource = `BigInt("${node.value}")` |
| 14 | context.report({ |
| 15 | node, |
| 16 | message: "BigInt literals are not allowed", |
| 17 | fix: (fixer) => fixer.replaceText(node, fixedSource) |
| 18 | }) |
| 19 | } |
| 20 | } |
| 21 | } as Visitor |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | export default rule |