-
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: add support for eslint for code style enforcement (#33)
* feat: add eslint * feat: add eslint to js standards * chore: add comments * chore: add comments * chore: add comments * refactor: simplify and electrify * test: foobar * test: remove test * docs: add jsdoc * fix: use sourcetype module * chore: remove sort imports * refactor: rename const to severity * refactor: here we go * refactor: run standardisation tools as a stream * chore: add babel-eslint as dep * refactor: change variable names for readability * refactor: export git commands * chore: add performance measurements for hotspots * chore: improve logging in verbose * chore: print amount of files for total time * chore: consistent logging * fix: abort early if there are no files to work on * refactor: rearrange structure * docs: update readme * docs: fix ugly formatting in readme * refactor: de-duplicate the code that runs js tools * fix: change command to runner * fix: remove confusing name from runner of commitlint * chore: only filter for violations once * fix: change output to debug level * chore: rename underscored functions to camelcase * chore: rename snake case to camel case * fix: add boolean to toggle between check and apply * fix: only write and stage modified files * fix: rename summary to summarize (verb vs. noun) * fix: track modified source * fix: reduce confusing logging * refactor: improve logging * fix: only do things when there are things to do * fix: remove unused prop * fix: make commit check consistent * docs: improve jsdocs * fix: ignore vendor folders for now * fix: make eslint a bit stricter for now * fix: do not use optional filename arg to execute on text
- Loading branch information
Showing
17 changed files
with
992 additions
and
227 deletions.
There are no files selected for viewing
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
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,39 @@ | ||
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], | ||
}, | ||
} |
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
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
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
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
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
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
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,41 @@ | ||
/** | ||
* This requires that there is a Git binary on $PATH | ||
*/ | ||
const { execSync } = require('child_process') | ||
|
||
const log = require('@dhis2/cli-helpers-engine').reporter | ||
|
||
const stageFile = (file, dir) => { | ||
log.debug(`Staging ${file}...`) | ||
const added = execSync(`git add ${file}`, { | ||
cwd: dir, | ||
encoding: 'utf8', | ||
}) | ||
return file | ||
} | ||
|
||
const stageFiles = (files, dir) => { | ||
const staged = files.map(f => stageFile(f, dir)) | ||
log.info(`Staged ${files.length} file(s).`) | ||
return staged | ||
} | ||
|
||
const stagedFiles = dir => { | ||
const files = execSync('git diff --cached --name-only --relative', { | ||
cwd: dir, | ||
encoding: 'utf8', | ||
}).trim() | ||
if (!!files) { | ||
const s = files.split('\n') | ||
log.info(`Fetching staged files: ${s.length} file(s).`) | ||
return s | ||
} | ||
log.info('No staged files found.') | ||
return [] | ||
} | ||
|
||
module.exports = { | ||
stagedFiles, | ||
stageFiles, | ||
stageFile, | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.