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

Commit

Permalink
refactor: ♻️ @jeromefitz/codestyle, prep for ts
Browse files Browse the repository at this point in the history
lint: 🚨 update to codebase with new codestyle ✅️ all good

prune: 🔥 renovate.json 🤷️

lint: 🚨 put back old rules (except where noted) and plugins

Let's move "slowly" I guess

typo: ✏️ lint-fix now since these scripts got updated
  • Loading branch information
JeromeFitz authored and kodiakhq[bot] committed May 1, 2021
1 parent 4ad6b62 commit f88e83a
Show file tree
Hide file tree
Showing 50 changed files with 1,019 additions and 761 deletions.
23 changes: 23 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
root = true

[*]
indent_style = space
indent_size = 2
tab_width = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false

[*.js]
quote_type = single

[{*.c,*.cc,*.h,*.hh,*.cpp,*.hpp,*.m,*.mm,*.mpp,*.js,*.java,*.go,*.rs,*.php,*.ng,*.jsx,*.ts,*.d,*.cs,*.swift}]
curly_bracket_next_line = false
spaces_around_operators = true
spaces_around_brackets = outside
# close enough to 1TB
indent_brace_style = K&R
44 changes: 19 additions & 25 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,13 @@
/* eslint-disable import/unambiguous */
/* eslint-disable filenames/match-regex */
const config = require('@jeromefitz/codestyle/.eslintrc.js')

module.exports = {
env: {
browser: true,
es6: true,
node: true,
},
extends: ['prettier'],
...config,
parser: '@babel/eslint-parser',
parserOptions: {
ecmaFeatures: {
experimentalObjectRestSpread: true,
globalReturn: false,
impliedStrict: true,
jsx: true,
},
ecmaVersion: 2017,
requireConfigFile: false,
sourceType: 'module',
},

// @todo(deprecate-old-lint)
plugins: [
...config.plugins,
'no-use-extend-native',
'babel',
'import',
Expand All @@ -29,6 +17,9 @@ module.exports = {
'unicorn',
],
rules: {
...config.rules,

// @todo(deprecate-old-lint)
'accessor-pairs': 2,
'array-bracket-newline': 0,
'array-bracket-spacing': [2, 'never'],
Expand All @@ -45,7 +36,9 @@ module.exports = {
],
'babel/new-cap': 0,
'babel/no-invalid-this': 2,
'babel/object-curly-spacing': [2, 'never'],

// @note(updated)
'babel/object-curly-spacing': [2, 'always'],
'block-scoped-var': 2,
'block-spacing': [2, 'always'],
'brace-style': [
Expand All @@ -59,7 +52,9 @@ module.exports = {
camelcase: 0,
'capitalized-comments': 0,
'class-methods-use-this': 2,
'comma-dangle': [2, 'always-multiline'],

// @note(updated)
'comma-dangle': [2, 'only-multiline'],
'comma-spacing': [
2,
{
Expand Down Expand Up @@ -465,7 +460,9 @@ module.exports = {
'require-await': 1,
'require-jsdoc': 0,
'require-yield': 2,
semi: [2, 'always'],

// @note(updated)
semi: [2, 'never'],
'semi-spacing': [
2,
{
Expand Down Expand Up @@ -548,7 +545,4 @@ module.exports = {
'wrap-regex': 0,
yoda: 0,
},
settings: {
'import/extensions': ['.js'],
},
};
}
13 changes: 4 additions & 9 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
/* eslint-disable filenames/match-regex */
const config = require('@jeromefitz/codestyle/.prettierrc.js')

module.exports = {
arrowParens: 'always',
bracketSpacing: false,
endOfLine: 'auto',
printWidth: 85,
semi: true,
singleQuote: true,
tabWidth: 2,
trailingComma: 'all',
};
...config,
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ module.exports = {
value: 'test',
},
},
};
}
```

## Non-interactive mode
Expand Down Expand Up @@ -359,7 +359,7 @@ module.exports = {
},
},
format: '{type}{scope}: {emoji}{branchName}{subject}',
};
}
```

The only `branch.questions` required is `branchName`. So should probably make that rqeuired.
Expand Down
6 changes: 4 additions & 2 deletions bin/git-cz.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env node

// eslint-disable-next-line import/no-unassigned-import, filenames/match-regex
require('../dist/cli');
/* eslint-disable filenames/match-regex */
/* eslint-disable import/no-unassigned-import */

require('../dist/cli')
2 changes: 1 addition & 1 deletion data/gitmoji/init.json
Original file line number Diff line number Diff line change
Expand Up @@ -513,4 +513,4 @@
"semver": null
}
]
}
}
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('./dist/cz');
module.exports = require('./dist/cz')
6 changes: 6 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"compilerOptions": {
"baseUrl": ".",
"paths": {}
}
}
56 changes: 28 additions & 28 deletions lib/LimitedInputPrompt.js
Original file line number Diff line number Diff line change
@@ -1,76 +1,76 @@
const chalk = require('chalk');
const InputPrompt = require('inquirer/lib/prompts/input');
const chalk = require('chalk')
const InputPrompt = require('inquirer/lib/prompts/input')

