Skip to content

Commit

Permalink
feat: introduce custom configurations and lint-staged for stashing un…
Browse files Browse the repository at this point in the history
…staged changes (#72)

BREAKING CHANGE: Changes multiple defaults for `d2-style`, removes the `install` command, adds extendable configs, only executes style checks on staged files by default, and more.

 - `d2-style js apply` no longer stages files by default, use `--stage` to stage fixed files. The intended usage for this function is primarily to apply the js code standards to files in general, e.g. unstaged/staged files or an entire repo.

- `d2-style validate` has changed to by default run `--fix`, and uses lint-staged to only apply code standards to staged files and/or hunks.

- `d2-style validate --all` no longer exists, validate only operates on staged files and is intended to be used as a pre-commit check. Use `d2-style js check` or apply with `--all` instead.

- `d2-style validate` output has changed. It no longer gives detailed information during a run. It only prints errors when it fails.

- `d2-style js install` has been removed, and the clean-up functions have also been removed.

- `d2-style setup` no longer installs `all` by default, instead prints available groups when command is run.

- It is now possible to stage hunks (`git add -p`) and only style check those hunks.

- It is now possible to extend configuration for lint-staged, eslint, etc.

- Husky hooks included out of the box with `d2-style setup git/husky`
  • Loading branch information
Mohammer5 authored and varl committed Jul 14, 2019
1 parent 3efdd1d commit 9f467ab
Show file tree
Hide file tree
Showing 28 changed files with 1,540 additions and 490 deletions.
3 changes: 0 additions & 3 deletions .commitlintrc.js

This file was deleted.

38 changes: 1 addition & 37 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,3 @@
const SEVERITY = 2

module.exports = {
root: true,

parser: 'babel-eslint',

env: {
browser: true,
node: true,
jest: true,
},

parserOptions: {
// latest standard is ok, eq. to 9
ecmaVersion: 2018,
ecmaFeatures: {
jsx: true,
modules: true,
},
},

rules: {
'max-params': [
SEVERITY,
{
max: 3,
},
],
'prefer-const': [
SEVERITY,
{
destructuring: 'any',
ignoreReadBeforeAssign: false,
},
],
'no-mixed-spaces-and-tabs': [SEVERITY],
},
extends: ['./config/js/eslint.config.js'],
}
7 changes: 7 additions & 0 deletions .huskyrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
hooks: {
'commit-msg': './bin/d2-style commit check',
'pre-commit':
'./bin/d2-style validate --lint-staged-config .lint-stagedrc.js',
},
}
11 changes: 11 additions & 0 deletions .lint-stagedrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const fix = process.env.CLI_STYLE_FIX === 'true'
const stage = process.env.CLI_STYLE_STAGE === 'true'

module.exports = {
'*.{js,jsx,ts,tsx}': [
'yarn test',
`./bin/d2-style js ${fix ? 'apply' : 'check'} ${
fix && stage ? '--stage' : ''
}`,
],
}
19 changes: 1 addition & 18 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,18 +1 @@
module.exports = {
printWidth: 80,
tabWidth: 4,
useTabs: false,
semi: false,
singleQuote: true,
trailingComma: 'es5',
bracketSpacing: true,
jsxBracketSameLine: false,
jsxSingleQuote: false,
arrowParens: 'avoid',
rangeStart: 0,
rangeEnd: Infinity,
proseWrap: 'preserve',
requirePragma: false,
insertPragma: false,
endOfLine: 'lf',
}
module.exports = require('./config/js/prettier.config.js')
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ language: node_js
node_js:
- lts/*
script:
- "./bin/d2-style validate --all"
- "./bin/d2-style js check --all"
- yarn test
deploy:
- provider: script
skip_cleanup: true
Expand Down
Loading

0 comments on commit 9f467ab

Please sign in to comment.