Clean up @babel/eslint-plugin-development (#10757)
* Clean up @babel/eslint-plugin-development * Add directory field to package.json
This commit is contained in:
parent
e239eb4c55
commit
0b06b23b00
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@babel/eslint-plugin-development",
|
"name": "@babel/eslint-plugin-development",
|
||||||
"version": "1.0.1",
|
"version": "0.0.0",
|
||||||
"description": "A set of eslint rules to enforce best practices in the development of Babel plugins.",
|
"description": "ESLint rules that enforce best practices in the development of Babel plugins.",
|
||||||
"private": true,
|
"private": true,
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"eslint",
|
"eslint",
|
||||||
@ -26,6 +26,11 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/babel/eslint-plugin-babel-plugin.git"
|
"url": "https://github.com/babel/babel.git",
|
||||||
}
|
"directory": "eslint/babel-eslint-plugin-development"
|
||||||
|
},
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/babel/babel/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/babel/babel/tree/master/eslint/babel-eslint-plugin-development"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,11 @@
|
|||||||
"use strict";
|
import noDeprecatedClone from "./rules/no-deprecated-clone";
|
||||||
|
import noUndefinedIdentifier from "./rules/no-undefined-identifier";
|
||||||
|
import pluginName from "./rules/plugin-name";
|
||||||
|
|
||||||
module.exports = {
|
export default {
|
||||||
rules: {
|
rules: {
|
||||||
"no-deprecated-clone": require("./rules/no-deprecated-clone"),
|
"no-deprecated-clone": noDeprecatedClone,
|
||||||
"no-undefined-identifier": require("./rules/no-undefined-identifier"),
|
"no-undefined-identifier": noUndefinedIdentifier,
|
||||||
"plugin-name": require("./rules/plugin-name"),
|
"plugin-name": pluginName,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,9 +1,7 @@
|
|||||||
"use strict";
|
import getReferenceOrigin from "../utils/get-reference-origin";
|
||||||
|
import isFromBabelTypes from "../utils/is-from-babel-types";
|
||||||
|
|
||||||
const getReferenceOrigin = require("../utils/get-reference-origin");
|
export default {
|
||||||
const isFromBabelTypes = require("../utils/is-from-babel-types");
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
meta: {
|
meta: {
|
||||||
schema: [],
|
schema: [],
|
||||||
fixable: "code",
|
fixable: "code",
|
||||||
|
|||||||
@ -1,7 +1,5 @@
|
|||||||
"use strict";
|
import getReferenceOrigin from "../utils/get-reference-origin";
|
||||||
|
import isFromBabelTypes from "../utils/is-from-babel-types";
|
||||||
const getReferenceOrigin = require("../utils/get-reference-origin");
|
|
||||||
const isFromBabelTypes = require("../utils/is-from-babel-types");
|
|
||||||
|
|
||||||
function firstArgumentIsUndefinedString(argumentsArray) {
|
function firstArgumentIsUndefinedString(argumentsArray) {
|
||||||
return (
|
return (
|
||||||
@ -11,7 +9,7 @@ function firstArgumentIsUndefinedString(argumentsArray) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
export default {
|
||||||
meta: {
|
meta: {
|
||||||
schema: [],
|
schema: [],
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,6 +1,4 @@
|
|||||||
"use strict";
|
import isBabelPluginFactory from "../utils/is-babel-plugin-factory";
|
||||||
|
|
||||||
const isBabelPluginFactory = require("../utils/is-babel-plugin-factory");
|
|
||||||
|
|
||||||
function getReturnValue(node) {
|
function getReturnValue(node) {
|
||||||
const { body } = node;
|
const { body } = node;
|
||||||
@ -14,7 +12,7 @@ function getReturnValue(node) {
|
|||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
export default {
|
||||||
meta: {
|
meta: {
|
||||||
schema: [],
|
schema: [],
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,6 +1,4 @@
|
|||||||
"use strict";
|
export default function getExportName(node) {
|
||||||
|
|
||||||
module.exports = function getExportName(node) {
|
|
||||||
const { parent } = node;
|
const { parent } = node;
|
||||||
|
|
||||||
if (parent.type === "ExportDefaultDeclaration") {
|
if (parent.type === "ExportDefaultDeclaration") {
|
||||||
@ -21,4 +19,4 @@ module.exports = function getExportName(node) {
|
|||||||
) {
|
) {
|
||||||
return "module.exports";
|
return "module.exports";
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|||||||
@ -1,7 +1,3 @@
|
|||||||
"use strict";
|
|
||||||
|
|
||||||
module.exports = getReferenceOrigin;
|
|
||||||
|
|
||||||
/*::
|
/*::
|
||||||
type ReferenceOriginImport = { kind: "import", source: string, name: string };
|
type ReferenceOriginImport = { kind: "import", source: string, name: string };
|
||||||
type ReferenceOriginParam = {
|
type ReferenceOriginParam = {
|
||||||
@ -26,7 +22,10 @@ type ReferenceOrigin =
|
|||||||
// from.
|
// from.
|
||||||
// It resolves imports, parameters of exported functions and property accesses.
|
// It resolves imports, parameters of exported functions and property accesses.
|
||||||
// See the ReferenceOrigin type for more informations.
|
// See the ReferenceOrigin type for more informations.
|
||||||
function getReferenceOrigin(node, scope) /*: ?ReferenceOrigin */ {
|
export default function getReferenceOrigin(
|
||||||
|
node,
|
||||||
|
scope,
|
||||||
|
) /*: ?ReferenceOrigin */ {
|
||||||
if (node.type === "Identifier") {
|
if (node.type === "Identifier") {
|
||||||
const variable = getVariableDefinition(node.name, scope);
|
const variable = getVariableDefinition(node.name, scope);
|
||||||
if (!variable) return null;
|
if (!variable) return null;
|
||||||
|
|||||||
@ -1,9 +1,7 @@
|
|||||||
"use strict";
|
import getReferenceOrigin from "./get-reference-origin";
|
||||||
|
import getExportName from "./get-export-name";
|
||||||
|
|
||||||
const getReferenceOrigin = require("./get-reference-origin");
|
export default function isBabelPluginFactory(node, scope) {
|
||||||
const getExportName = require("./get-export-name");
|
|
||||||
|
|
||||||
module.exports = function isBabelPluginFactory(node, scope) {
|
|
||||||
const { parent } = node;
|
const { parent } = node;
|
||||||
|
|
||||||
if (parent.type === "CallExpression") {
|
if (parent.type === "CallExpression") {
|
||||||
@ -23,4 +21,4 @@ module.exports = function isBabelPluginFactory(node, scope) {
|
|||||||
// export default function ({ types: t }) {}
|
// export default function ({ types: t }) {}
|
||||||
// module.exports = function ({ types: t }) {}
|
// module.exports = function ({ types: t }) {}
|
||||||
return exportName === "default" || exportName === "module.exports";
|
return exportName === "default" || exportName === "module.exports";
|
||||||
};
|
}
|
||||||
|
|||||||
@ -1,10 +1,8 @@
|
|||||||
"use strict";
|
import isBabelPluginFactory from "./is-babel-plugin-factory";
|
||||||
|
|
||||||
const isBabelPluginFactory = require("./is-babel-plugin-factory");
|
|
||||||
|
|
||||||
// Check if a ReferenceOrigin (returned by ./get-reference-origin.js)
|
// Check if a ReferenceOrigin (returned by ./get-reference-origin.js)
|
||||||
// is a reference to a @babel/types export.
|
// is a reference to a @babel/types export.
|
||||||
module.exports = function isFromBabelTypes(
|
export default function isFromBabelTypes(
|
||||||
origin /*: ReferenceOrigin */,
|
origin /*: ReferenceOrigin */,
|
||||||
scope /*: Scope */,
|
scope /*: Scope */,
|
||||||
) {
|
) {
|
||||||
@ -32,4 +30,4 @@ module.exports = function isFromBabelTypes(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
};
|
}
|
||||||
|
|||||||
@ -1,7 +1,5 @@
|
|||||||
"use strict";
|
import rule from "../../src/rules/no-deprecated-clone";
|
||||||
|
import { RuleTester } from "eslint";
|
||||||
const rule = require("../../src/rules/no-deprecated-clone");
|
|
||||||
const { RuleTester } = require("eslint");
|
|
||||||
|
|
||||||
const cloneError = "t.clone() is deprecated. Use t.cloneNode() instead.";
|
const cloneError = "t.clone() is deprecated. Use t.cloneNode() instead.";
|
||||||
const cloneDeepError =
|
const cloneDeepError =
|
||||||
|
|||||||
@ -1,7 +1,5 @@
|
|||||||
"use strict";
|
import rule from "../../src/rules/no-undefined-identifier";
|
||||||
|
import { RuleTester } from "eslint";
|
||||||
const rule = require("../../src/rules/no-undefined-identifier");
|
|
||||||
const { RuleTester } = require("eslint");
|
|
||||||
|
|
||||||
const error =
|
const error =
|
||||||
"Use path.scope.buildUndefinedNode() to create an undefined identifier directly.";
|
"Use path.scope.buildUndefinedNode() to create an undefined identifier directly.";
|
||||||
|
|||||||
@ -1,7 +1,5 @@
|
|||||||
"use strict";
|
import rule from "../../src/rules/plugin-name";
|
||||||
|
import { RuleTester } from "eslint";
|
||||||
const rule = require("../../src/rules/plugin-name");
|
|
||||||
const { RuleTester } = require("eslint");
|
|
||||||
|
|
||||||
const missingPluginError = "This file does not export a Babel plugin.";
|
const missingPluginError = "This file does not export a Babel plugin.";
|
||||||
const missingNameError = "This Babel plugin doesn't have a 'name' property.";
|
const missingNameError = "This Babel plugin doesn't have a 'name' property.";
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user