Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run new lint rules #5413

Merged
merged 1 commit into from
Mar 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{
"extends": "babel",
"rules": {
"comma-dangle": ["error", "always-multiline"],
"curly": ["error", "multi-line"],
"func-call-spacing": "error",
"key-spacing": "error",
"no-multi-spaces": "error"
},
"env": {
"node": true,
Expand Down
22 changes: 11 additions & 11 deletions packages/babel-cli/src/_babel-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ program.parse(process.argv);

register({
extensions: program.extensions,
ignore: program.ignore,
only: program.only,
plugins: program.plugins,
presets: program.presets,
ignore: program.ignore,
only: program.only,
plugins: program.plugins,
presets: program.presets,
});

//
Expand All @@ -55,8 +55,8 @@ const replPlugin = ({ types: t }) => ({
// If the executed code doesn't evaluate to a value,
// prevent implicit strict mode from printing 'use strict'.
path.pushContainer("body", t.expressionStatement(t.identifier("undefined")));
}
}
},
},
});

//
Expand All @@ -68,11 +68,11 @@ const _eval = function (code, filename) {
code = babel.transform(code, {
filename: filename,
presets: program.presets,
plugins: (program.plugins || []).concat([replPlugin])
plugins: (program.plugins || []).concat([replPlugin]),
}).code;

return vm.runInThisContext(code, {
filename: filename
filename: filename,
});
};

Expand All @@ -85,10 +85,10 @@ if (program.eval || program.print) {

const module = new Module(global.__filename);
module.filename = global.__filename;
module.paths = Module._nodeModulePaths(global.__dirname);
module.paths = Module._nodeModulePaths(global.__dirname);

global.exports = module.exports;
global.module = module;
global.module = module;
global.require = module.require.bind(module);

const result = _eval(code, global.__filename);
Expand Down Expand Up @@ -141,7 +141,7 @@ function replStart() {
input: process.stdin,
output: process.stdout,
eval: replEval,
useGlobal: true
useGlobal: true,
});
}

Expand Down
2 changes: 1 addition & 1 deletion packages/babel-cli/src/babel-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ let userArgs;
// separate node arguments from script arguments
const argSeparator = babelArgs.indexOf("--");
if (argSeparator > -1) {
userArgs = babelArgs.slice(argSeparator); // including the --
userArgs = babelArgs.slice(argSeparator); // including the --
babelArgs = babelArgs.slice(0, argSeparator);
}

Expand Down
4 changes: 2 additions & 2 deletions packages/babel-cli/src/babel/dir.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default function (commander, filenames) {

const data = util.compile(src, {
sourceFileName: slash(path.relative(dest + "/..", src)),
sourceMapTarget: path.basename(relative)
sourceMapTarget: path.basename(relative),
});
if (!commander.copyFiles && data.ignored) return;

Expand Down Expand Up @@ -74,7 +74,7 @@ export default function (commander, filenames) {
awaitWriteFinish: {
stabilityThreshold: 50,
pollInterval: 10,
}
},
});

