Skip to content

Commit

Permalink
Update ESLint config and remove trailing comma from debuggerWorker (#253
Browse files Browse the repository at this point in the history
)

* update eslint config and remove trailing comma

* format files
  • Loading branch information
zamotany authored and satya164 committed Oct 16, 2017
1 parent 09f767a commit 4fe8102
Show file tree
Hide file tree
Showing 44 changed files with 120 additions and 119 deletions.
4 changes: 2 additions & 2 deletions integration_tests/__tests__/bundle/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ const fs = require('fs');

export const TEST_PROJECT_DIR = path.resolve(
__dirname,
'../../fixtures/react-native-with-haul',
'../../fixtures/react-native-with-haul'
);

export function bundleForPlatform(platform: string) {
const bundlePath = path.resolve(
TEST_PROJECT_DIR,
'dist',
`index.${platform}.bundle`,
`index.${platform}.bundle`
);
const { stdout } = runHaulSync(TEST_PROJECT_DIR, [
'bundle',
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/__tests__/init.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const { runHaul } = require('../runHaul');

const TEST_PROJECT_DIR = path.resolve(
__dirname,
'../fixtures/react-native-clean',
'../fixtures/react-native-clean'
);
const CONFIG_FILE_PATH = path.resolve(TEST_PROJECT_DIR, 'webpack.haul.js');
const ENTER_KEY = '\x0d';
Expand Down
4 changes: 2 additions & 2 deletions integration_tests/__tests__/start.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const stripAnsi = require('strip-ansi');
const TEMP_DIR = path.resolve(os.tmpdir(), 'start_test');
const TEST_PROJECT_DIR = path.resolve(
__dirname,
'../fixtures/react-native-with-haul',
'../fixtures/react-native-with-haul'
);

beforeAll(() => run('yarn --mutex network', TEST_PROJECT_DIR));
Expand Down Expand Up @@ -65,7 +65,7 @@ function testPlatform(platform, done) {
expect(stdout).toMatch('Haul is now bundling your React Native app');
expect(stdout).toMatch('A fresh build may take longer than usual');
expect(stdout).toMatch(
`You can now run the app on your ${platform} device`,
`You can now run the app on your ${platform} device`
);
done();
haul.kill();
Expand Down
4 changes: 2 additions & 2 deletions integration_tests/runHaul.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type RunHaulOptions = {
function runHaulSync(
dir: string,
args?: Array<string>,
options: RunHaulOptions = {},
options: RunHaulOptions = {}
) {
let cwd = dir;
const isRelative = cwd[0] !== '/';
Expand All @@ -43,7 +43,7 @@ function runHaulSync(
function runHaul(
dir: string,
args?: Array<string>,
options: RunHaulOptions = {},
options: RunHaulOptions = {}
) {
let cwd = dir;
const isRelative = cwd[0] !== '/';
Expand Down
8 changes: 4 additions & 4 deletions integration_tests/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const cleanup = (directory: string) => rimraf.sync(directory);
*/
const writeFiles = (
directory: string,
files: { [filename: string]: string },
files: { [filename: string]: string }
) => {
mkdirp.sync(directory);
Object.keys(files).forEach(fileOrPath => {
Expand All @@ -70,7 +70,7 @@ const writeFiles = (
}
fs.writeFileSync(
path.resolve(...[directory, filename, ...filePath]),
files[fileOrPath],
files[fileOrPath]
);
});
};
Expand All @@ -95,13 +95,13 @@ const DEFAULT_PACKAGE_JSON = {

const createEmptyPackage = (
directory: string,
packageJson: Object = DEFAULT_PACKAGE_JSON,
packageJson: Object = DEFAULT_PACKAGE_JSON
) => {
mkdirp.sync(directory);

fs.writeFileSync(
path.resolve(directory, 'package.json'),
JSON.stringify(packageJson, null, 2),
JSON.stringify(packageJson, null, 2)
);
};

Expand Down
4 changes: 2 additions & 2 deletions jest/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

'use strict';

const traverse = require('traverse'); // eslint-disable-line import/no-extraneous-dependencies
const traverse = require('traverse'); // eslint-disable-line

const flushPromises = (): Promise<any> =>
new Promise(resolve => setTimeout(resolve));
Expand All @@ -19,7 +19,7 @@ const replacePathsInObject = (object: mixed) => {
? entry
.replace(/\/.*\/src/, '<<REPLACED>>')
.replace(/\/.*\/node_modules/, '<<NODE_MODULE>>')
: entry,
: entry
);
};

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"babel-jest": "test",
"babel-preset-react-native": "^2.0.0",
"eslint": "^4.3.0",
"eslint-config-callstack-io": "^0.3.1",
"eslint-config-callstack-io": "^0.5.0",
"flow-bin": "^0.57.2",
"husky": "^0.13.3",
"jest": "test",
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/cliEntry.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import stripAnsi from 'strip-ansi';
import inquirer from 'inquirer';
import { flushPromises } from 'jest/helpers';
import { flushPromises } from 'jest/helpers'; // eslint-disable-line import/no-unresolved
import run from '../cliEntry';
import init from '../commands/init';
import bundle from '../commands/bundle';
Expand Down Expand Up @@ -90,6 +90,6 @@ test('run a command with options (bundle)', async () => {
},
]);
expect(bundle.action).toBeCalledWith(
expect.objectContaining({ platform: 'ios' }),
expect.objectContaining({ platform: 'ios' })
);
});
4 changes: 2 additions & 2 deletions src/cliEntry.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ async function run(args: Array<string>) {
const { _, ...flags } = camelcaseKeys(
minimist(args, {
string: opts.map(opt => opt.name),
}),
})
);

const { options, promptedOptions } = await validateOptions(opts, flags);
Expand All @@ -186,7 +186,7 @@ async function run(args: Array<string>) {
command: displayName,
error,
stack: error && error.stack,
}),
})
);
}
process.exit(1);
Expand Down
10 changes: 5 additions & 5 deletions src/commands/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ async function bundle(opts: *) {
dev: opts.dev,
minify: opts.minify,
bundle: true,
},
}
);

