mirror of
https://github.com/hanzoai/babel.git
synced 2026-09-24 16:56:45 +00:00
* chore: bundle babel-cli and babel-node * chore: bundle babel-helper-builder-react-jsx * refactor: unify extra entrypoints handling * chore: bundle babel-helper-transform-fixture-test-runner * chore: bundle babel-helper-fixtures * build: bundle babel-helpers * build: bundle babel-build-external-helpers * refactor: reuse pkgJSON in PackageInfo * refactor: skip inputs path normalization * build: bundle babel-eslint-parser * fixup babel-helpers * revert babel-cli bin changes * update npm-ignore generators * cleanup outdated comments * test(eslint): avoid private sub imports * chore: bundle babel-eslint-* * chore: bundle babel-register * chore: skip rollup for private packages
79 lines
2.4 KiB
JavaScript
79 lines
2.4 KiB
JavaScript
import plugin from "../../lib/index.js";
|
|
import RuleTester from "../../../babel-eslint-shared-fixtures/utils/RuleTester.js";
|
|
|
|
const rule = plugin.rules["no-undefined-identifier"];
|
|
|
|
const error =
|
|
"Use t.buildUndefinedNode() to create an undefined identifier directly.";
|
|
|
|
const ruleTester = new RuleTester();
|
|
|
|
ruleTester.run("no-undefined-identifier", rule, {
|
|
valid: [
|
|
`_.identifier("undefined")`,
|
|
`_.Identifier("undefined")`,
|
|
`import * as t from "lib"; t.identifier("undefined");`,
|
|
`function f(_) { _.types.identifier("undefined"); }`,
|
|
`import * as t from "@babel/types"; t.identifier("not_undefined");`,
|
|
`t.buildUndefinedNode();`,
|
|
],
|
|
invalid: [
|
|
{
|
|
code: `import { identifier } from "@babel/types"; identifier("undefined");`,
|
|
errors: [error],
|
|
},
|
|
{
|
|
code: `import { Identifier } from "@babel/types"; Identifier("undefined");`,
|
|
errors: [error],
|
|
},
|
|
{
|
|
code: `import * as t from "@babel/types"; t.identifier("undefined");`,
|
|
errors: [error],
|
|
},
|
|
{
|
|
code: `import * as t from "@babel/types"; var { identifier } = t; identifier("undefined");`,
|
|
errors: [error],
|
|
},
|
|
{
|
|
code: `import { identifier as id } from "@babel/types"; id("undefined");`,
|
|
errors: [error],
|
|
},
|
|
{
|
|
code: `import * as babel from "@babel/core"; babel.types.identifier("undefined");`,
|
|
errors: [error],
|
|
},
|
|
{
|
|
code: `import { types } from "@babel/core"; types.identifier("undefined");`,
|
|
errors: [error],
|
|
},
|
|
{
|
|
code: `import { types as t } from "@babel/core"; t.identifier("undefined");`,
|
|
errors: [error],
|
|
},
|
|
{
|
|
code: `export default function plugin(babel) { babel.types.identifier("undefined") }`,
|
|
errors: [error],
|
|
},
|
|
{
|
|
code: `export default function plugin({ types }) { types.identifier("undefined") }`,
|
|
errors: [error],
|
|
},
|
|
{
|
|
code: `export default function plugin({ types: t }) { t.identifier("undefined") }`,
|
|
errors: [error],
|
|
},
|
|
{
|
|
code: `export default ({ types }) => { types.identifier("undefined") }`,
|
|
errors: [error],
|
|
},
|
|
{
|
|
code: `module.exports = function plugin({ types }) { types.identifier("undefined") }`,
|
|
errors: [error],
|
|
},
|
|
{
|
|
code: `import { declare } from "@babel/helper-plugin-utils"; declare(({ types }) => { types.identifier("undefined") });`,
|
|
errors: [error],
|
|
},
|
|
],
|
|
});
|