Skip to content

Commit

Permalink
chore: Require spaces around infix operators (#483)
Browse files Browse the repository at this point in the history
  • Loading branch information
pdehaan authored and kumar303 committed Sep 13, 2016
1 parent 2c06dbd commit a6c5004
Show file tree
Hide file tree
Showing 15 changed files with 54 additions and 50 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"semi": [2, "always"],
"space-before-blocks": [2, "always"],
"space-before-function-paren": [2, "never"],
"space-infix-ops": 0,
"space-infix-ops": 2,
"strict": [2, "never"],
"valid-typeof": 2,
"wrap-iife": [2, "inside"],
Expand Down
8 changes: 4 additions & 4 deletions src/cmd/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ export type BuildCmdOptions = {
};

export default function build(
{sourceDir, artifactsDir, asNeeded=false}: BuildCmdParams,
{sourceDir, artifactsDir, asNeeded = false}: BuildCmdParams,
{
manifestData, fileFilter=new FileFilter(),
onSourceChange=defaultSourceWatcher,
packageCreator=defaultPackageCreator,
manifestData, fileFilter = new FileFilter(),
onSourceChange = defaultSourceWatcher,
packageCreator = defaultPackageCreator,
}: BuildCmdOptions = {}
): Promise<ExtensionBuildResult> {
const rebuildAsNeeded = asNeeded; // alias for `build --as-needed`
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ export default function lint(
metadata, pretty,
}: LintCmdParams,
{
createLinter=defaultLinterCreator,
fileFilter=new FileFilter(),
createLinter = defaultLinterCreator,
fileFilter = new FileFilter(),
}: LintCmdOptions = {}
): Promise<void> {
log.debug(`Running addons-linter on ${sourceDir}`);
Expand Down
16 changes: 8 additions & 8 deletions src/cmd/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export type WatcherCreatorFn = (params: WatcherCreatorParams) => Watchpack;
export function defaultWatcherCreator(
{
addonId, client, sourceDir, artifactsDir,
onSourceChange=defaultSourceWatcher,
onSourceChange = defaultSourceWatcher,
}: WatcherCreatorParams
): Watchpack {
return onSourceChange({
Expand Down Expand Up @@ -78,7 +78,7 @@ export function defaultReloadStrategy(
addonId, firefoxProcess, client, profile, sourceDir, artifactsDir,
}: ReloadStrategyParams,
{
createWatcher=defaultWatcherCreator,
createWatcher = defaultWatcherCreator,
}: ReloadStrategyOptions = {}
): void {
let watcher: Watchpack;
Expand All @@ -102,9 +102,9 @@ export type CreateFirefoxClientParams = {

export function defaultFirefoxClient(
{
connectToFirefox=defaultFirefoxConnector,
connectToFirefox = defaultFirefoxConnector,
// A max of 250 will try connecting for 30 seconds.
maxRetries=250, retryInterval=120,
maxRetries = 250, retryInterval = 120,
}: CreateFirefoxClientParams = {}
): Promise<RemoteFirefox> {
var retries = 0;
Expand Down Expand Up @@ -161,12 +161,12 @@ export type CmdRunOptions = {
export default function run(
{
sourceDir, artifactsDir, firefox, firefoxProfile,
preInstall=false, noReload=false,
preInstall = false, noReload = false,
}: CmdRunParams,
{
firefoxApp=defaultFirefoxApp,
firefoxClient=defaultFirefoxClient,
reloadStrategy=defaultReloadStrategy,
firefoxApp = defaultFirefoxApp,
firefoxClient = defaultFirefoxClient,
reloadStrategy = defaultReloadStrategy,
}: CmdRunOptions = {}): Promise<Object> {

log.info(`Running web extension from ${sourceDir}`);
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/sign.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default function sign(
apiUrlPrefix, id, timeout,
}: SignParams,
{
build=defaultBuilder, signAddon=defaultAddonSigner,
build = defaultBuilder, signAddon = defaultAddonSigner,
preValidatedManifest,
}: SignOptions = {}
): Promise<SignResult> {
Expand Down
26 changes: 15 additions & 11 deletions src/firefox/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ export type RemotePortFinderFn =

export function defaultRemotePortFinder(
{
portToTry=REMOTE_PORT,
connectToFirefox=defaultFirefoxConnector,
portToTry = REMOTE_PORT,
connectToFirefox = defaultFirefoxConnector,
}: RemotePortFinderParams = {}
): Promise<number> {
log.debug(`Checking if remote Firefox port ${portToTry} is available`);
Expand Down Expand Up @@ -115,8 +115,8 @@ export type FirefoxRunOptions = {
export function run(
profile: FirefoxProfile,
{
fxRunner=defaultFxRunner,
findRemotePort=defaultRemotePortFinder,
fxRunner = defaultFxRunner,
findRemotePort = defaultRemotePortFinder,
firefoxBinary, binaryArgs,
}: FirefoxRunOptions = {}
): Promise<FirefoxProcess> {
Expand Down Expand Up @@ -196,8 +196,8 @@ export type ConfigureProfileFn = (
export function configureProfile(
profile: FirefoxProfile,
{
app='firefox',
getPrefs=defaultPrefGetter,
app = 'firefox',
getPrefs = defaultPrefGetter,
}: ConfigureProfileOptions = {}
): Promise<FirefoxProfile> {
return new Promise((resolve) => {
Expand Down Expand Up @@ -228,7 +228,7 @@ export type CreateProfileParams = {
* The profile will be deleted when the system process exits.
*/
export function createProfile(
{app, configureThisProfile=configureProfile}: CreateProfileParams = {}
{app, configureThisProfile = configureProfile}: CreateProfileParams = {}
): Promise<FirefoxProfile> {
return new Promise(
(resolve) => {
Expand Down Expand Up @@ -262,8 +262,8 @@ export type CopyProfileOptions = {
export function copyProfile(
profileDirectory: string,
{
copyFromUserProfile=defaultUserProfileCopier,
configureThisProfile=configureProfile,
copyFromUserProfile = defaultUserProfileCopier,
configureThisProfile = configureProfile,
app,
}: CopyProfileOptions = {}
): Promise<FirefoxProfile> {
Expand Down Expand Up @@ -310,8 +310,12 @@ export type InstallExtensionParams = {
* text file that contains the path to the extension source.
*/
export function installExtension(
{asProxy=false, manifestData, profile, extensionPath}: InstallExtensionParams
): Promise<any> {
{
asProxy = false,
manifestData,
profile,
extensionPath,
}: InstallExtensionParams): Promise<any> {
// This more or less follows
// https://github.com/saadtazi/firefox-profile-js/blob/master/lib/firefox_profile.js#L531
// (which is broken for web extensions).
Expand Down
2 changes: 1 addition & 1 deletion src/firefox/remote.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ declare function exports(

export default function connect(
port: number = REMOTE_PORT,
{connectToFirefox=defaultFirefoxConnector}: ConnectOptions = {}
{connectToFirefox = defaultFirefoxConnector}: ConnectOptions = {}
): Promise<RemoteFirefox> {
log.debug(`Connecting to Firefox on port ${port}`);
return connectToFirefox(port)
Expand Down
10 changes: 5 additions & 5 deletions src/program.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class Program {

constructor(
argv: ?Array<string>,
{absolutePackageDir=process.cwd()}: {absolutePackageDir?: string} = {}
{absolutePackageDir = process.cwd()}: {absolutePackageDir?: string} = {}
) {
// This allows us to override the process argv which is useful for
// testing.
Expand Down Expand Up @@ -77,8 +77,8 @@ export class Program {
}

run(absolutePackageDir: string,
{systemProcess=process, logStream=defaultLogStream,
getVersion=defaultVersionGetter, shouldExitProgram=true}
{systemProcess = process, logStream = defaultLogStream,
getVersion = defaultVersionGetter, shouldExitProgram = true}
: Object = {}): Promise<any> {

this.shouldExitProgram = shouldExitProgram;
Expand Down Expand Up @@ -131,8 +131,8 @@ export function defaultVersionGetter(absolutePackageDir: string): string {

export function main(
absolutePackageDir: string,
{getVersion=defaultVersionGetter, commands=defaultCommands, argv,
runOptions={}}: Object = {}): Promise<any> {
{getVersion = defaultVersionGetter, commands = defaultCommands, argv,
runOptions = {}}: Object = {}): Promise<any> {
let program = new Program(argv, {absolutePackageDir});
// yargs uses magic camel case expansion to expose options on the
// final argv object. For example, the 'artifacts-dir' option is alternatively
Expand Down
8 changes: 4 additions & 4 deletions src/util/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class ConsoleStream {
isCapturing: boolean;
capturedMessages: Array<string>;

constructor({verbose=false}: ConsoleStreamParams = {}) {
constructor({verbose = false}: ConsoleStreamParams = {}) {
this.verbose = verbose;
this.isCapturing = false;
this.capturedMessages = [];
Expand All @@ -61,7 +61,7 @@ export class ConsoleStream {

write(
packet: BunyanLogEntry,
{localProcess=process}: ConsoleOptions = {}
{localProcess = process}: ConsoleOptions = {}
): void {
const thisLevel: BunyanLogLevel = this.verbose ? bunyan.TRACE : bunyan.INFO;
if (packet.level >= thisLevel) {
Expand All @@ -83,7 +83,7 @@ export class ConsoleStream {
this.capturedMessages = [];
}

flushCapturedLogs({localProcess=process}: ConsoleOptions = {}) {
flushCapturedLogs({localProcess = process}: ConsoleOptions = {}) {
for (let msg of this.capturedMessages) {
localProcess.stdout.write(msg);
}
Expand Down Expand Up @@ -115,7 +115,7 @@ export type CreateLoggerOptions = {

export function createLogger(
filename: string,
{createBunyanLog=defaultLogCreator}: CreateLoggerOptions = {}
{createBunyanLog = defaultLogCreator}: CreateLoggerOptions = {}
): Logger {
return createBunyanLog({
// Strip the leading src/ from file names (which is in all file names) to
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ export function fake<T>(original: Object, methods: Object = {}): T {
* connect() of 'node-firefox-connect'
*/
export function fakeFirefoxClient(
{requestResult={}, requestError=null,
makeRequestResult={}, makeRequestError=null}: Object = {}) {
{requestResult = {}, requestError = null,
makeRequestResult = {}, makeRequestError = null}: Object = {}) {
return {
disconnect: sinon.spy(() => {}),
request: sinon.spy(
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/test-cmd/test.run.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ describe('run', () => {

return {
argv, options,
run: (customArgv={}, customOpt={}) => run(
run: (customArgv = {}, customOpt = {}) => run(
{...argv, ...customArgv},
{...options, ...customOpt}
),
};
}

function getFakeFirefox(implementations={}) {
function getFakeFirefox(implementations = {}) {
let profile = {}; // empty object just to avoid errors.
let allImplementations = {
createProfile: () => Promise.resolve(profile),
Expand Down Expand Up @@ -242,7 +242,7 @@ describe('run', () => {
};
return {
config,
createWatcher: (customConfig={}) => {
createWatcher: (customConfig = {}) => {
return defaultWatcherCreator({...config, ...customConfig});
},
};
Expand Down Expand Up @@ -321,7 +321,7 @@ describe('run', () => {
...options,
client,
watcher,
reloadStrategy: (argOverride={}, optOverride={}) => {
reloadStrategy: (argOverride = {}, optOverride = {}) => {
return defaultReloadStrategy(
{...args, ...argOverride},
{...options, ...optOverride});
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test-cmd/test.sign.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe('sign', () => {
*/
function sign(
tmpDir: Object, stubs: Object,
{extraArgs={}, extraOptions={}}: Object = {}): Promise<*> {
{extraArgs = {}, extraOptions = {}}: Object = {}): Promise<*> {
return completeSignCommand({
verbose: false,
artifactsDir: path.join(tmpDir.path(), 'artifacts-dir'),
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test-firefox/test.firefox.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('firefox', () => {
stderr: {on: () => {}},
};

function createFakeFxRunner(firefoxOverrides={}) {
function createFakeFxRunner(firefoxOverrides = {}) {
let firefox = {
...deepcopy(fakeFirefoxProcess),
...firefoxOverrides,
Expand All @@ -46,7 +46,7 @@ describe('firefox', () => {
}));
}

function runFirefox({profile=fakeProfile, ...args}: Object = {}) {
function runFirefox({profile = fakeProfile, ...args}: Object = {}) {
return firefox.run(profile, {
fxRunner: createFakeFxRunner(),
findRemotePort: () => Promise.resolve(6000),
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test-firefox/test.remote.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('firefox.remote', () => {

describe('connect', () => {

function prepareConnection(port=undefined, options={}) {
function prepareConnection(port = undefined, options = {}) {
options = {
connectToFirefox:
sinon.spy(() => Promise.resolve(fakeFirefoxClient())),
Expand Down Expand Up @@ -52,7 +52,7 @@ describe('firefox.remote', () => {
return {id: 'some-id', actor: 'serv1.localhost'};
}

function makeInstance(client=fakeFirefoxClient()) {
function makeInstance(client = fakeFirefoxClient()) {
return new RemoteFirefox(client);
}

Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test.program.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {ConsoleStream} from '../../src/util/logger';

describe('program.Program', () => {

function run(program, options={}) {
function run(program, options = {}) {
let fakeProcess = fake(process);
let absolutePackageDir = path.join(__dirname, '..', '..');
return program.run(
Expand Down Expand Up @@ -242,7 +242,7 @@ describe('program.Program', () => {

describe('program.main', () => {

function run(argv, {projectRoot='', ...mainOptions}: Object = {}) {
function run(argv, {projectRoot = '', ...mainOptions}: Object = {}) {
const runOptions = {shouldExitProgram: false, systemProcess: fake(process)};
return main(projectRoot, {argv, runOptions, ...mainOptions});
}
Expand Down

0 comments on commit a6c5004

Please sign in to comment.