From 895b7c7652ea166e814fb698c5d9ff17c2d1319e Mon Sep 17 00:00:00 2001 From: Jerome Fitzgerald Date: Sun, 28 Feb 2021 11:46:45 -0500 Subject: [PATCH] =?UTF-8?q?style:=20=F0=9F=92=84=20comma-dangle=20update?= =?UTF-8?q?=20to=20eslint=20(to=20match=20prettier)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintrc.js | 134 +++++++++++++++---------------- lib/cli.js | 4 +- lib/createQuestions.js | 2 +- lib/createState.js | 6 +- lib/defaults.js | 28 +++---- lib/formatCommitMessage.js | 2 +- lib/getConfig.js | 2 +- lib/parseArgs.js | 14 ++-- lib/questions/body.js | 2 +- lib/questions/breaking.js | 2 +- lib/questions/issues.js | 2 +- lib/questions/lerna.js | 2 +- lib/questions/scope.js | 4 +- lib/questions/subject.js | 2 +- lib/questions/type.js | 6 +- lib/runNonInteractiveMode.js | 4 +- lib/util/lerna.js | 2 +- lint-staged.config.js | 6 +- release.config.js | 18 ++--- test/.eslintrc.js | 6 +- test/formatCommitMessage.test.js | 50 ++++++------ test/testUtils.js | 4 +- 22 files changed, 151 insertions(+), 151 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 109523bd..872c00ed 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -4,7 +4,7 @@ module.exports = { env: { browser: true, es6: true, - node: true + node: true, }, extends: ['prettier'], parser: '@babel/eslint-parser', @@ -13,11 +13,11 @@ module.exports = { experimentalObjectRestSpread: true, globalReturn: false, impliedStrict: true, - jsx: true + jsx: true, }, ecmaVersion: 2017, requireConfigFile: false, - sourceType: 'module' + sourceType: 'module', }, plugins: [ 'no-use-extend-native', @@ -26,7 +26,7 @@ module.exports = { 'jsdoc', 'promise', 'filenames', - 'unicorn' + 'unicorn', ], rules: { 'accessor-pairs': 2, @@ -40,8 +40,8 @@ module.exports = { 2, { after: true, - before: true - } + before: true, + }, ], 'babel/new-cap': 0, 'babel/no-invalid-this': 2, @@ -52,20 +52,20 @@ module.exports = { 2, '1tbs', { - allowSingleLine: false - } + allowSingleLine: false, + }, ], 'callback-return': 2, camelcase: 0, 'capitalized-comments': 0, 'class-methods-use-this': 2, - 'comma-dangle': [2, 'never'], + 'comma-dangle': [2, 'always-multiline'], 'comma-spacing': [ 2, { after: true, - before: false - } + before: false, + }, ], 'comma-style': [2, 'last'], complexity: [1, 10], @@ -83,7 +83,7 @@ module.exports = { 'filenames/match-regex': [ 2, '^[A-Z]?[a-z]+(?:[A-Z][a-z]+)*(\\.[a-z]+)*$', - false + false, ], 'filenames/no-index': 0, 'for-direction': 2, @@ -95,8 +95,8 @@ module.exports = { 2, { after: false, - before: true - } + before: true, + }, ], 'global-require': 2, 'guard-for-in': 2, @@ -106,16 +106,16 @@ module.exports = { { exceptions: ['P', 'R', '$', '_'], max: 50, - min: 2 - } + min: 2, + }, ], 'id-match': [ 2, '(^[A-Za-z]+(?:[A-Z][a-z]*)*\\d*$)|(^[A-Z]+(_[A-Z]+)*(_\\d$)*$)|(^(_|\\$)$)', { onlyDeclarations: true, - properties: true - } + properties: true, + }, ], 'import/default': 2, 'import/export': 2, @@ -123,8 +123,8 @@ module.exports = { 2, 'never', { - json: 'always' - } + json: 'always', + }, ], 'import/first': [2, 'absolute-first'], 'import/max-dependencies': 0, @@ -141,8 +141,8 @@ module.exports = { allowArray: false, allowArrowFunction: false, allowLiteral: false, - allowObject: false - } + allowObject: false, + }, ], // @question(lint) this was overriden at the end @@ -157,8 +157,8 @@ module.exports = { { devDependencies: true, optionalDependencies: true, - peerDependencies: true - } + peerDependencies: true, + }, ], 'import/no-internal-modules': 0, 'import/no-mutable-exports': 2, @@ -175,8 +175,8 @@ module.exports = { 2, { groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'], - 'newlines-between': 'never' - } + 'newlines-between': 'never', + }, ], 'import/prefer-default-export': 0, @@ -202,21 +202,21 @@ module.exports = { 2, { afterColon: true, - beforeColon: false - } + beforeColon: false, + }, ], 'keyword-spacing': [ 2, { after: true, - before: true - } + before: true, + }, ], 'line-comment-position': [ 2, { - position: 'above' - } + position: 'above', + }, ], 'linebreak-style': [2, 'unix'], 'lines-around-comment': [ @@ -229,30 +229,30 @@ module.exports = { allowObjectEnd: true, allowObjectStart: true, beforeBlockComment: true, - beforeLineComment: true - } + beforeLineComment: true, + }, ], 'lines-around-directive': [2, 'always'], 'max-len': [ 1, { - code: 160 - } + code: 160, + }, ], 'max-nested-callbacks': [1, 3], 'max-statements-per-line': [ 2, { - max: 1 - } + max: 1, + }, ], 'multiline-ternary': 0, 'new-cap': [ 0, { capIsNew: false, - newIsCap: true - } + newIsCap: true, + }, ], 'new-parens': 2, 'newline-before-return': 2, @@ -321,8 +321,8 @@ module.exports = { { max: 1, maxBOF: 0, - maxEOF: 1 - } + maxEOF: 1, + }, ], 'no-native-reassign': 2, 'no-negated-condition': 2, @@ -340,8 +340,8 @@ module.exports = { 'no-param-reassign': [ 2, { - props: false - } + props: false, + }, ], 'no-path-concat': 2, 'no-process-env': 2, @@ -350,8 +350,8 @@ module.exports = { 'no-redeclare': [ 2, { - builtinGlobals: true - } + builtinGlobals: true, + }, ], 'no-regex-spaces': 2, 'no-restricted-globals': 0, @@ -368,8 +368,8 @@ module.exports = { 2, { builtinGlobals: false, - hoist: 'all' - } + hoist: 'all', + }, ], 'no-shadow-restricted-names': 2, 'no-spaced-func': 2, @@ -405,8 +405,8 @@ module.exports = { { ignoreDestructuring: false, ignoreExport: false, - ignoreImport: false - } + ignoreImport: false, + }, ], 'no-useless-return': 2, 'no-var': 2, @@ -415,8 +415,8 @@ module.exports = { 1, { location: 'start', - terms: ['todo', '@toto'] - } + terms: ['todo', '@toto'], + }, ], 'no-whitespace-before-property': 2, 'no-with': 2, @@ -425,8 +425,8 @@ module.exports = { 'object-property-newline': [ 2, { - allowMultiplePropertiesPerLine: false - } + allowMultiplePropertiesPerLine: false, + }, ], 'object-shorthand': [2, 'always'], 'one-var': [2, 'never'], @@ -470,8 +470,8 @@ module.exports = { 2, { after: true, - before: false - } + before: false, + }, ], 'semi-style': [2, 'last'], 'sort-keys': [ @@ -479,8 +479,8 @@ module.exports = { 'asc', { caseSensitive: false, - natural: true - } + natural: true, + }, ], 'sort-vars': 2, 'space-before-blocks': [2, 'always'], @@ -491,8 +491,8 @@ module.exports = { 2, { nonwords: false, - words: true - } + words: true, + }, ], 'spaced-comment': [2, 'always'], @@ -504,8 +504,8 @@ module.exports = { 2, { after: true, - before: false - } + before: false, + }, ], 'symbol-description': 2, 'template-tag-spacing': [2, 'never'], @@ -513,8 +513,8 @@ module.exports = { 'unicorn/catch-error-name': [ 'error', { - name: 'error' - } + name: 'error', + }, ], 'unicorn/custom-error-definition': 0, 'unicorn/escape-case': 2, @@ -535,9 +535,9 @@ module.exports = { 'vars-on-top': 2, 'wrap-iife': [2, 'inside'], 'wrap-regex': 0, - yoda: 0 + yoda: 0, }, settings: { - 'import/extensions': ['.js'] - } + 'import/extensions': ['.js'], + }, }; diff --git a/lib/cli.js b/lib/cli.js index d8b32e28..4eb057b1 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -15,7 +15,7 @@ const executeCommand = (command, env = process.env) => { const proc = spawn(command, [], { env, shell: true, - stdio: [0, 1, 2] + stdio: [0, 1, 2], }); proc.on('close', (code) => { @@ -96,7 +96,7 @@ const main = async () => { 'commit', '--file', commitMsgFile, - ...appendedArgs + ...appendedArgs, ]); if (cliOptions.dryRun) { diff --git a/lib/createQuestions.js b/lib/createQuestions.js index d74eb62e..b8559e43 100644 --- a/lib/createQuestions.js +++ b/lib/createQuestions.js @@ -14,7 +14,7 @@ const creators = { lerna: qLerna, scope: qScope, subject: qSubject, - type: qType + type: qType, }; const createQuestions = (state, cliAnswers) => { diff --git a/lib/createState.js b/lib/createState.js index bc21af93..38ee2d0b 100644 --- a/lib/createState.js +++ b/lib/createState.js @@ -18,13 +18,13 @@ const createState = (config = {}) => { lerna: '', scope: '', subject: '', - type: '' + type: '', }, config: { ...getConfig(root), - ...config + ...config, }, - root + root, }; return state; diff --git a/lib/defaults.js b/lib/defaults.js index 68dfdf7c..e70553a7 100644 --- a/lib/defaults.js +++ b/lib/defaults.js @@ -4,53 +4,53 @@ const types = { chore: { description: 'Build process or auxiliary tool changes', emoji: '🤖', - value: 'chore' + value: 'chore', }, ci: { description: 'CI related changes', emoji: '🎡', - value: 'ci' + value: 'ci', }, docs: { description: 'Documentation only changes', emoji: '✏️', - value: 'docs' + value: 'docs', }, feat: { description: 'A new feature', emoji: '🎸', - value: 'feat' + value: 'feat', }, fix: { description: 'A bug fix', emoji: '🐛', - value: 'fix' + value: 'fix', }, perf: { description: 'A code change that improves performance', emoji: '⚡️', - value: 'perf' + value: 'perf', }, refactor: { description: 'A code change that neither fixes a bug or adds a feature', emoji: '💡', - value: 'refactor' + value: 'refactor', }, release: { description: 'Create a release commit', emoji: '🏹', - value: 'release' + value: 'release', }, style: { description: 'Markup, white-space, formatting, missing semi-colons...', emoji: '💄', - value: 'style' + value: 'style', }, test: { description: 'Adding missing tests', emoji: '💍', - value: 'test' - } + value: 'test', + }, }; // https://github.com/angular/angular/blob/master/CONTRIBUTING.md#type @@ -63,7 +63,7 @@ const list = [ 'refactor', 'style', 'ci', - 'perf' + 'perf', ]; // https://github.com/angular/angular/blob/master/CONTRIBUTING.md#scope @@ -76,7 +76,7 @@ const questions = [ 'body', 'breaking', 'issues', - 'lerna' + 'lerna', ]; module.exports = { @@ -89,5 +89,5 @@ module.exports = { minMessageLength: 3, questions, scopes, - types + types, }; diff --git a/lib/formatCommitMessage.js b/lib/formatCommitMessage.js index a3869524..11a991bd 100644 --- a/lib/formatCommitMessage.js +++ b/lib/formatCommitMessage.js @@ -19,7 +19,7 @@ const formatCommitMessage = (state) => { const wrapOptions = { indent: '', trim: true, - width: MAX_LINE_WIDTH + width: MAX_LINE_WIDTH, }; const emoji = config.types[answers.type].emoji; diff --git a/lib/getConfig.js b/lib/getConfig.js index 8816dcd2..adc9ca8d 100644 --- a/lib/getConfig.js +++ b/lib/getConfig.js @@ -51,7 +51,7 @@ const getConfig = (root) => { return { ...defaults, - ...overrides + ...overrides, }; }; diff --git a/lib/parseArgs.js b/lib/parseArgs.js index 503171c1..be3ee5db 100644 --- a/lib/parseArgs.js +++ b/lib/parseArgs.js @@ -50,7 +50,7 @@ const parseArgs = () => { } = minimist(process.argv.slice(2), { alias: { h: 'help', - v: 'version' + v: 'version', }, boolean: [ 'version', @@ -58,7 +58,7 @@ const parseArgs = () => { 'disable-emoji', 'non-interactive', 'hook', - 'dry-run' + 'dry-run', ], string: [ 'format', @@ -68,8 +68,8 @@ const parseArgs = () => { 'body', 'breaking', 'issues', - 'learna' - ] + 'learna', + ], }); if (help || h) { @@ -89,7 +89,7 @@ const parseArgs = () => { help, hook, nonInteractive, - version + version, }; const cliAnswers = { @@ -99,13 +99,13 @@ const parseArgs = () => { lerna, scope, subject, - type + type, }; return { cliAnswers, cliOptions, - passThroughParams + passThroughParams, }; }; diff --git a/lib/questions/body.js b/lib/questions/body.js index c50720fd..37b66c94 100644 --- a/lib/questions/body.js +++ b/lib/questions/body.js @@ -2,7 +2,7 @@ exports.createQuestion = () => { const question = { message: 'Provide a longer description of the change:\n ', name: 'body', - type: 'input' + type: 'input', }; return question; diff --git a/lib/questions/breaking.js b/lib/questions/breaking.js index c2647672..765593a0 100644 --- a/lib/questions/breaking.js +++ b/lib/questions/breaking.js @@ -4,7 +4,7 @@ exports.createQuestion = () => { const question = { message: `List any breaking changes\n ${chalk.red('BREAKING CHANGE')}:`, name: 'breaking', - type: 'input' + type: 'input', }; return question; diff --git a/lib/questions/issues.js b/lib/questions/issues.js index 154366b3..b53a53c5 100644 --- a/lib/questions/issues.js +++ b/lib/questions/issues.js @@ -1,5 +1,5 @@ exports.createQuestion = () => ({ message: 'Issues this commit closes, e.g #123:', name: 'issues', - type: 'input' + type: 'input', }); diff --git a/lib/questions/lerna.js b/lib/questions/lerna.js index ae424885..606fc71a 100644 --- a/lib/questions/lerna.js +++ b/lib/questions/lerna.js @@ -13,7 +13,7 @@ exports.createQuestion = (state) => { default: changedPackages, message: `The packages that this commit has affected (${changedPackages.length} detected)\n`, name: 'packages', - type: 'checkbox' + type: 'checkbox', }; return question; diff --git a/lib/questions/scope.js b/lib/questions/scope.js index 7523fb44..b0826718 100644 --- a/lib/questions/scope.js +++ b/lib/questions/scope.js @@ -8,7 +8,7 @@ const fuzzy = require('fuzzy'); */ const findScope = function (substring, scopes) { return Promise.resolve( - fuzzy.filter(substring || '', scopes).map(({original: scope}) => scope) + fuzzy.filter(substring || '', scopes).map(({original: scope}) => scope), ); }; @@ -31,7 +31,7 @@ exports.createQuestion = (state) => { message: 'Select the scope this component affects:', name: 'scope', source: (_answers, input) => findScope(input, scopes), - type: 'autocomplete' + type: 'autocomplete', }; return question; diff --git a/lib/questions/subject.js b/lib/questions/subject.js index c53a8398..871c9f18 100644 --- a/lib/questions/subject.js +++ b/lib/questions/subject.js @@ -28,7 +28,7 @@ exports.createQuestion = (state) => { name: 'subject', type: 'limitedInput', validate: (input) => - input.length >= config.minMessageLength || minTitleLengthErrorMessage + input.length >= config.minMessageLength || minTitleLengthErrorMessage, }; return question; diff --git a/lib/questions/type.js b/lib/questions/type.js index e432f895..7571d78c 100644 --- a/lib/questions/type.js +++ b/lib/questions/type.js @@ -6,7 +6,7 @@ const typeToListItem = ({types, disableEmoji}, type) => { return { name: prefix + (value + ':').padEnd(12, ' ') + description, - value + value, }; }; @@ -22,7 +22,7 @@ const findType = function (substring, config) { return Promise.resolve( fuzzy .filter(substring || '', types) - .map(({original: type}) => typeToListItem(config, type)) + .map(({original: type}) => typeToListItem(config, type)), ); }; @@ -32,7 +32,7 @@ exports.createQuestion = (state) => { message: 'Select the type of change that you\'re committing:', name: 'type', source: (_answers, input) => findType(input, config), - type: 'autocomplete' + type: 'autocomplete', }; return question; diff --git a/lib/runNonInteractiveMode.js b/lib/runNonInteractiveMode.js index 4577b85a..d472fc09 100644 --- a/lib/runNonInteractiveMode.js +++ b/lib/runNonInteractiveMode.js @@ -1,11 +1,11 @@ const runNonInteractiveMode = ( state, - {type = 'chore', subject = 'automated commit', ...restAnswers} + {type = 'chore', subject = 'automated commit', ...restAnswers}, ) => { const answers = { subject, type, - ...restAnswers + ...restAnswers, }; Object.keys(state.answers).forEach((key) => { diff --git a/lib/util/lerna.js b/lib/util/lerna.js index e33ef57d..a1aa7cca 100755 --- a/lib/util/lerna.js +++ b/lib/util/lerna.js @@ -74,5 +74,5 @@ const getChangedPackages = (state) => { module.exports = { getAllPackages, getChangedPackages, - isLerna + isLerna, }; diff --git a/lint-staged.config.js b/lint-staged.config.js index 5f26ed62..4e852557 100644 --- a/lint-staged.config.js +++ b/lint-staged.config.js @@ -9,7 +9,7 @@ module.exports = { return [ `prettier --with-node-modules --ignore-path='./.prettierignore_staged' --write ${filenames}`, `eslint --no-ignore --max-warnings=0 --fix ${filenames}`, - `git add ${filenames}` + `git add ${filenames}`, ]; }, @@ -18,7 +18,7 @@ module.exports = { return [ `prettier --with-node-modules --ignore-path='./.prettierignore_staged' --write ${filenames}`, - `git add ${filenames}` + `git add ${filenames}`, ]; - } + }, }; diff --git a/release.config.js b/release.config.js index b94cb852..9aeb73c9 100644 --- a/release.config.js +++ b/release.config.js @@ -7,7 +7,7 @@ module.exports = { branches: [ {name: 'main', prerelease: 'main'}, {name: 'master'}, - {name: 'canary', prerelease: 'canary'} + {name: 'canary', prerelease: 'canary'}, ], extends: [], plugins: [ @@ -15,19 +15,19 @@ module.exports = { '@semantic-release/commit-analyzer', { parserOpts: { - noteKeywords: ['BREAKING CHANGE', 'BREAKING CHANGES', 'BREAKING'] - } - } + noteKeywords: ['BREAKING CHANGE', 'BREAKING CHANGES', 'BREAKING'], + }, + }, ], [ '@semantic-release/release-notes-generator', { parserOpts: { - noteKeywords: ['BREAKING CHANGE', 'BREAKING CHANGES', 'BREAKING'] - } - } + noteKeywords: ['BREAKING CHANGE', 'BREAKING CHANGES', 'BREAKING'], + }, + }, ], '@semantic-release/npm', - '@semantic-release/git' - ] + '@semantic-release/git', + ], }; diff --git a/test/.eslintrc.js b/test/.eslintrc.js index 79fd96d9..e28ffef0 100644 --- a/test/.eslintrc.js +++ b/test/.eslintrc.js @@ -1,13 +1,13 @@ /* eslint-disable filenames/match-regex */ module.exports = { env: { - jest: true + jest: true, }, plugins: ['jest'], rules: { 'jest/no-disabled-tests': 'error', 'jest/no-focused-tests': 'error', 'jest/no-identical-title': 'error', - 'jest/valid-expect': 'error' - } + 'jest/valid-expect': 'error', + }, }; diff --git a/test/formatCommitMessage.test.js b/test/formatCommitMessage.test.js index 3cffa4a2..8e316186 100644 --- a/test/formatCommitMessage.test.js +++ b/test/formatCommitMessage.test.js @@ -18,54 +18,54 @@ const defaultConfig = { chore: { description: 'Build process or auxiliary tool changes', emoji: '🤖', - value: 'chore' + value: 'chore', }, ci: { description: 'CI related changes', emoji: '🎡', - value: 'ci' + value: 'ci', }, docs: { description: 'Documentation only changes', emoji: '✏️', - value: 'docs' + value: 'docs', }, feat: { description: 'A new feature', emoji: '🎸', - value: 'feat' + value: 'feat', }, fix: { description: 'A bug fix', emoji: '🐛', - value: 'fix' + value: 'fix', }, perf: { description: 'A code change that improves performance', emoji: '⚡️', - value: 'perf' + value: 'perf', }, refactor: { description: 'A code change that neither fixes a bug or adds a feature', emoji: '💡', - value: 'refactor' + value: 'refactor', }, release: { description: 'Create a release commit', emoji: '🏹', - value: 'release' + value: 'release', }, style: { description: 'Markup, white-space, formatting, missing semi-colons...', emoji: '💄', - value: 'style' + value: 'style', }, test: { description: 'Adding missing tests', emoji: '💍', - value: 'test' - } - } + value: 'test', + }, + }, }; const defaultState = { @@ -76,10 +76,10 @@ const defaultState = { lerna: '', scope: '', subject: 'First commit', - type: 'feat' + type: 'feat', }, config: defaultConfig, - root: '/Users/vad/dev/git-cz' + root: '/Users/vad/dev/git-cz', }; describe('formatCommitMessage()', () => { @@ -88,8 +88,8 @@ describe('formatCommitMessage()', () => { ...defaultState, config: { ...defaultConfig, - disableEmoji: true - } + disableEmoji: true, + }, }); expect(message).equal('feat: First commit'); @@ -100,12 +100,12 @@ describe('formatCommitMessage()', () => { ...defaultState, answers: { ...defaultState.answers, - scope: 'init' + scope: 'init', }, config: { ...defaultConfig, - disableEmoji: true - } + disableEmoji: true, + }, }); expect(message).equal('feat(init): First commit'); @@ -116,13 +116,13 @@ describe('formatCommitMessage()', () => { ...defaultState, answers: { ...defaultState.answers, - scope: 'init' + scope: 'init', }, config: { ...defaultConfig, format: '{subject} :{scope}{type}', - disableEmoji: true - } + disableEmoji: true, + }, }); expect(message).equal('First commit :(init)feat'); @@ -134,13 +134,13 @@ describe('formatCommitMessage()', () => { ...defaultState, answers: { ...defaultState.answers, - scope: 'init' + scope: 'init', }, config: { ...defaultConfig, format: `{subject} :{scope}{type}${isDynamic && ' [skip ci]'}`, - disableEmoji: true - } + disableEmoji: true, + }, }); expect(message).equal('First commit :(init)feat [skip ci]'); diff --git a/test/testUtils.js b/test/testUtils.js index 36969ad2..4e67c38f 100644 --- a/test/testUtils.js +++ b/test/testUtils.js @@ -4,7 +4,7 @@ const spawn = require('spawncommand'); exports.keys = { down: '\u001B\u005B\u0042', enter: '\r', - up: '\u001B\u005B\u0041' + up: '\u001B\u005B\u0041', }; exports.runCLI = (args = []) => { @@ -31,6 +31,6 @@ exports.runCLI = (args = []) => { return { getResult, - write + write, }; };