Skip to content
This repository has been archived by the owner on Jun 16, 2021. It is now read-only.

Commit

Permalink
style: 💄 space-before-function-paren (p) trailingComma (e)
Browse files Browse the repository at this point in the history
```bash
â–² git-cz [feature/prettier-update] yarn lint
yarn run v1.22.5
$ yarn lint:prettier --check && yarn lint:eslint
$ prettier "**/*.{js,jsx,ts,tsx,json,md,mdx,css,html,yml,yaml,scss}" --check
Checking formatting...
All matched files use Prettier code style!
$ eslint . --ext js,jsx,ts,tsx --max-warnings=0
✨  Done in 4.00s.
```
  • Loading branch information
JeromeFitz committed Feb 28, 2021
1 parent 0231a55 commit c81029c
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 14 deletions.
9 changes: 8 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,14 @@ module.exports = {

// @question this contradicts prettier
// 'space-before-function-paren': [2, 'always'],
'space-before-function-paren': [2, 'never'],
'space-before-function-paren': [
2,
{
anonymous: 'always',
asyncArrow: 'always',
named: 'never',
},
],

'space-in-parens': [2, 'never'],
'space-infix-ops': 2,
Expand Down
3 changes: 2 additions & 1 deletion .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable filenames/match-regex */
module.exports = {
arrowParens: 'always',
bracketSpacing: false,
Expand All @@ -6,5 +7,5 @@ module.exports = {
semi: true,
singleQuote: true,
tabWidth: 2,
trailingComma: 'es5',
trailingComma: 'all',
};
2 changes: 1 addition & 1 deletion lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const executeCommand = (command, env = process.env) => {
};

// eslint-disable-next-line complexity
const main = async() => {
const main = async () => {
try {
const {cliAnswers, cliOptions, passThroughParams} = parseArgs();

Expand Down
2 changes: 1 addition & 1 deletion lib/cz.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const runInteractiveQuestions = require('./runInteractiveQuestions');
const formatCommitMessage = require('./formatCommitMessage');

exports.prompter = (cz, commit) => {
const run = async() => {
const run = async () => {
const state = createState();

await runInteractiveQuestions(state);
Expand Down
2 changes: 1 addition & 1 deletion lib/formatCommitMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const wrap = require('word-wrap');

const MAX_LINE_WIDTH = 72;

const makeAffectsLine = function(answers) {
const makeAffectsLine = function (answers) {
const selectedPackages = answers.packages;

if (selectedPackages && selectedPackages.length) {
Expand Down
2 changes: 1 addition & 1 deletion lib/questions/scope.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const fuzzy = require('fuzzy');
* @param {string} substring Substring to search with.
* @param {string[]} scopes Scopes list.
*/
const findScope = function(substring, scopes) {
const findScope = function (substring, scopes) {
return Promise.resolve(
fuzzy.filter(substring || '', scopes).map(({original: scope}) => scope),
);
Expand Down
4 changes: 2 additions & 2 deletions lib/questions/type.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const typeToListItem = ({types, disableEmoji}, type) => {
* @param {string} substring Substring to search with.
* @param {string[]} config The whole config.
*/
const findType = function(substring, config) {
const findType = function (substring, config) {
const types = config.list;

return Promise.resolve(
Expand All @@ -29,7 +29,7 @@ const findType = function(substring, config) {
exports.createQuestion = (state) => {
const {config} = state;
const question = {
message: 'Select the type of change that you\'re committing:',
message: 'Select the type of change that you’re committing:',
name: 'type',
source: (_answers, input) => findType(input, config),
type: 'autocomplete',
Expand Down
2 changes: 1 addition & 1 deletion lib/runInteractiveQuestions.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ inquirer.registerPrompt('autocomplete', AutocompletePrompt);
// promptQuestions = promptQuestions.concat(createPackagesQuestion(allPackages, changedPackages));
// }

const runInteractiveQuestions = async(state, cliAnswers) => {
const runInteractiveQuestions = async (state, cliAnswers) => {
Object.keys(cliAnswers).forEach((key) => {
state.answers[key] = cliAnswers[key];
});
Expand Down
6 changes: 3 additions & 3 deletions test/cli.test.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
const pkg = require('../package.json');
const {runCLI} = require('./testUtils');

test('git-cz --help', async() => {
test('git-cz --help', async () => {
const {getResult} = runCLI(['--help']);

const result = await getResult();

expect(result).toMatchSnapshot();
});

test('git-cz --version', async() => {
test('git-cz --version', async () => {
const {getResult} = runCLI(['--version']);

const result = await getResult();

expect(result.trim()).toBe(pkg.version);
});

test('git-cz --non-interactive', async() => {
test('git-cz --non-interactive', async () => {
const {getResult} = runCLI(['--non-interactive', '--dry-run']);

const result = await getResult();
Expand Down
4 changes: 2 additions & 2 deletions test/testUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ exports.runCLI = (args = []) => {

const {promise, stdin} = spawn('node', [CLI_PATH, ...args]);

const getResult = async() => {
const getResult = async () => {
const {stdout} = await promise;

return stdout;
};

const delay = () => new Promise((resolve) => setTimeout(resolve, 500));

const write = async(inputs = []) => {
const write = async (inputs = []) => {
for (const input of inputs) {
stdin.write(input);
await delay();
Expand Down

0 comments on commit c81029c

Please sign in to comment.