-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: introduce custom configurations and lint-staged for stashing un…
…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
Showing
28 changed files
with
1,540 additions
and
490 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' : '' | ||
}`, | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.