Skip to content

Commit

Permalink
Update prettier to v2 (#11579)
Browse files Browse the repository at this point in the history
Co-authored-by: Nicol貌 Ribaudo <nicolo.ribaudo@gmail.com>
  • Loading branch information
zxbodya and nicolo-ribaudo committed Jun 7, 2020
1 parent 426acf3 commit 4108524
Show file tree
Hide file tree
Showing 147 changed files with 1,021 additions and 1,109 deletions.
4 changes: 2 additions & 2 deletions Gulpfile.js
Expand Up @@ -33,7 +33,7 @@ function getIndexFromPackage(name) {
}

function compilationLogger() {
return through.obj(function(file, enc, callback) {
return through.obj(function (file, enc, callback) {
fancyLog(`Compiling '${chalk.cyan(file.relative)}'...`);
callback(null, file);
});
Expand All @@ -48,7 +48,7 @@ function errorsLogger() {
}

function rename(fn) {
return through.obj(function(file, enc, callback) {
return through.obj(function (file, enc, callback) {
file.path = fn(file);
callback(null, file);
});
Expand Down
2 changes: 1 addition & 1 deletion babel.config.js
@@ -1,6 +1,6 @@
"use strict";

module.exports = function(api) {
module.exports = function (api) {
const env = api.env();

const includeCoverage = process.env.BABEL_COVERAGE === "true";
Expand Down
@@ -1,6 +1,6 @@
import syntaxObjectRestSpread from "@babel/plugin-syntax-object-rest-spread";

export default function({ types: t }) {
export default function ({ types: t }) {
return {
inherits: syntaxObjectRestSpread,

Expand Down
@@ -1,6 +1,6 @@
import syntaxOptionalCatchBinding from "@babel/plugin-syntax-optional-catch-binding";

export default function({ types: t }) {
export default function ({ types: t }) {
return {
inherits: syntaxOptionalCatchBinding,

Expand Down
2 changes: 1 addition & 1 deletion eslint/babel-eslint-parser/src/analyze-scope.js
Expand Up @@ -237,7 +237,7 @@ class Referencer extends OriginalReferencer {
this._checkIdentifierOrVisit(name);
}
}
scope.__define = function() {
scope.__define = function () {
return parentScope.__define.apply(parentScope, arguments);
};

Expand Down
2 changes: 1 addition & 1 deletion eslint/babel-eslint-parser/src/convert/index.js
Expand Up @@ -2,7 +2,7 @@ import convertTokens from "./convertTokens";
import convertComments from "./convertComments";
import convertAST from "./convertAST";

export default function(ast, code) {
export default function (ast, code) {
ast.tokens = convertTokens(ast.tokens, code);
convertComments(ast.comments);
convertAST(ast, code);
Expand Down
2 changes: 1 addition & 1 deletion eslint/babel-eslint-parser/test/index.js
Expand Up @@ -84,7 +84,7 @@ describe("Babel and Espree", () => {
});

describe("compatibility", () => {
it("should allow ast.analyze to be called without options", function() {
it("should allow ast.analyze to be called without options", function () {
const ast = parseForESLint("`test`", {
eslintScopeManager: true,
eslintVisitorKeys: true,
Expand Down
4 changes: 2 additions & 2 deletions eslint/babel-eslint-plugin/src/rules/semi.js
Expand Up @@ -57,13 +57,13 @@ function report(context, node, missing) {
if (!missing) {
message = "Missing semicolon.";
loc = loc.end;
fix = function(fixer) {
fix = function (fixer) {
return fixer.insertTextAfter(lastToken, ";");
};
} else {
message = "Extra semicolon.";
loc = loc.start;
fix = function(fixer) {
fix = function (fixer) {
return fixer.remove(lastToken);
};
}
Expand Down
4 changes: 2 additions & 2 deletions eslint/babel-eslint-plugin/test/rules/no-invalid-this.js
Expand Up @@ -50,8 +50,8 @@ function MODULES(pattern) {
*/
function extractPatterns(patterns, type) {
// Clone and apply the pattern environment.
const patternsList = patterns.map(function(pattern) {
return pattern[type].map(function(applyCondition) {
const patternsList = patterns.map(function (pattern) {
return pattern[type].map(function (applyCondition) {
const thisPattern = cloneDeep(pattern);

applyCondition(thisPattern);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -57,7 +57,7 @@
"lodash": "^4.17.13",
"mergeiterator": "^1.2.5",
"output-file-sync": "^2.0.0",
"prettier": "^1.19.1",
"prettier": "^2.0.5",
"pump": "^3.0.0",
"rimraf": "^2.6.3",
"rollup": "1.27.9",
Expand Down
10 changes: 5 additions & 5 deletions packages/babel-cli/src/babel/dir.js
Expand Up @@ -22,7 +22,7 @@ function outputFileSync(filePath: string, data: string | Buffer): void {
fs.writeFileSync(filePath, data);
}

export default async function({
export default async function ({
cliOptions,
babelOptions,
}: CmdOptions): Promise<void> {
Expand Down Expand Up @@ -143,7 +143,7 @@ export default async function({
let startTime = null;

const logSuccess = debounce(
function() {
function () {
if (startTime === null) {
// This should never happen, but just in case it's better
// to ignore the log message rather than making @babel/cli crash.
Expand Down Expand Up @@ -189,7 +189,7 @@ export default async function({
if (cliOptions.watch) {
const chokidar = util.requireChokidar();

filenames.forEach(function(filenameOrDir: string): void {
filenames.forEach(function (filenameOrDir: string): void {
const watcher = chokidar.watch(filenameOrDir, {
persistent: true,
ignoreInitial: true,
Expand All @@ -203,8 +203,8 @@ export default async function({
// when we are sure that all the files have been compiled.
let processing = 0;

["add", "change"].forEach(function(type: string): void {
watcher.on(type, async function(filename: string) {
["add", "change"].forEach(function (type: string): void {
watcher.on(type, async function (filename: string) {
processing++;
if (startTime === null) startTime = process.hrtime();

Expand Down
16 changes: 8 additions & 8 deletions packages/babel-cli/src/babel/file.js
Expand Up @@ -16,7 +16,7 @@ type CompilationOutput = {
map: Object,
};

export default async function({
export default async function ({
cliOptions,
babelOptions,
}: CmdOptions): Promise<void> {
Expand All @@ -41,7 +41,7 @@ export default async function({
const consumer = new sourceMap.SourceMapConsumer(result.map);
const sources = new Set();

consumer.eachMapping(function(mapping) {
consumer.eachMapping(function (mapping) {
if (mapping.source != null) sources.add(mapping.source);

map.addMapping({
Expand Down Expand Up @@ -111,13 +111,13 @@ export default async function({

process.stdin.setEncoding("utf8");

process.stdin.on("readable", function() {
process.stdin.on("readable", function () {
const chunk = process.stdin.read();
// $FlowIgnore
if (chunk !== null) code += chunk;
});

process.stdin.on("end", function() {
process.stdin.on("end", function () {
resolve(code);
});
process.stdin.on("error", reject);
Expand All @@ -144,7 +144,7 @@ export default async function({
async function walk(filenames: Array<string>): Promise<void> {
const _filenames = [];

filenames.forEach(function(filename) {
filenames.forEach(function (filename) {
if (!fs.existsSync(filename)) return;

const stat = fs.statSync(filename);
Expand All @@ -157,7 +157,7 @@ export default async function({
cliOptions.includeDotfiles,
cliOptions.extensions,
)
.forEach(function(filename) {
.forEach(function (filename) {
_filenames.push(path.join(dirname, filename));
});
} else {
Expand All @@ -166,7 +166,7 @@ export default async function({
});

const results = await Promise.all(
_filenames.map(async function(filename: string): Promise<Object> {
_filenames.map(async function (filename: string): Promise<Object> {
let sourceFilename = filename;
if (cliOptions.outFile) {
sourceFilename = path.relative(
Expand Down Expand Up @@ -224,7 +224,7 @@ export default async function({
pollInterval: 10,
},
})
.on("all", function(type: string, filename: string): void {
.on("all", function (type: string, filename: string): void {
if (
!util.isCompilableExtension(filename, cliOptions.extensions) &&
!filenames.includes(filename)
Expand Down
6 changes: 3 additions & 3 deletions packages/babel-cli/src/babel/options.js
Expand Up @@ -189,15 +189,15 @@ export default function parseArgv(args: Array<string>): CmdOptions | null {

const errors = [];

let filenames = commander.args.reduce(function(globbed, input) {
let filenames = commander.args.reduce(function (globbed, input) {
let files = glob.sync(input);
if (!files.length) files = [input];
return globbed.concat(files);
}, []);

filenames = uniq(filenames);

filenames.forEach(function(filename) {
filenames.forEach(function (filename) {
if (!fs.existsSync(filename)) {
errors.push(filename + " does not exist");
}
Expand Down Expand Up @@ -255,7 +255,7 @@ export default function parseArgv(args: Array<string>): CmdOptions | null {

if (errors.length) {
console.error("babel:");
errors.forEach(function(e) {
errors.forEach(function (e) {
console.error(" " + e);
});
return null;
Expand Down
6 changes: 3 additions & 3 deletions packages/babel-cli/src/babel/util.js
Expand Up @@ -33,7 +33,7 @@ export function readdirForCompilable(
includeDotfiles: boolean,
altExts?: Array<string>,
): Array<string> {
return readdir(dirname, includeDotfiles, function(filename) {
return readdir(dirname, includeDotfiles, function (filename) {
return isCompilableExtension(filename, altExts);
});
}
Expand Down Expand Up @@ -96,7 +96,7 @@ export function compile(

export function deleteDir(path: string): void {
if (fs.existsSync(path)) {
fs.readdirSync(path).forEach(function(file) {
fs.readdirSync(path).forEach(function (file) {
const curPath = path + "/" + file;
if (fs.lstatSync(curPath).isDirectory()) {
// recurse
Expand All @@ -110,7 +110,7 @@ export function deleteDir(path: string): void {
}
}

process.on("uncaughtException", function(err) {
process.on("uncaughtException", function (err) {
console.error(err);
process.exitCode = 1;
});
Expand Down

0 comments on commit 4108524

Please sign in to comment.