Skip to content

Commit

Permalink
Update rules/tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kaicataldo committed Jan 10, 2020
1 parent 374efac commit 2258e2b
Show file tree
Hide file tree
Showing 18 changed files with 85 additions and 3,854 deletions.
15 changes: 0 additions & 15 deletions eslint/babel-eslint-parser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,6 @@
},
"devDependencies": {
"@babel/core": "^7.2.0",
"@babel/plugin-proposal-class-properties": "^7.1.0",
"@babel/plugin-proposal-decorators": "^7.1.2",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.0.0",
"@babel/plugin-proposal-optional-chaining": "^7.0.0",
"@babel/plugin-proposal-pipeline-operator": "^7.0.0",
"@babel/plugin-proposal-private-methods": "^7.7.4",
"@babel/plugin-syntax-bigint": "^7.7.4",
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
"@babel/plugin-syntax-export-default-from": "^7.0.0",
"@babel/plugin-syntax-export-namespace-from": "^7.0.0",
"@babel/plugin-syntax-import-meta": "^7.0.0",
"@babel/plugin-syntax-numeric-separator": "^7.0.0",
"@babel/preset-env": "^7.1.5",
"@babel/preset-flow": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"dedent": "^0.7.0",
"eslint": "^6.0.1",
"espree": "^6.0.0"
Expand Down
5 changes: 4 additions & 1 deletion eslint/babel-eslint-parser/test/babel-eslint-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import { parseForESLint } from "../src";
import assertImplementsAST from "./helpers/assert-implements-ast";

const babelOptions = {
configFile: path.resolve(__dirname, "./fixtures/config/babel.config.js"),
configFile: path.resolve(
__dirname,
"../../babel-eslint-shared-fixtures/config/babel.config.js",
),
};

function parseAndAssertSame(code) {
Expand Down
4 changes: 2 additions & 2 deletions eslint/babel-eslint-parser/test/non-regression.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function verifyAndAssertMessagesWithSpecificESLint(
babelOptions: {
configFile: path.resolve(
__dirname,
"./fixtures/config/babel.config.js",
"../../babel-eslint-shared-fixtures/config/babel.config.js",
),
},
...overrideConfig?.parserOptions,
Expand Down Expand Up @@ -1159,7 +1159,7 @@ describe("verify", () => {
babelOptions: {
configFile: path.resolve(
__dirname,
"./fixtures/config/babel.config.decorators-legacy.js",
"../../babel-eslint-shared-fixtures/config/babel.config.decorators-legacy.js",
),
},
},
Expand Down
231 changes: 0 additions & 231 deletions eslint/babel-eslint-plugin/src/rules/camelcase.js

This file was deleted.

4 changes: 2 additions & 2 deletions eslint/babel-eslint-plugin/src/rules/new-cap.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ruleComposer from "eslint-rule-composer";
import eslint from "eslint";

const newCapRule = new eslint.Linter().getRules().get("new-cap");
const rule = new eslint.Linter().getRules().get("new-cap");

/**
* Returns whether a node is under a decorator or not.
Expand All @@ -13,6 +13,6 @@ function isDecorator(node) {
}

export default ruleComposer.filterReports(
newCapRule,
rule,
problem => !isDecorator(problem.node),
);
6 changes: 4 additions & 2 deletions eslint/babel-eslint-plugin/src/rules/no-unused-expressions.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ function isFinalStatementInBlockStatement(node) {
* @param {ASTNode} node - any node
* @returns {boolean} whether the given node represents an unbroken chain of
* tail ExpressionStatements and IfStatements within a DoExpression
* https://github.com/tc39/proposal-do-expressions
*/
function isInDoStatement(node) {
if (!node) return false;
Expand All @@ -31,7 +32,8 @@ function isInDoStatement(node) {
if (
node.type === "IfStatement" &&
node.parent &&
node.parent.type === "IfStatement"
node.parent.type === "IfStatement" &&
node.parent.alternate === node
) {
return isInDoStatement(node.parent);
}
Expand All @@ -46,7 +48,7 @@ function isInDoStatement(node) {
/**
* @param {ASTNode} node - any node
* @returns {boolean} whether the given node is an optional call expression,
* see https://github.com/tc39/proposal-optional-chaining
* https://github.com/tc39/proposal-optional-chaining
*/
function isOptionalCallExpression(node) {
return (
Expand Down
34 changes: 14 additions & 20 deletions eslint/babel-eslint-plugin/src/rules/object-curly-spacing.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,20 @@
import ruleComposer from "eslint-rule-composer";
import eslint from "eslint";

const objectCurlySpacingRule = new eslint.Linter()
.getRules()
.get("object-curly-spacing");
const rule = new eslint.Linter().getRules().get("object-curly-spacing");

export default ruleComposer.filterReports(
objectCurlySpacingRule,
(problem, metadata) => {
const node = problem.node;
export default ruleComposer.filterReports(rule, problem => {
const node = problem.node;

// Allow `exportNamespaceFrom` and `exportDefaultFrom` syntax:
// export * as x from '...';
// export x from '...';
if (
node.type === "ExportNamedDeclaration" &&
node.specifiers.length > 0 &&
metadata.sourceCode.getTokenBefore(node.specifiers[0]).value === "export"
) {
return false;
}
// Allow exportDefaultFrom syntax:
// export x from '...';
if (
node.type === "ExportNamedDeclaration" &&
node.specifiers.length === 1 &&
node.specifiers[0].type === "ExportDefaultSpecifier"
) {
return false;
}

return true;
},
);
return true;
});

0 comments on commit 2258e2b

Please sign in to comment.