const config = configs[availablePlatforms.indexOf(opts.platform)];
Expand All @@ -50,7 +50,7 @@ async function bundle(opts: *) {
? path.relative(config.output.path, opts.bundleOutput)
: path.relative(
config.output.path,
path.join(directory, opts.bundleOutput),
path.join(directory, opts.bundleOutput)
);
}

Expand All @@ -60,7 +60,7 @@ async function bundle(opts: *) {
messages.initialBundleInformation({
entry: config.entry,
dev: opts.dev,
}),
})
);

const stats = await new Promise((resolve, reject) =>
Expand All @@ -70,7 +70,7 @@ async function bundle(opts: *) {
} else {
resolve(info);
}
}),
})
);

clear();
Expand All @@ -81,7 +81,7 @@ async function bundle(opts: *) {
platform: opts.platform,
assetsPath: config.output.path,
bundlePath: config.output.filename,
}),
})
);
}

Expand Down
22 changes: 11 additions & 11 deletions src/commands/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,20 +145,20 @@ const getRunScript = (scriptName: string) => {
*/
const addToPackageScripts = async (cwd: string) => {
const pjson = JSON.parse(
fs.readFileSync(path.join(cwd, 'package.json')).toString(),
fs.readFileSync(path.join(cwd, 'package.json')).toString()
);

const scripts = pjson.scripts || {};

const haulScript = Object.keys(scripts).find(
name => scripts[name] === 'haul start',
name => scripts[name] === 'haul start'
);

if (haulScript) {
ora().info(
`Haul already exists in your package.json. Start Haul by running ${getRunScript(
haulScript,
)}'`,
haulScript
)}'`
);
return;
}
Expand Down Expand Up @@ -187,18 +187,18 @@ const addToPackageScripts = async (cwd: string) => {
});

const progress = ora(
`Adding \`${scriptName}\` script to your package.json`,
`Adding \`${scriptName}\` script to your package.json`
).start();

await sleep();

fs.writeFileSync(
path.join(cwd, 'package.json'),
JSON.stringify(pjson, null, 2),
JSON.stringify(pjson, null, 2)
);

progress.succeed(
`You can now start Haul by running '${getRunScript(scriptName)}'`,
`You can now start Haul by running '${getRunScript(scriptName)}'`
);
};

Expand Down Expand Up @@ -275,7 +275,7 @@ const addToXcodeBuild = async (cwd: string) => {
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "bash ../node_modules/haul/src/utils/haul-integrate.sh";
};`,
};`
);