class LimitedInputPrompt extends InputPrompt {
constructor(...args) {
super(...args);
super(...args)

if (!this.opt.maxLength) {
this.throwParamError('maxLength');
this.throwParamError('maxLength')
}
this.originalMessage = this.opt.message;
this.spacer = new Array(this.opt.maxLength).fill('-').join('');
this.originalMessage = this.opt.message
this.spacer = new Array(this.opt.maxLength).fill('-').join('')

if (this.opt.leadingLabel) {
if (typeof this.opt.leadingLabel === 'function') {
this.leadingLabel = ' ' + this.opt.leadingLabel(this.answers);
this.leadingLabel = ' ' + this.opt.leadingLabel(this.answers)
} else {
this.leadingLabel = ' ' + this.opt.leadingLabel;
this.leadingLabel = ' ' + this.opt.leadingLabel
}
} else {
this.leadingLabel = '';
this.leadingLabel = ''
}

this.leadingLength = this.leadingLabel.length;
this.leadingLength = this.leadingLabel.length
}

remainingChar() {
return this.opt.maxLength - this.leadingLength - this.rl.line.length;
return this.opt.maxLength - this.leadingLength - this.rl.line.length
}

onKeypress() {
if (this.rl.line.length > this.opt.maxLength - this.leadingLength) {
this.rl.line = this.rl.line.slice(0, this.opt.maxLength - this.leadingLength);
this.rl.cursor--;
this.rl.line = this.rl.line.slice(0, this.opt.maxLength - this.leadingLength)
this.rl.cursor--
}

this.render();
this.render()
}

getCharsLeftText() {
const chars = this.remainingChar();
const chars = this.remainingChar()

if (chars > 15) {
return chalk.green(`${chars} chars left`);
return chalk.green(`${chars} chars left`)
} else if (chars > 5) {
return chalk.yellow(`${chars} chars left`);
return chalk.yellow(`${chars} chars left`)
} else {
return chalk.red(`${chars} chars left`);
return chalk.red(`${chars} chars left`)
}
}

render(error) {
let bottomContent = '';
let message = this.getQuestion();
let appendContent = '';
const isFinal = this.status === 'answered';
let bottomContent = ''
let message = this.getQuestion()
let appendContent = ''
const isFinal = this.status === 'answered'

if (isFinal) {
appendContent = this.answer;
appendContent = this.answer
} else {
appendContent = this.rl.line;
appendContent = this.rl.line
}

message = `${message}\n\n[${this.spacer}] ${this.getCharsLeftText()}\n\n${
this.leadingLabel
} ${appendContent}`;
} ${appendContent}`

if (error) {
bottomContent = chalk.red('>> ') + error;
bottomContent = chalk.red('>> ') + error
}

this.screen.render(message, bottomContent);
this.screen.render(message, bottomContent)
}
}

module.exports = LimitedInputPrompt;
module.exports = LimitedInputPrompt
Loading

0 comments on commit f88e83a

Please sign in to comment.