Skip to content

Commit

Permalink
ahem; lint :laugh:. and doc.
Browse files Browse the repository at this point in the history
  • Loading branch information
zburke committed Jun 21, 2024
1 parent dd6653f commit a0f23f5
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 3 deletions.
77 changes: 77 additions & 0 deletions doc/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ This following command documentation is generated from the CLI's own built-in he
* [`app perms` command](#app-perms-command)
* [`build` command](#build-command)
* [`inventory` command](#inventory-command)
* [`lint` command](#lint-command)
* [`mod` command](#mod-command)
* [`mod add` command](#mod-add-command)
* [`mod descriptor` command](#mod-descriptor-command)
Expand Down Expand Up @@ -51,6 +52,7 @@ This following command documentation is generated from the CLI's own built-in he
* [`status` command](#status-command)
* [`test` command](#test-command)
* [`test karma` command](#test-karma-command)
* [`translate` command](#translate-command)
* [`workspace` command](#workspace-command)
* [`completion` command](#completion-command)

Expand Down Expand Up @@ -1292,3 +1294,78 @@ Usage:
```
$ stripes completion
```

## `translate` command

Translation utilities

Usage:
```
$ stripes translate [compile | pcheck | stats]
```

Sub-commands:
* [`stripes translate compile`](#translate-compile-command)
* [`stripes translate pcheck`](#translate-pcheck-command)
* [`stripes translate stats`](#translate-stats-command)

### `translate compile` command

Compile translations to AST. This is done automatically by CI workflows when merging any PR or publishing a release. Compiled translations must not be committed to source control.

Usage:
```
$ stripes translate compile
```

### `translate pcheck` command

Look for permissions defined in `package.json` that lack corresponding translation keys in `en.json`. Exits non-zero if any are missing.

Usage:
```
$ stripes translate pcheck
```
Output:
```
Could not find a translation for permission.call-number-browse.view.
Could not find a translation for permission.subjects.view.
```

### `translate stats` command

Compile completion statistics for each locale.

Usage:
```
$ stripes translate stats
```
Output:
```
ar 83% 720/864
ber 0% 0/864
ca 0% 2/864
cs_CZ 98% 855/864
da 15% 132/864
de 95% 827/864
en_GB 0% 0/864
en_SE 0% 0/864
es 59% 511/864
```

## `lint` command

Run lint on `./lib` and/or `./src` directories. Includes `.eslintrc`. Exits 0 on warnings, 1 on errors.

Usage:
```
$ stripes lint
```
Output:
```
/Users/zburke/projects/folio-org/stripes-cli/lib/commands/lint.js
17:24 error Arrow function used ambiguously with a conditional expression. no-confusing-arrow
✖ 1 problem (1 error, 0 warnings)
1 error and 0 warnings potentially fixable with the `--fix` option.
```
6 changes: 3 additions & 3 deletions lib/commands/lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ function createESLintInstance(overrideConfig) {

const lineFormat = (line, column) => chalk.green(`${_.padStart(line, 4)}:${_.padEnd(column, 3)}`);
const messageFormat = (message, maxLen) => _.padEnd(message, maxLen);
const severityFormat = (severity) => severity === 1 ? chalk.green(_.padEnd('warning', 10)) : chalk.red(_.padEnd('error', 10));
const severityFormat = (severity) => (severity === 1 ? chalk.green(_.padEnd('warning', 10)) : chalk.red(_.padEnd('error', 10)));
const messagesFormat = (list) => {
const maxLen = Math.max(...list.map(m => m.message.length)) + 2;
return list.map(m => `${lineFormat(m.line, m.column)}${severityFormat(m.severity)}${messageFormat(m.message, maxLen)}${m.ruleId}`).join('\n');
return list.map(m => `${lineFormat(m.line, m.column)}${severityFormat(m.severity)}${messageFormat(m.message, maxLen)}${chalk.green(m.ruleId)}`).join('\n');
};

const resultFormatter = (message) => (
Expand Down Expand Up @@ -61,7 +61,7 @@ const lintCommand = async () => {
const dingCount = errors + warnings;
const theme = errors ? chalk.bold.red : chalk.bold.green;
if (errors || warnings) {
console.warn(theme(`✖ ${dingCount} problem${dingCount === 1 ? '' : 's'} (${errors} errors, ${warnings} warnings)`));
console.warn(theme(`✖ ${dingCount} problem${dingCount === 1 ? '' : 's'} (${errors} error${errors === 1 ? '' : 's'}, ${warnings} warning${warnings === 1 ? '' : 's'})`));
}
if (ferrors || fwarnings) {
console.warn(theme(` ${ferrors} error${ferrors === 1 ? '' : 's'} and ${fwarnings} warning${fwarnings === 1 ? '' : 's'} potentially fixable with the \`--fix\` option.`));
Expand Down

0 comments on commit a0f23f5

Please sign in to comment.