/**
Expand Down Expand Up @@ -303,7 +303,7 @@ const addToXcodeBuild = async (cwd: string) => {
dedent`
buildPhases = (
${haulScriptKey} /* Integrate Haul with React Native */,
`,
`
);
});

Expand All @@ -313,8 +313,8 @@ const addToXcodeBuild = async (cwd: string) => {
} else {
progress.fail(
`Failed to add Haul to your Xcode build scripts. See: ${chalk.grey(
'https://github.com/callstack-io/haul/blob/master/docs/Configuring%20Your%20Project.md#integrating-with-xcode',
)} for manual instructions`,
'https://github.com/callstack-io/haul/blob/master/docs/Configuring%20Your%20Project.md#integrating-with-xcode'
)} for manual instructions`
);
}
};
Expand Down
12 changes: 6 additions & 6 deletions src/commands/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ async function start(opts: *) {
dev: opts.dev,
minify: opts.minify,
port: opts.port,
},
}
);

if (opts.platform !== 'all' && platforms.includes(opts.platform)) {
Expand All @@ -75,14 +75,14 @@ async function start(opts: *) {
logger.info(
messages.commandSuccess({
command: `${path.basename(adb)} ${args}`,
}),
})
);
} catch (error) {
logger.warn(
messages.commandFailed({
command: `${path.basename(adb)} ${args}`,
error,
}),
})
);
}
}
Expand All @@ -93,7 +93,7 @@ async function start(opts: *) {
? config.map(c => c.entry)
: [config.entry],
port: opts.port,
}),
})
);

const compiler = webpack(config);
Expand All @@ -117,10 +117,10 @@ async function start(opts: *) {
messages.bundleBuilt({
stats,
platform: opts.platform,
}),
})
);
}
},
}
).listen(opts.port);
}

Expand Down
6 changes: 3 additions & 3 deletions src/hot/client/hotApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* Original code was written by Dan Abramov - https://github.com/gaearon/react-hot-loader/
*/

// eslint-disable-next-line import/no-extraneous-dependencies
// eslint-disable-next-line
import React, { Component } from 'react';
import deepForceUpdate from 'react-deep-force-update';
import hoistNonReactStatic from 'hoist-non-react-statics';
Expand Down Expand Up @@ -59,7 +59,7 @@ export function makeHot(initialRootFactory: Function, id?: string = 'default') {
console.error(
'Haul HMR: It appears that "haul-hmr/patch" ' +
'did not run immediately before the app started. Make sure that it ' +
'runs before any other code.',
'runs before any other code.'
);
}
}
Expand Down Expand Up @@ -97,7 +97,7 @@ export function makeHot(initialRootFactory: Function, id?: string = 'default') {
*/
export function redraw(
rootComponentFactory: Function,
id?: string = 'default',
id?: string = 'default'
) {
instances[id]._redraw(rootComponentFactory);
}
Expand Down
10 changes: 5 additions & 5 deletions src/hot/client/hotClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ function processPayload(payload, { logger, reporter, ...opts }) {
logger.log(
`[Haul HMR] Bundle ${payload.name
? `'${payload.name}' `
: ''}rebuilding`,
: ''}rebuilding`
);
break;
case 'built':
logger.log(
`[Haul HMR] Bundle ${payload.name
? `'${payload.name}' `
: ''}rebuilt in ${payload.time}ms`,
: ''}rebuilt in ${payload.time}ms`
);
// fall through
case 'sync':
Expand Down Expand Up @@ -99,21 +99,21 @@ module.exports = function connect(options: Object) {
ws.onopen = () => {
logger.log(
'[Haul HMR] Client connected, however until you `Enable Hot Reloading`, ' +
'you will not get any updates',
'you will not get any updates'
);
};

ws.onerror = error => {
logger.error(
`[Haul HMR] Client could not connect to the server ${opts.path}`,
error,
error
);
};

ws.onmessage = (message: MessageEvent) => {
if (typeof message.data !== 'string') {
throw new Error(
`[Haul HMR] Data from websocker#onmessage must be a string`,
`[Haul HMR] Data from websocker#onmessage must be a string`
);
}
const payload = JSON.parse(message.data);
Expand Down

0 comments on commit 4fe8102

Please sign in to comment.