["add", "change"].forEach(function (type) {
Expand Down
8 changes: 4 additions & 4 deletions packages/babel-cli/src/babel/file.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import convertSourceMap from "convert-source-map";
import sourceMap from "source-map";
import sourceMap from "source-map";
import slash from "slash";
import path from "path";
import fs from "fs";
Expand All @@ -16,7 +16,7 @@ export default function (commander, filenames, opts) {
const buildResult = function () {
const map = new sourceMap.SourceMapGenerator({
file: path.basename(commander.outFile || "") || "stdout",
sourceRoot: opts.sourceRoot
sourceRoot: opts.sourceRoot,
});

let code = "";
Expand Down Expand Up @@ -64,7 +64,7 @@ export default function (commander, filenames, opts) {

return {
map: map,
code: code
code: code,
};
};

Expand Down Expand Up @@ -156,7 +156,7 @@ export default function (commander, filenames, opts) {
awaitWriteFinish: {
stabilityThreshold: 50,
pollInterval: 10,
}
},
}).on("all", function (type, filename) {
if (util.shouldIgnore(filename) || !util.canCompile(filename, commander.extensions)) return;

Expand Down
6 changes: 3 additions & 3 deletions packages/babel-cli/src/babel/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/usr/bin/env node

import fs from "fs";
import fs from "fs";
import commander from "commander";
import kebabCase from "lodash/kebabCase";
import { options, util, version } from "babel-core";
import uniq from "lodash/uniq";
import glob from "glob";
import uniq from "lodash/uniq";
import glob from "glob";

import dirCommand from "./dir";
import fileCommand from "./file";
Expand Down
26 changes: 13 additions & 13 deletions packages/babel-cli/test/index.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
const includes = require("lodash/includes");
const readdir = require("fs-readdir-recursive");
const helper = require("babel-helper-fixtures");
const assert = require("assert");
const rimraf = require("rimraf");
const includes = require("lodash/includes");
const readdir = require("fs-readdir-recursive");
const helper = require("babel-helper-fixtures");
const assert = require("assert");
const rimraf = require("rimraf");
const outputFileSync = require("output-file-sync");
const child = require("child_process");
const merge = require("lodash/merge");
const path = require("path");
const chai = require("chai");
const fs = require("fs");
const child = require("child_process");
const merge = require("lodash/merge");
const path = require("path");
const chai = require("chai");
const fs = require("fs");

const fixtureLoc = path.join(__dirname, "fixtures");
const tmpLoc = path.join(__dirname, "tmp");

const presetLocs = [
path.join(__dirname, "../../babel-preset-es2015"),
path.join(__dirname, "../../babel-preset-react")
path.join(__dirname, "../../babel-preset-react"),
].join(",");

const pluginLocs = [
Expand Down Expand Up @@ -150,7 +150,7 @@ fs.readdirSync(fixtureLoc).forEach(function (binName) {
const testLoc = path.join(suiteLoc, testName);

const opts = {
args: []
args: [],
};

const optionsLoc = path.join(testLoc, "options.json");
Expand All @@ -166,7 +166,7 @@ fs.readdirSync(fixtureLoc).forEach(function (binName) {
});

opts.outFiles = readDir(path.join(testLoc, "out-files"));
opts.inFiles = readDir(path.join(testLoc, "in-files"));
opts.inFiles = readDir(path.join(testLoc, "in-files"));

const babelrcLoc = path.join(testLoc, ".babelrc");
if (fs.existsSync(babelrcLoc)) {
Expand Down
26 changes: 13 additions & 13 deletions packages/babel-code-frame/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ import Chalk from "chalk";

function getDefs(chalk) {
return {
keyword: chalk.cyan,
keyword: chalk.cyan,
capitalized: chalk.yellow,
jsx_tag: chalk.yellow,
punctuator: chalk.yellow,
jsx_tag: chalk.yellow,
punctuator: chalk.yellow,
// bracket: intentionally omitted.
number: chalk.magenta,
string: chalk.green,
regex: chalk.magenta,
comment: chalk.grey,
invalid: chalk.white.bgRed.bold,
gutter: chalk.grey,
marker: chalk.red.bold,
number: chalk.magenta,
string: chalk.green,
regex: chalk.magenta,
comment: chalk.grey,
invalid: chalk.white.bgRed.bold,
gutter: chalk.grey,
marker: chalk.red.bold,
};
}

Expand Down Expand Up @@ -117,7 +117,7 @@ export default function (

const lines = rawLines.split(NEWLINE);
let start = Math.max(lineNumber - (linesAbove + 1), 0);
let end = Math.min(lines.length, lineNumber + linesBelow);
let end = Math.min(lines.length, lineNumber + linesBelow);

if (!lineNumber && !colNumber) {
start = 0;
Expand All @@ -138,14 +138,14 @@ export default function (
"\n ",
maybeHighlight(defs.gutter, gutter.replace(/\d/g, " ")),
markerSpacing,
maybeHighlight(defs.marker, "^")
maybeHighlight(defs.marker, "^"),
].join("");
}
return [
maybeHighlight(defs.marker, ">"),
maybeHighlight(defs.gutter, gutter),
line,
markerLine
markerLine,
].join("");
} else {
return ` ${maybeHighlight(defs.gutter, gutter)}${line}`;
Expand Down
18 changes: 9 additions & 9 deletions packages/babel-code-frame/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe("babel-code-frame", function () {
"",
"function sum(a, b) {",
" return a + b",
"}"
"}",
].join("\n");
assert.equal(codeFrame(rawLines, 7, 2), [
" 5 | * @param b Number",
Expand All @@ -80,7 +80,7 @@ describe("babel-code-frame", function () {
"",
"function sum(a, b) {",
" return a + b",
"}"
"}",
].join("\n");
assert.equal(codeFrame(rawLines, 6, 2), [
" 4 | * @param a Number",
Expand Down Expand Up @@ -130,7 +130,7 @@ describe("babel-code-frame", function () {
"",
"function sum(a, b) {",
" return a + b",
"}"
"}",
].join("\n");
assert.equal(codeFrame(rawLines, 7, 2, { linesAbove: 1 }), [
" 6 | * @returns Number",
Expand All @@ -154,14 +154,14 @@ describe("babel-code-frame", function () {
"",
"function sum(a, b) {",
" return a + b",
"}"
"}",
].join("\n");
assert.equal(codeFrame(rawLines, 7, 2, { linesBelow: 1 }), [
" 5 | * @param b Number",
" 6 | * @returns Number",
"> 7 | */",
" | ^",
" 8 | "
" 8 | ",
].join("\n"));
});

Expand All @@ -177,13 +177,13 @@ describe("babel-code-frame", function () {
"",
"function sum(a, b) {",
" return a + b",
"}"
"}",
].join("\n");
assert.equal(codeFrame(rawLines, 7, 2, { linesAbove: 1, linesBelow: 1 }), [
" 6 | * @returns Number",
"> 7 | */",
" | ^",
" 8 | "
" 8 | ",
].join("\n"));
});

Expand All @@ -195,13 +195,13 @@ describe("babel-code-frame", function () {
"",
"",
"",
""
"",
].join("\n");
assert.equal(codeFrame(rawLines, 3, null, { linesAbove: 1, linesBelow: 1, forceColor: true }),
chalk.reset([
" " + gutter(" 2 | "),
marker(">") + gutter(" 3 | "),
" " + gutter(" 4 | ")
" " + gutter(" 4 | "),
].join("\n"))
);
});
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-core/src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default class Store {
return this._map.get(key);
} else {
if (Object.prototype.hasOwnProperty.call(this._map.dynamicData, key)) {
const val = this._map.dynamicData[key]();
const val = this._map.dynamicData[key]();
this._map.set(key, val);
return val;
}
Expand Down
Loading