Fix linting in ESLint packages (#10712)
* Lint eslint/* * Run "make fix-js" * Fix remaining problems * Remove linting from subpackages * Remove husky * Add back eslint dep
This commit is contained in:
parent
17dfdab7d2
commit
b4c42601d1
@ -24,3 +24,7 @@ packages/babel-preset-env-standalone/babel-preset-env.min.js
|
||||
packages/babel-standalone/babel.js
|
||||
packages/babel-standalone/babel.min.js
|
||||
packages/babel-parser/test/expressions
|
||||
|
||||
eslint/*/node_modules
|
||||
eslint/*/test
|
||||
eslint/*/tests
|
||||
|
||||
2
Makefile
2
Makefile
@ -6,7 +6,7 @@ FORCE_PUBLISH = "@babel/runtime,@babel/runtime-corejs2,@babel/runtime-corejs3,@b
|
||||
# Fix color output until TravisCI fixes https://github.com/travis-ci/travis-ci/issues/7967
|
||||
export FORCE_COLOR = true
|
||||
|
||||
SOURCES = packages codemods
|
||||
SOURCES = packages codemods eslint
|
||||
|
||||
.PHONY: build build-dist watch lint fix clean test-clean test-only test test-ci publish bootstrap
|
||||
|
||||
|
||||
@ -4,12 +4,12 @@ module.exports = {
|
||||
plugins: ["flowtype"],
|
||||
parserOptions: {
|
||||
ecmaVersion: 2017,
|
||||
sourceType: "module"
|
||||
sourceType: "module",
|
||||
},
|
||||
rules: {
|
||||
"camelcase": "off",
|
||||
camelcase: "off",
|
||||
"consistent-return": "off",
|
||||
"curly": ["error", "multi-line"],
|
||||
curly: ["error", "multi-line"],
|
||||
"linebreak-style": ["error", "unix"],
|
||||
"max-len": ["error", 110, 2],
|
||||
"new-cap": "off",
|
||||
@ -31,18 +31,18 @@ module.exports = {
|
||||
"no-use-before-define": "off",
|
||||
"no-var": "error",
|
||||
"prefer-const": "error",
|
||||
"strict": "off",
|
||||
strict: "off",
|
||||
"flowtype/define-flow-type": "warn",
|
||||
"flowtype/use-flow-type": "warn",
|
||||
},
|
||||
globals: {
|
||||
// Flow
|
||||
Iterator: true,
|
||||
$Keys: true
|
||||
$Keys: true,
|
||||
},
|
||||
env: {
|
||||
node: true,
|
||||
es6: true,
|
||||
browser: true
|
||||
}
|
||||
browser: true,
|
||||
},
|
||||
};
|
||||
|
||||
@ -1 +0,0 @@
|
||||
*.json
|
||||
@ -1,3 +0,0 @@
|
||||
{
|
||||
"trailingComma": "es5"
|
||||
}
|
||||
@ -13,11 +13,7 @@
|
||||
},
|
||||
"homepage": "https://github.com/babel/babel-eslint",
|
||||
"scripts": {
|
||||
"test": "npm run lint && npm run test-only",
|
||||
"test-only": "cd test && mocha specs && cd -",
|
||||
"lint": "eslint .",
|
||||
"lint-fix": "npm run lint -- --fix",
|
||||
"precommit": "lint-staged",
|
||||
"test": "cd test && mocha specs && cd -",
|
||||
"preversion": "npm test",
|
||||
"changelog": "git log `git describe --tags --abbrev=0`..HEAD --pretty=format:' * %s (%an)' | grep -v 'Merge pull request'"
|
||||
},
|
||||
@ -52,23 +48,9 @@
|
||||
"@babel/preset-env": "^7.1.5",
|
||||
"@babel/preset-flow": "^7.0.0",
|
||||
"@babel/preset-react": "^7.0.0",
|
||||
"babel-eslint": "^10.0.2",
|
||||
"dedent": "^0.7.0",
|
||||
"eslint": "^6.0.1",
|
||||
"eslint-config-babel": "^9.0.0",
|
||||
"eslint-plugin-flowtype": "^3.11.1",
|
||||
"eslint-plugin-import": "^2.14.0",
|
||||
"eslint-plugin-prettier": "^3.1.0",
|
||||
"espree": "^6.0.0",
|
||||
"husky": "^1.0.0-rc.13",
|
||||
"lint-staged": "^7.2.2",
|
||||
"mocha": "^6.1.4",
|
||||
"prettier": "^1.4.4"
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.js": [
|
||||
"eslint --format=codeframe --fix",
|
||||
"git add"
|
||||
]
|
||||
"mocha": "^6.1.4"
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,20 +0,0 @@
|
||||
{
|
||||
"root": true,
|
||||
"extends": "eslint:recommended",
|
||||
"plugins": ["prettier"],
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 2018,
|
||||
"sourceType": "script"
|
||||
},
|
||||
"env": {
|
||||
"node": true
|
||||
},
|
||||
"rules": {
|
||||
"prettier/prettier": "error",
|
||||
|
||||
"curly": ["error", "multi-line"],
|
||||
"linebreak-style": ["error", "unix"],
|
||||
"no-var": "error",
|
||||
"prefer-const": "error"
|
||||
}
|
||||
}
|
||||
@ -1,11 +0,0 @@
|
||||
{
|
||||
"arrowParens": "avoid",
|
||||
"trailingComma": "all",
|
||||
"useTabs": false,
|
||||
"semi": true,
|
||||
"singleQuote": false,
|
||||
"bracketSpacing": true,
|
||||
"jsxBracketSameLine": false,
|
||||
"tabWidth": 2,
|
||||
"printWidth": 80
|
||||
}
|
||||
@ -14,14 +14,11 @@
|
||||
},
|
||||
"main": "src/index.js",
|
||||
"scripts": {
|
||||
"test": "mocha tests --recursive",
|
||||
"lint": "eslint src tests"
|
||||
"test": "mocha tests --recursive"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^5.9.0",
|
||||
"eslint-plugin-prettier": "^3.0.0",
|
||||
"mocha": "^5.2.0",
|
||||
"prettier": "^1.15.2"
|
||||
"mocha": "^5.2.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8.0.0"
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
// @flow
|
||||
|
||||
"use strict";
|
||||
|
||||
const getReferenceOrigin = require("../utils/get-reference-origin");
|
||||
|
||||
@ -32,7 +32,7 @@ module.exports = {
|
||||
) {
|
||||
context.report(
|
||||
node,
|
||||
"Use path.scope.buildUndefinedNode() to create an undefined identifier directly.",
|
||||
"Use path.scope.buildUndefinedNode() to create an undefined identifier directly."
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
@ -44,7 +44,7 @@ module.exports = {
|
||||
if (!returnValue.properties.some(p => p.key.name === "name")) {
|
||||
context.report(
|
||||
returnValue,
|
||||
"This Babel plugin doesn't have a 'name' property.",
|
||||
"This Babel plugin doesn't have a 'name' property."
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@ const isBabelPluginFactory = require("./is-babel-plugin-factory");
|
||||
// is a reference to a @babel/types export.
|
||||
module.exports = function isFromBabelTypes(
|
||||
origin /*: ReferenceOrigin */,
|
||||
scope /*: Scope */,
|
||||
scope /*: Scope */
|
||||
) {
|
||||
if (origin.kind === "import" && origin.source === "@babel/types") {
|
||||
// imported from @babel/types
|
||||
|
||||
@ -1,38 +1,38 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
rules: {
|
||||
'array-bracket-spacing': require('./rules/array-bracket-spacing'),
|
||||
'arrow-parens': require('./rules/arrow-parens'),
|
||||
'flow-object-type': require('./rules/flow-object-type'),
|
||||
'func-params-comma-dangle': require('./rules/func-params-comma-dangle'),
|
||||
'generator-star-spacing': require('./rules/generator-star-spacing'),
|
||||
'new-cap': require('./rules/new-cap'),
|
||||
'camelcase': require('./rules/camelcase'),
|
||||
'no-await-in-loop': require('./rules/no-await-in-loop'),
|
||||
'no-invalid-this': require('./rules/no-invalid-this'),
|
||||
'no-unused-expressions': require('./rules/no-unused-expressions'),
|
||||
'object-curly-spacing': require('./rules/object-curly-spacing'),
|
||||
'object-shorthand': require('./rules/object-shorthand'),
|
||||
'quotes': require('./rules/quotes'),
|
||||
'semi': require('./rules/semi'),
|
||||
'valid-typeof': require('./rules/valid-typeof'),
|
||||
"array-bracket-spacing": require("./rules/array-bracket-spacing"),
|
||||
"arrow-parens": require("./rules/arrow-parens"),
|
||||
"flow-object-type": require("./rules/flow-object-type"),
|
||||
"func-params-comma-dangle": require("./rules/func-params-comma-dangle"),
|
||||
"generator-star-spacing": require("./rules/generator-star-spacing"),
|
||||
"new-cap": require("./rules/new-cap"),
|
||||
camelcase: require("./rules/camelcase"),
|
||||
"no-await-in-loop": require("./rules/no-await-in-loop"),
|
||||
"no-invalid-this": require("./rules/no-invalid-this"),
|
||||
"no-unused-expressions": require("./rules/no-unused-expressions"),
|
||||
"object-curly-spacing": require("./rules/object-curly-spacing"),
|
||||
"object-shorthand": require("./rules/object-shorthand"),
|
||||
quotes: require("./rules/quotes"),
|
||||
semi: require("./rules/semi"),
|
||||
"valid-typeof": require("./rules/valid-typeof"),
|
||||
},
|
||||
rulesConfig: {
|
||||
'array-bracket-spacing': 0,
|
||||
'arrow-parens': 0,
|
||||
'camelcase': 0,
|
||||
'flow-object-type': 0,
|
||||
'func-params-comma-dangle': 0,
|
||||
'generator-star-spacing': 0,
|
||||
'new-cap': 0,
|
||||
'no-await-in-loop': 0,
|
||||
'no-invalid-this': 0,
|
||||
'no-unused-expressions': 0,
|
||||
'object-curly-spacing': 0,
|
||||
'object-shorthand': 0,
|
||||
'quotes': 0,
|
||||
'semi': 0,
|
||||
'valid-typeof': 0,
|
||||
"array-bracket-spacing": 0,
|
||||
"arrow-parens": 0,
|
||||
camelcase: 0,
|
||||
"flow-object-type": 0,
|
||||
"func-params-comma-dangle": 0,
|
||||
"generator-star-spacing": 0,
|
||||
"new-cap": 0,
|
||||
"no-await-in-loop": 0,
|
||||
"no-invalid-this": 0,
|
||||
"no-unused-expressions": 0,
|
||||
"object-curly-spacing": 0,
|
||||
"object-shorthand": 0,
|
||||
quotes: 0,
|
||||
semi: 0,
|
||||
"valid-typeof": 0,
|
||||
},
|
||||
};
|
||||
|
||||
@ -1,43 +1,46 @@
|
||||
"use strict";
|
||||
|
||||
var isWarnedForDeprecation = false;
|
||||
let isWarnedForDeprecation = false;
|
||||
module.exports = {
|
||||
meta: {
|
||||
deprecated: true,
|
||||
schema: [
|
||||
{
|
||||
"enum": ["always", "never"]
|
||||
enum: ["always", "never"],
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"singleValue": {
|
||||
"type": "boolean"
|
||||
type: "object",
|
||||
properties: {
|
||||
singleValue: {
|
||||
type: "boolean",
|
||||
},
|
||||
"objectsInArrays": {
|
||||
"type": "boolean"
|
||||
objectsInArrays: {
|
||||
type: "boolean",
|
||||
},
|
||||
"arraysInArrays": {
|
||||
"type": "boolean"
|
||||
}
|
||||
arraysInArrays: {
|
||||
type: "boolean",
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
]
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
create: function() {
|
||||
return {
|
||||
Program: function() {
|
||||
if (isWarnedForDeprecation || /\=-(f|-format)=/.test(process.argv.join('='))) {
|
||||
if (
|
||||
isWarnedForDeprecation ||
|
||||
/=-(f|-format)=/.test(process.argv.join("="))
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* eslint-disable no-console */
|
||||
console.log('The babel/array-bracket-spacing rule is deprecated. Please ' +
|
||||
'use the built in array-bracket-spacing rule instead.');
|
||||
/* eslint-enable no-console */
|
||||
console.log(
|
||||
"The babel/array-bracket-spacing rule is deprecated. Please " +
|
||||
"use the built in array-bracket-spacing rule instead."
|
||||
);
|
||||
isWarnedForDeprecation = true;
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@ -1,28 +1,31 @@
|
||||
"use strict";
|
||||
|
||||
var isWarnedForDeprecation = false;
|
||||
let isWarnedForDeprecation = false;
|
||||
module.exports = {
|
||||
meta: {
|
||||
deprecated: true,
|
||||
schema: [
|
||||
{
|
||||
"enum": ["always", "as-needed"]
|
||||
}
|
||||
]
|
||||
enum: ["always", "as-needed"],
|
||||
},
|
||||
],
|
||||
},
|
||||
create: function() {
|
||||
return {
|
||||
Program: function() {
|
||||
if (isWarnedForDeprecation || /\=-(f|-format)=/.test(process.argv.join('='))) {
|
||||
if (
|
||||
isWarnedForDeprecation ||
|
||||
/=-(f|-format)=/.test(process.argv.join("="))
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* eslint-disable no-console */
|
||||
console.log('The babel/arrow-parens rule is deprecated. Please ' +
|
||||
'use the built in arrow-parens rule instead.');
|
||||
/* eslint-enable no-console */
|
||||
console.log(
|
||||
"The babel/arrow-parens rule is deprecated. Please " +
|
||||
"use the built in arrow-parens rule instead."
|
||||
);
|
||||
isWarnedForDeprecation = true;
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@ -15,7 +15,7 @@ module.exports = {
|
||||
description: "enforce camelcase naming convention",
|
||||
category: "Stylistic Issues",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/camelcase"
|
||||
url: "https://eslint.org/docs/rules/camelcase",
|
||||
},
|
||||
|
||||
schema: [
|
||||
@ -23,23 +23,22 @@ module.exports = {
|
||||
type: "object",
|
||||
properties: {
|
||||
ignoreDestructuring: {
|
||||
type: "boolean"
|
||||
type: "boolean",
|
||||
},
|
||||
properties: {
|
||||
enum: ["always", "never"]
|
||||
}
|
||||
enum: ["always", "never"],
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
],
|
||||
|
||||
messages: {
|
||||
notCamelCase: "Identifier '{{name}}' is not in camel case."
|
||||
}
|
||||
notCamelCase: "Identifier '{{name}}' is not in camel case.",
|
||||
},
|
||||
},
|
||||
|
||||
create(context) {
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Helpers
|
||||
//--------------------------------------------------------------------------
|
||||
@ -66,7 +65,6 @@ module.exports = {
|
||||
* @private
|
||||
*/
|
||||
function isUnderscored(name) {
|
||||
|
||||
// if there's an underscore, it might be A_CONSTANT, which is okay
|
||||
return name.indexOf("_") > -1 && name !== name.toUpperCase();
|
||||
}
|
||||
@ -100,7 +98,11 @@ module.exports = {
|
||||
function report(node) {
|
||||
if (reported.indexOf(node.parent) < 0) {
|
||||
reported.push(node.parent);
|
||||
context.report({ node, messageId: "notCamelCase", data: { name: node.name } });
|
||||
context.report({
|
||||
node,
|
||||
messageId: "notCamelCase",
|
||||
data: { name: node.name },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -113,30 +115,39 @@ module.exports = {
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
Identifier(node) {
|
||||
|
||||
/*
|
||||
* Leading and trailing underscores are commonly used to flag
|
||||
* private/protected identifiers, strip them
|
||||
*/
|
||||
const name = node.name.replace(/^_+|_+$/g, ""),
|
||||
effectiveParent = isMemberExpression(node.parent.type) ? node.parent.parent : node.parent;
|
||||
effectiveParent = isMemberExpression(node.parent.type)
|
||||
? node.parent.parent
|
||||
: node.parent;
|
||||
|
||||
// MemberExpressions get special rules
|
||||
if (isMemberExpression(node.parent.type)) {
|
||||
|
||||
// "never" check properties
|
||||
if (properties === "never") {
|
||||
return;
|
||||
}
|
||||
|
||||
// Always report underscored object names
|
||||
if (node.parent.object.type === "Identifier" && node.parent.object.name === node.name && isUnderscored(name)) {
|
||||
if (
|
||||
node.parent.object.type === "Identifier" &&
|
||||
node.parent.object.name === node.name &&
|
||||
isUnderscored(name)
|
||||
) {
|
||||
report(node);
|
||||
|
||||
// Report AssignmentExpressions only if they are the left side of the assignment
|
||||
} else if (effectiveParent.type === "AssignmentExpression" && isUnderscored(name) && (!isMemberExpression(effectiveParent.right.type) || isMemberExpression(effectiveParent.left.type) && effectiveParent.left.property.name === node.name)) {
|
||||
} else if (
|
||||
effectiveParent.type === "AssignmentExpression" &&
|
||||
isUnderscored(name) &&
|
||||
(!isMemberExpression(effectiveParent.right.type) ||
|
||||
(isMemberExpression(effectiveParent.left.type) &&
|
||||
effectiveParent.left.property.name === node.name))
|
||||
) {
|
||||
report(node);
|
||||
}
|
||||
|
||||
@ -145,50 +156,76 @@ module.exports = {
|
||||
* AssignmentPattern nodes can be treated like Properties:
|
||||
* e.g.: const { no_camelcased = false } = bar;
|
||||
*/
|
||||
} else if (node.parent.type === "Property" || node.parent.type === "AssignmentPattern") {
|
||||
|
||||
if (node.parent.parent && node.parent.parent.type === "ObjectPattern") {
|
||||
|
||||
const assignmentKeyEqualsValue = node.parent.key.name === node.parent.value.name;
|
||||
} else if (
|
||||
node.parent.type === "Property" ||
|
||||
node.parent.type === "AssignmentPattern"
|
||||
) {
|
||||
if (
|
||||
node.parent.parent &&
|
||||
node.parent.parent.type === "ObjectPattern"
|
||||
) {
|
||||
const assignmentKeyEqualsValue =
|
||||
node.parent.key.name === node.parent.value.name;
|
||||
|
||||
// prevent checking righthand side of destructured object
|
||||
if (node.parent.key === node && node.parent.value !== node) {
|
||||
return;
|
||||
}
|
||||
|
||||
const valueIsUnderscored = node.parent.value.name && isUnderscored(name);
|
||||
const valueIsUnderscored =
|
||||
node.parent.value.name && isUnderscored(name);
|
||||
|
||||
// ignore destructuring if the option is set, unless a new identifier is created
|
||||
if (valueIsUnderscored && !(assignmentKeyEqualsValue && ignoreDestructuring)) {
|
||||
if (
|
||||
valueIsUnderscored &&
|
||||
!(assignmentKeyEqualsValue && ignoreDestructuring)
|
||||
) {
|
||||
report(node);
|
||||
}
|
||||
}
|
||||
|
||||
// "never" check properties or always ignore destructuring
|
||||
if (properties === "never" || (ignoreDestructuring && isInsideObjectPattern(node))) {
|
||||
if (
|
||||
properties === "never" ||
|
||||
(ignoreDestructuring && isInsideObjectPattern(node))
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
// don't check right hand side of AssignmentExpression to prevent duplicate warnings
|
||||
if (isUnderscored(name) && !ALLOWED_PARENT_TYPES.has(effectiveParent.type) && !(node.parent.right === node)) {
|
||||
if (
|
||||
isUnderscored(name) &&
|
||||
!ALLOWED_PARENT_TYPES.has(effectiveParent.type) &&
|
||||
!(node.parent.right === node)
|
||||
) {
|
||||
report(node);
|
||||
}
|
||||
|
||||
// Check if it's an import specifier
|
||||
} else if (["ImportSpecifier", "ImportNamespaceSpecifier", "ImportDefaultSpecifier"].indexOf(node.parent.type) >= 0) {
|
||||
|
||||
} else if (
|
||||
[
|
||||
"ImportSpecifier",
|
||||
"ImportNamespaceSpecifier",
|
||||
"ImportDefaultSpecifier",
|
||||
].indexOf(node.parent.type) >= 0
|
||||
) {
|
||||
// Report only if the local imported identifier is underscored
|
||||
if (node.parent.local && node.parent.local.name === node.name && isUnderscored(name)) {
|
||||
if (
|
||||
node.parent.local &&
|
||||
node.parent.local.name === node.name &&
|
||||
isUnderscored(name)
|
||||
) {
|
||||
report(node);
|
||||
}
|
||||
|
||||
// Report anything that is underscored that isn't a CallExpression
|
||||
} else if (isUnderscored(name) && !ALLOWED_PARENT_TYPES.has(effectiveParent.type)) {
|
||||
} else if (
|
||||
isUnderscored(name) &&
|
||||
!ALLOWED_PARENT_TYPES.has(effectiveParent.type)
|
||||
) {
|
||||
report(node);
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
};
|
||||
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@ -1,29 +1,34 @@
|
||||
"use strict";
|
||||
|
||||
var isWarnedForDeprecation = false;
|
||||
let isWarnedForDeprecation = false;
|
||||
module.exports = {
|
||||
meta: {
|
||||
deprecated: true,
|
||||
schema: [
|
||||
{
|
||||
"enum": ["semicolon", "comma"],
|
||||
}
|
||||
]
|
||||
enum: ["semicolon", "comma"],
|
||||
},
|
||||
],
|
||||
},
|
||||
create: function() {
|
||||
return {
|
||||
Program: function() {
|
||||
if (isWarnedForDeprecation || /\=-(f|-format)=/.test(process.argv.join('='))) {
|
||||
if (
|
||||
isWarnedForDeprecation ||
|
||||
/=-(f|-format)=/.test(process.argv.join("="))
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* eslint-disable no-console */
|
||||
console.log('The babel/flow-object-type rule is deprecated. Please ' +
|
||||
'use the flowtype/object-type-delimiter rule instead.\n' +
|
||||
'Check out https://github.com/gajus/eslint-plugin-flowtype#eslint-plugin-flowtype-rules-object-type-delimiter');
|
||||
/* eslint-enable no-console */
|
||||
console.log(
|
||||
"The babel/flow-object-type rule is deprecated. Please " +
|
||||
"use the flowtype/object-type-delimiter rule instead.\n" +
|
||||
// eslint-disable-next-line
|
||||
"Check out https://github.com/gajus/eslint-plugin-flowtype#eslint-plugin-flowtype-rules-object-type-delimiter"
|
||||
);
|
||||
|
||||
isWarnedForDeprecation = true;
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@ -1,28 +1,31 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var isWarnedForDeprecation = false;
|
||||
let isWarnedForDeprecation = false;
|
||||
module.exports = {
|
||||
meta: {
|
||||
deprecated: true,
|
||||
schema: [
|
||||
{
|
||||
"enum": ["always", "always-multiline", "only-multiline", "never"]
|
||||
}
|
||||
]
|
||||
enum: ["always", "always-multiline", "only-multiline", "never"],
|
||||
},
|
||||
],
|
||||
},
|
||||
create: function() {
|
||||
return {
|
||||
Program: function() {
|
||||
if (isWarnedForDeprecation || /\=-(f|-format)=/.test(process.argv.join('='))) {
|
||||
if (
|
||||
isWarnedForDeprecation ||
|
||||
/=-(f|-format)=/.test(process.argv.join("="))
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* eslint-disable no-console */
|
||||
console.log('The babel/func-params-comma-dangle rule is deprecated. Please ' +
|
||||
'use the built in comma-dangle rule instead.');
|
||||
/* eslint-enable no-console */
|
||||
console.log(
|
||||
"The babel/func-params-comma-dangle rule is deprecated. Please " +
|
||||
"use the built in comma-dangle rule instead."
|
||||
);
|
||||
isWarnedForDeprecation = true;
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@ -1,40 +1,43 @@
|
||||
"use strict";
|
||||
|
||||
var isWarnedForDeprecation = false;
|
||||
let isWarnedForDeprecation = false;
|
||||
module.exports = {
|
||||
meta: {
|
||||
deprecated: true,
|
||||
schema: [
|
||||
{
|
||||
"oneOf": [
|
||||
oneOf: [
|
||||
{
|
||||
"enum": ["before", "after", "both", "neither"]
|
||||
enum: ["before", "after", "both", "neither"],
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"before": {"type": "boolean"},
|
||||
"after": {"type": "boolean"}
|
||||
type: "object",
|
||||
properties: {
|
||||
before: { type: "boolean" },
|
||||
after: { type: "boolean" },
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
create: function() {
|
||||
return {
|
||||
Program: function() {
|
||||
if (isWarnedForDeprecation || /\=-(f|-format)=/.test(process.argv.join('='))) {
|
||||
if (
|
||||
isWarnedForDeprecation ||
|
||||
/=-(f|-format)=/.test(process.argv.join("="))
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* eslint-disable no-console */
|
||||
console.log('The babel/generator-star-spacing rule is deprecated. Please ' +
|
||||
'use the built in generator-star-spacing rule instead.');
|
||||
/* eslint-enable no-console */
|
||||
console.log(
|
||||
"The babel/generator-star-spacing rule is deprecated. Please " +
|
||||
"use the built in generator-star-spacing rule instead."
|
||||
);
|
||||
isWarnedForDeprecation = true;
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
"use strict";
|
||||
|
||||
const ruleComposer = require('eslint-rule-composer');
|
||||
const eslint = require('eslint');
|
||||
const newCapRule = new eslint.Linter().getRules().get('new-cap');
|
||||
const ruleComposer = require("eslint-rule-composer");
|
||||
const eslint = require("eslint");
|
||||
const newCapRule = new eslint.Linter().getRules().get("new-cap");
|
||||
|
||||
/**
|
||||
* Returns whether a node is under a decorator or not.
|
||||
@ -15,5 +15,5 @@ function isDecorator(node) {
|
||||
|
||||
module.exports = ruleComposer.filterReports(
|
||||
newCapRule,
|
||||
(problem, metadata) => !isDecorator(problem.node)
|
||||
problem => !isDecorator(problem.node)
|
||||
);
|
||||
|
||||
@ -1,24 +1,27 @@
|
||||
"use strict";
|
||||
|
||||
var isWarnedForDeprecation = false;
|
||||
let isWarnedForDeprecation = false;
|
||||
module.exports = {
|
||||
meta: {
|
||||
deprecated: true,
|
||||
schema: []
|
||||
schema: [],
|
||||
},
|
||||
create: function() {
|
||||
return {
|
||||
Program: function() {
|
||||
if (isWarnedForDeprecation || /\=-(f|-format)=/.test(process.argv.join('='))) {
|
||||
if (
|
||||
isWarnedForDeprecation ||
|
||||
/=-(f|-format)=/.test(process.argv.join("="))
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* eslint-disable no-console */
|
||||
console.log('The babel/no-await-in-loop rule is deprecated. Please ' +
|
||||
'use the built in no-await-in-loop rule instead.');
|
||||
/* eslint-enable no-console */
|
||||
console.log(
|
||||
"The babel/no-await-in-loop rule is deprecated. Please " +
|
||||
"use the built in no-await-in-loop rule instead."
|
||||
);
|
||||
isWarnedForDeprecation = true;
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@ -1,18 +1,15 @@
|
||||
"use strict";
|
||||
|
||||
const ruleComposer = require('eslint-rule-composer');
|
||||
const eslint = require('eslint');
|
||||
const noInvalidThisRule = new eslint.Linter().getRules().get('no-invalid-this');
|
||||
const ruleComposer = require("eslint-rule-composer");
|
||||
const eslint = require("eslint");
|
||||
const noInvalidThisRule = new eslint.Linter().getRules().get("no-invalid-this");
|
||||
|
||||
module.exports = ruleComposer.filterReports(
|
||||
noInvalidThisRule,
|
||||
(problem, metadata) => {
|
||||
module.exports = ruleComposer.filterReports(noInvalidThisRule, problem => {
|
||||
let inClassProperty = false;
|
||||
let node = problem.node;
|
||||
|
||||
while (node) {
|
||||
if (node.type === "ClassProperty" ||
|
||||
node.type === "ClassPrivateProperty") {
|
||||
if (node.type === "ClassProperty" || node.type === "ClassPrivateProperty") {
|
||||
inClassProperty = true;
|
||||
return;
|
||||
}
|
||||
@ -21,5 +18,4 @@ module.exports = ruleComposer.filterReports(
|
||||
}
|
||||
|
||||
return !inClassProperty;
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
"use strict";
|
||||
|
||||
const ruleComposer = require('eslint-rule-composer');
|
||||
const eslint = require('eslint');
|
||||
const rule = new eslint.Linter().getRules().get('no-unused-expressions');
|
||||
const ruleComposer = require("eslint-rule-composer");
|
||||
const eslint = require("eslint");
|
||||
const rule = new eslint.Linter().getRules().get("no-unused-expressions");
|
||||
|
||||
/**
|
||||
* @param {ASTNode} node - any node
|
||||
@ -11,9 +11,11 @@ const rule = new eslint.Linter().getRules().get('no-unused-expressions');
|
||||
*/
|
||||
function isFinalStatementInBlockStatement(node) {
|
||||
const parent = node.parent;
|
||||
return /^(?:If|Expression)Statement$/.test(node.type) &&
|
||||
parent.type === 'BlockStatement' &&
|
||||
parent.body[parent.body.length - 1] === node;
|
||||
return (
|
||||
/^(?:If|Expression)Statement$/.test(node.type) &&
|
||||
parent.type === "BlockStatement" &&
|
||||
parent.body[parent.body.length - 1] === node
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -24,13 +26,13 @@ function isFinalStatementInBlockStatement(node) {
|
||||
function isInDoStatement(node) {
|
||||
if (!node) return false;
|
||||
|
||||
if (node.type === 'DoExpression') return true;
|
||||
if (node.type === "DoExpression") return true;
|
||||
|
||||
// this is an `else if`
|
||||
if (
|
||||
node.type === 'IfStatement' &&
|
||||
node.type === "IfStatement" &&
|
||||
node.parent &&
|
||||
node.parent.type === 'IfStatement'
|
||||
node.parent.type === "IfStatement"
|
||||
) {
|
||||
return isInDoStatement(node.parent);
|
||||
}
|
||||
@ -50,14 +52,13 @@ function isInDoStatement(node) {
|
||||
function isOptionalCallExpression(node) {
|
||||
return (
|
||||
!!node &&
|
||||
node.type === 'ExpressionStatement' &&
|
||||
node.expression.type === 'OptionalCallExpression'
|
||||
node.type === "ExpressionStatement" &&
|
||||
node.expression.type === "OptionalCallExpression"
|
||||
);
|
||||
}
|
||||
|
||||
module.exports = ruleComposer.filterReports(
|
||||
rule,
|
||||
(problem, metadata) =>
|
||||
problem =>
|
||||
!isInDoStatement(problem.node) && !isOptionalCallExpression(problem.node)
|
||||
);
|
||||
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
"use strict";
|
||||
|
||||
const ruleComposer = require('eslint-rule-composer');
|
||||
const eslint = require('eslint');
|
||||
const objectCurlySpacingRule = new eslint.Linter().getRules().get('object-curly-spacing');
|
||||
const ruleComposer = require("eslint-rule-composer");
|
||||
const eslint = require("eslint");
|
||||
const objectCurlySpacingRule = new eslint.Linter()
|
||||
.getRules()
|
||||
.get("object-curly-spacing");
|
||||
|
||||
module.exports = ruleComposer.filterReports(
|
||||
objectCurlySpacingRule,
|
||||
@ -13,7 +15,7 @@ module.exports = ruleComposer.filterReports(
|
||||
// export * as x from '...';
|
||||
// export x from '...';
|
||||
if (
|
||||
node.type === 'ExportNamedDeclaration' &&
|
||||
node.type === "ExportNamedDeclaration" &&
|
||||
node.specifiers.length > 0 &&
|
||||
metadata.sourceCode.getTokenBefore(node.specifiers[0]).value === "export"
|
||||
) {
|
||||
|
||||
@ -1,28 +1,31 @@
|
||||
"use strict";
|
||||
|
||||
var isWarnedForDeprecation = false;
|
||||
let isWarnedForDeprecation = false;
|
||||
module.exports = {
|
||||
meta: {
|
||||
deprecated: true,
|
||||
schema: [
|
||||
{
|
||||
"enum": ["always", "methods", "properties", "never"]
|
||||
}
|
||||
]
|
||||
enum: ["always", "methods", "properties", "never"],
|
||||
},
|
||||
],
|
||||
},
|
||||
create: function() {
|
||||
return {
|
||||
Program: function() {
|
||||
if (isWarnedForDeprecation || /\=-(f|-format)=/.test(process.argv.join('='))) {
|
||||
if (
|
||||
isWarnedForDeprecation ||
|
||||
/=-(f|-format)=/.test(process.argv.join("="))
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* eslint-disable no-console */
|
||||
console.log('The babel/object-shorthand rule is deprecated. Please ' +
|
||||
'use the built in object-shorthand rule instead.');
|
||||
/* eslint-enable no-console */
|
||||
console.log(
|
||||
"The babel/object-shorthand rule is deprecated. Please " +
|
||||
"use the built in object-shorthand rule instead."
|
||||
);
|
||||
isWarnedForDeprecation = true;
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@ -1,12 +1,10 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
const ruleComposer = require('eslint-rule-composer');
|
||||
const eslint = require('eslint');
|
||||
const quotesRule = new eslint.Linter().getRules().get('quotes');
|
||||
const ruleComposer = require("eslint-rule-composer");
|
||||
const eslint = require("eslint");
|
||||
const quotesRule = new eslint.Linter().getRules().get("quotes");
|
||||
|
||||
module.exports = ruleComposer.filterReports(
|
||||
quotesRule,
|
||||
(problem, metadata) => {
|
||||
module.exports = ruleComposer.filterReports(quotesRule, problem => {
|
||||
// Workaround for JSX fragment syntax until
|
||||
// https://github.com/eslint/eslint/issues/9662
|
||||
if (problem.node.parent.type === "JSXFragment") {
|
||||
@ -14,5 +12,4 @@ module.exports = ruleComposer.filterReports(
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
"use strict";
|
||||
|
||||
const ruleComposer = require('eslint-rule-composer');
|
||||
const eslint = require('eslint');
|
||||
const semiRule = new eslint.Linter().getRules().get('semi');
|
||||
const ruleComposer = require("eslint-rule-composer");
|
||||
const eslint = require("eslint");
|
||||
const semiRule = new eslint.Linter().getRules().get("semi");
|
||||
|
||||
const OPT_OUT_PATTERN = /^[-[(/+`]/; // One of [(/+-`
|
||||
|
||||
@ -21,11 +21,14 @@ const isUnnecessarySemicolon = (context, lastToken) => {
|
||||
|
||||
const lastTokenLine = lastToken.loc.end.line;
|
||||
const nextTokenLine = nextToken.loc.start.line;
|
||||
const isOptOutToken = OPT_OUT_PATTERN.test(nextToken.value) && nextToken.value !== "++" && nextToken.value !== "--";
|
||||
const isDivider = (nextToken.value === "}" || nextToken.value === ";");
|
||||
const isOptOutToken =
|
||||
OPT_OUT_PATTERN.test(nextToken.value) &&
|
||||
nextToken.value !== "++" &&
|
||||
nextToken.value !== "--";
|
||||
const isDivider = nextToken.value === "}" || nextToken.value === ";";
|
||||
|
||||
return (lastTokenLine !== nextTokenLine && !isOptOutToken) || isDivider;
|
||||
}
|
||||
};
|
||||
|
||||
const isOneLinerBlock = (context, node) => {
|
||||
const nextToken = context.getSourceCode().getTokenAfter(node);
|
||||
@ -36,14 +39,19 @@ const isOneLinerBlock = (context, node) => {
|
||||
|
||||
const parent = node.parent;
|
||||
|
||||
return parent && parent.type === "BlockStatement" &&
|
||||
parent.loc.start.line === parent.loc.end.line;
|
||||
return (
|
||||
parent &&
|
||||
parent.type === "BlockStatement" &&
|
||||
parent.loc.start.line === parent.loc.end.line
|
||||
);
|
||||
};
|
||||
|
||||
const report = (context, node, missing) => {
|
||||
const lastToken = context.getSourceCode().getLastToken(node);
|
||||
|
||||
let message, fix, loc = lastToken.loc;
|
||||
let message,
|
||||
fix,
|
||||
loc = lastToken.loc;
|
||||
|
||||
if (!missing) {
|
||||
message = "Missing semicolon.";
|
||||
@ -63,7 +71,7 @@ const report = (context, node, missing) => {
|
||||
node,
|
||||
loc,
|
||||
message,
|
||||
fix
|
||||
fix,
|
||||
});
|
||||
};
|
||||
|
||||
@ -98,7 +106,7 @@ const semiRuleWithClassProperty = ruleComposer.joinReports([
|
||||
|
||||
module.exports = ruleComposer.filterReports(
|
||||
semiRuleWithClassProperty,
|
||||
(problem, metadata) => {
|
||||
problem => {
|
||||
const node = problem.node;
|
||||
|
||||
// Handle async iterator:
|
||||
|
||||
@ -1,12 +1,9 @@
|
||||
"use strict";
|
||||
|
||||
const ruleComposer = require('eslint-rule-composer');
|
||||
const eslint = require('eslint');
|
||||
const validTypeOf = new eslint.Linter().getRules().get('valid-typeof');
|
||||
const ruleComposer = require("eslint-rule-composer");
|
||||
const eslint = require("eslint");
|
||||
const validTypeOf = new eslint.Linter().getRules().get("valid-typeof");
|
||||
|
||||
module.exports = ruleComposer.filterReports(
|
||||
validTypeOf,
|
||||
(problem, metadata) => {
|
||||
return problem.node.value !== 'bigint';
|
||||
}
|
||||
)
|
||||
module.exports = ruleComposer.filterReports(validTypeOf, problem => {
|
||||
return problem.node.value !== "bigint";
|
||||
});
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
/* eslint-disable */
|
||||
|
||||
/**
|
||||
* @fileoverview Tests for new-cap rule.
|
||||
* @author Nicholas C. Zakas
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
/* eslint-disable */
|
||||
|
||||
/**
|
||||
* @fileoverview Disallows or enforces spaces inside of object literals.
|
||||
* @author Jamund Ferguson
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user