Skip to content

Commit

Permalink
chore: Reformat all files with new eslint rules
Browse files Browse the repository at this point in the history
  • Loading branch information
zimme committed Dec 3, 2017
1 parent 23b023e commit 89aebb1
Show file tree
Hide file tree
Showing 19 changed files with 724 additions and 721 deletions.
4 changes: 2 additions & 2 deletions __mocks__/find-up.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {sync}
module.exports = { sync };

function sync(filename) {
return `/${filename}`
return `/${filename}`;
}
26 changes: 13 additions & 13 deletions __mocks__/fs.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
const readFile = jest.fn((filePath, encoding, callback) => {
callback(null, `console.log('this is a mock thing for file: ${filePath}')`)
})
callback(null, `console.log('this is a mock thing for file: ${filePath}')`);
});
const writeFile = jest.fn((filePath, contents, callback) => {
callback(null)
})
callback(null);
});

const readFileSync = jest.fn(filePath => {
if (filePath.indexOf('.eslintrc') !== -1) {
return '{ "rules": { "semi": "error" } }'
if (filePath.indexOf(".eslintrc") !== -1) {
return '{ "rules": { "semi": "error" } }';
}

if (filePath.indexOf('eslintignore')) {
return '*ignored*\n**/ignored/**\n'
if (filePath.indexOf("eslintignore")) {
return "*ignored*\n**/ignored/**\n";
} else {
throw new Error('readFileSync mock does nto yet handle ', filePath)
throw new Error("readFileSync mock does nto yet handle ", filePath);
}
})
});

const readdirSync = jest.fn(() => {
return []
})
return [];
});

module.exports = {readFile, writeFile, readFileSync, readdirSync}
module.exports = { readFile, writeFile, readFileSync, readdirSync };
6 changes: 3 additions & 3 deletions __mocks__/get-stdin.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = jest.fn(function mockGetStdin() {
return Promise.resolve(module.exports.stdin)
})
return Promise.resolve(module.exports.stdin);
});

module.exports.stdin = ''
module.exports.stdin = "";
100 changes: 50 additions & 50 deletions __mocks__/glob.js
Original file line number Diff line number Diff line change
@@ -1,70 +1,70 @@
module.exports = jest.fn(function mockGlob(globString, options, callback) {
/* eslint complexity:0 */
if (globString.includes('1')) {
if (globString.includes("1")) {
callback(null, [
fredProject('index.js'),
fredProject('start.js'),
fredProject('stop/index.js'),
fredProject('stop/log.js'),
])
} else if (globString.includes('2')) {
fredProject("index.js"),
fredProject("start.js"),
fredProject("stop/index.js"),
fredProject("stop/log.js")
]);
} else if (globString.includes("2")) {
callback(null, [
fredProject('index.js'),
fredProject('start.js'),
fredProject('continue/index.js'),
fredProject('continue/forever.js'),
])
} else if (globString.includes('node_modules')) {
fredProject("index.js"),
fredProject("start.js"),
fredProject("continue/index.js"),
fredProject("continue/forever.js")
]);
} else if (globString.includes("node_modules")) {
callback(null, [
fredProject('foo/node_modules/stuff1.js'),
fredProject('foo/node_modules/stuff2.js'),
fredProject('foo/node_modules/stuff3.js'),
])
} else if (globString.includes('files-with-syntax-errors')) {
fredProject("foo/node_modules/stuff1.js"),
fredProject("foo/node_modules/stuff2.js"),
fredProject("foo/node_modules/stuff3.js")
]);
} else if (globString.includes("files-with-syntax-errors")) {
callback(null, [
fredProject('syntax-error1.js'),
fredProject('syntax-error2.js'),
])
} else if (globString.includes('no-match')) {
callback(null, [])
} else if (globString.includes('throw-error')) {
callback(new Error('something weird happened'))
} else if (globString.includes('no-change')) {
fredProject("syntax-error1.js"),
fredProject("syntax-error2.js")
]);
} else if (globString.includes("no-match")) {
callback(null, []);
} else if (globString.includes("throw-error")) {
callback(new Error("something weird happened"));
} else if (globString.includes("no-change")) {
callback(null, [
fredProject('no-change/1.js'),
fredProject('no-change/2.js'),
fredProject('no-change/3.js'),
])
} else if (globString.includes('ignored')) {
fredProject("no-change/1.js"),
fredProject("no-change/2.js"),
fredProject("no-change/3.js")
]);
} else if (globString.includes("ignored")) {
callback(null, [
fredProject('ignored1.js'),
fredProject('ignored2.js'),
fredProject('ignored3.js'),
fredProject('applied4.js'),
])
} else if (globString.includes('no-eslint-ignore')) {
fredProject("ignored1.js"),
fredProject("ignored2.js"),
fredProject("ignored3.js"),
fredProject("applied4.js")
]);
} else if (globString.includes("no-eslint-ignore")) {
callback(null, [
barneyProject('no-ignore/1.js'),
barneyProject('no-ignore/2.js'),
barneyProject('no-ignore/3.js'),
])
} else if (globString.includes('eslint-config-error')) {
barneyProject("no-ignore/1.js"),
barneyProject("no-ignore/2.js"),
barneyProject("no-ignore/3.js")
]);
} else if (globString.includes("eslint-config-error")) {
callback(null, [
fredProject('eslint-config-error/1.js'),
fredProject('eslint-config-error/2.js'),
])
fredProject("eslint-config-error/1.js"),
fredProject("eslint-config-error/2.js")
]);
} else {
throw new Error(
`Your test globString: "${globString}"` +
` doesn't have associated mock data.`,
)
` doesn't have associated mock data.`
);
}
})
});

function fredProject(path) {
return `/Users/fredFlintstone/Developer/top-secret/footless-carriage/${path}`
return `/Users/fredFlintstone/Developer/top-secret/footless-carriage/${path}`;
}

function barneyProject(path) {
return `/Users/barneyRubble/Developer/top-secret/tesla/${path}`
return `/Users/barneyRubble/Developer/top-secret/tesla/${path}`;
}
20 changes: 10 additions & 10 deletions __mocks__/prettier-eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
// so we just return some spies here and assert
// that we're calling prettier-eslint APIs correctly
// eslint-disable-next-line require-await
const format = jest.fn(({text, filePath = ''}) => {
if (text === 'MOCK_SYNTAX_ERROR' || filePath.includes('syntax-error')) {
throw new Error('Mock error for a syntax error')
} else if (filePath.includes('eslint-config-error')) {
throw new Error('Some weird eslint config error')
} else if (filePath.includes('no-change')) {
return text
const format = jest.fn(({ text, filePath = "" }) => {
if (text === "MOCK_SYNTAX_ERROR" || filePath.includes("syntax-error")) {
throw new Error("Mock error for a syntax error");
} else if (filePath.includes("eslint-config-error")) {
throw new Error("Some weird eslint config error");
} else if (filePath.includes("no-change")) {
return text;
}
return `MOCK_OUTPUT for ${filePath || 'stdin'}`
})
return `MOCK_OUTPUT for ${filePath || "stdin"}`;
});

export default format
export default format;
4 changes: 2 additions & 2 deletions cli-test/tests/__snapshots__/index.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

exports[`file contents: prettier-eslint cli-test/fixtures/example*.js --write --no-eslint-ignore 1`] = `
Object {
"example1Result": "const {example1} = baz.bar
"example1Result": "const { example1 } = baz.bar;
",
"example2Result": "function example2(thing) {
return thing
return thing;
}
",
}
Expand Down
Loading

0 comments on commit 89aebb1

Please sign in to comment.