Skip to content

Commit

Permalink
Fix linting in ESLint packages (#10712)
Browse files Browse the repository at this point in the history
* Lint eslint/*

* Run "make fix-js"

* Fix remaining problems

* Remove linting from subpackages

* Remove husky

* Add back eslint dep
  • Loading branch information
nicolo-ribaudo committed Nov 14, 2019
1 parent 17dfdab commit b4c4260
Show file tree
Hide file tree
Showing 31 changed files with 498 additions and 495 deletions.
4 changes: 4 additions & 0 deletions .eslintignore
Expand Up @@ -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 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -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

Expand Down
14 changes: 7 additions & 7 deletions eslint/babel-eslint-config-internal/index.js
Expand Up @@ -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",
Expand All @@ -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 change: 0 additions & 1 deletion eslint/babel-eslint-parser/.prettierignore

This file was deleted.

3 changes: 0 additions & 3 deletions eslint/babel-eslint-parser/.prettierrc

This file was deleted.

22 changes: 2 additions & 20 deletions eslint/babel-eslint-parser/package.json
Expand Up @@ -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'"
},
Expand Down Expand Up @@ -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"
}
}
20 changes: 0 additions & 20 deletions eslint/babel-eslint-plugin-development/.eslintrc.json

This file was deleted.

11 changes: 0 additions & 11 deletions eslint/babel-eslint-plugin-development/.prettierrc

This file was deleted.

7 changes: 2 additions & 5 deletions eslint/babel-eslint-plugin-development/package.json
Expand Up @@ -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"
Expand Down
@@ -1,5 +1,3 @@
// @flow

"use strict";

const getReferenceOrigin = require("../utils/get-reference-origin");
Expand Down
Expand Up @@ -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."
);
}
},
Expand Down
Expand Up @@ -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."
);
}
}
Expand Down
Expand Up @@ -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
Expand Down
62 changes: 31 additions & 31 deletions eslint/babel-eslint-plugin/index.js
@@ -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,
},
};
79 changes: 41 additions & 38 deletions eslint/babel-eslint-plugin/rules/array-bracket-spacing.js
@@ -1,43 +1,46 @@
"use strict";

var isWarnedForDeprecation = false;
let isWarnedForDeprecation = false;
module.exports = {
meta: {
deprecated: true,
schema: [
{
"enum": ["always", "never"]
},
{
"type": "object",
"properties": {
"singleValue": {
"type": "boolean"
},
"objectsInArrays": {
"type": "boolean"
},
"arraysInArrays": {
"type": "boolean"
}
},
"additionalProperties": false
}
]
},
create: function() {
return {
Program: function() {
if (isWarnedForDeprecation || /\=-(f|-format)=/.test(process.argv.join('='))) {
return;
}
meta: {
deprecated: true,
schema: [
{
enum: ["always", "never"],
},
{
type: "object",
properties: {
singleValue: {
type: "boolean",
},
objectsInArrays: {
type: "boolean",
},
arraysInArrays: {
type: "boolean",
},
},
additionalProperties: false,
},
],
},
create: function() {
return {
Program: function() {
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 */
isWarnedForDeprecation = true;
}
};
}
console.log(
"The babel/array-bracket-spacing rule is deprecated. Please " +
"use the built in array-bracket-spacing rule instead."
);
isWarnedForDeprecation = true;
},
};
},
};
49 changes: 26 additions & 23 deletions eslint/babel-eslint-plugin/rules/arrow-parens.js
@@ -1,28 +1,31 @@
"use strict";

var isWarnedForDeprecation = false;
let isWarnedForDeprecation = false;
module.exports = {
meta: {
deprecated: true,
schema: [
{
"enum": ["always", "as-needed"]
}
]
},
create: function() {
return {
Program: function() {
if (isWarnedForDeprecation || /\=-(f|-format)=/.test(process.argv.join('='))) {
return;
}
meta: {
deprecated: true,
schema: [
{
enum: ["always", "as-needed"],
},
],
},
create: function() {
return {
Program: function() {
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 */
isWarnedForDeprecation = true;
}
};
}
console.log(
"The babel/arrow-parens rule is deprecated. Please " +
"use the built in arrow-parens rule instead."
);
isWarnedForDeprecation = true;
},
};
},
};

0 comments on commit b4c4260

Please sign in to comment.