-
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: lint file system for consistent names (#379)
This introduces ls-lint to check the file system for consistent naming of files and folders. Installed using: yarn d2-style add ls-lint Can be run individually: yarn d2-style check fs If it is configured (i.e. .ls-lint.yml exists), then it will run on: yarn d2-style check
- Loading branch information
Showing
12 changed files
with
131 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
ls: | ||
src: | ||
.dir: kebab-case | ||
.js: kebab-case | ||
.ts: kebab-case | ||
.css: kebab-case | ||
.d.ts: kebab-case | ||
|
||
ignore: | ||
- node_modules |
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,35 @@ | ||
const log = require('@dhis2/cli-helpers-engine').reporter | ||
const cfg = require('../../utils/config.js') | ||
|
||
exports.command = 'ls-lint [type]' | ||
|
||
exports.desc = 'Lint file and directory names.' | ||
|
||
exports.builder = yargs => | ||
yargs | ||
.positional('type', { | ||
describe: '', | ||
type: 'string', | ||
}) | ||
.option('overwrite', { | ||
describe: '', | ||
type: 'boolean', | ||
}) | ||
.example('$0', 'Adds the standard configuration to .ls-lint.yml') | ||
|
||
exports.handler = argv => { | ||
const { add, type, overwrite } = argv | ||
|
||
log.info(`ls-lint > ${add ? 'add' : 'remove'}`) | ||
|
||
if (add) { | ||
const template = type ? type : 'base' | ||
cfg.add({ | ||
tool: 'lslint', | ||
template, | ||
overwrite, | ||
}) | ||
} else { | ||
cfg.remove({ tool: 'lslint', type }) | ||
} | ||
} |
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,30 @@ | ||
const log = require('@dhis2/cli-helpers-engine').reporter | ||
const { lslint } = require('../../tools/ls-lint.js') | ||
const { callback: runCb, exit } = require('../../utils/run.js') | ||
|
||
exports.command = 'fs' | ||
exports.aliases = ['file-system'] | ||
exports.desc = 'Lint file and directory names.' | ||
|
||
exports.builder = yargs => yargs | ||
|
||
exports.handler = (argv, callback) => { | ||
const finalStatus = callback || runCb() | ||
|
||
log.info('file-system > ls-lint') | ||
lslint({ | ||
callback: finalStatus, | ||
}) | ||
|
||
if (finalStatus() === 0) { | ||
log.print('All matched files pass the lint rules.') | ||
log.print('') | ||
} | ||
|
||
if (!callback) { | ||
log.debug('Linted files in project.') | ||
exit(finalStatus()) | ||
} | ||
|
||
return finalStatus() | ||
} |
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,8 @@ | ||
const { bin } = require('../utils/run.js') | ||
|
||
exports.lslint = ({ callback }) => { | ||
const cmd = 'ls-lint' | ||
const args = [] | ||
|
||
bin(cmd, { args }, callback) | ||
} |
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,11 @@ | ||
ls: | ||
src/: | ||
.dir: kebab-case | ||
|
||
.js: kebab-case | ||
.ts: kebab-case | ||
.css: kebab-case | ||
.d.ts: kebab-case | ||
|
||
ignore: | ||
- node_modules |
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