Skip to content

Commit

Permalink
chore: add recommended option for rule generation
Browse files Browse the repository at this point in the history
  • Loading branch information
brettz9 committed May 21, 2021
1 parent aa69581 commit f3faaf2
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/bin/generateRule.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
/* eslint-disable no-console -- CLI */

/**
* @example
*
* ```shell
* npm run create-rule my-new-rule --recommended
* ```
*/

import {
existsSync,
} from 'fs';
Expand All @@ -11,7 +20,9 @@ import open from 'open-editor';

// Todo: Would ideally have prompts, e.g., to ask for whether type was problem/layout, etc.

const [, , ruleName] = process.argv;
const [, , ruleName, ...options] = process.argv;

const recommended = options.includes('--recommended');

(async () => {
if (!ruleName) {
Expand Down Expand Up @@ -104,7 +115,7 @@ export default iterateJsdoc(({
|---|---|
|Context|everywhere|
|Tags|\`\`|
|Recommended|false|
|Recommended|${recommended ? 'true' : 'false'}|
|Settings||
|Options||
Expand Down Expand Up @@ -184,7 +195,7 @@ export default iterateJsdoc(({

await replaceInOrder({
checkName: 'index recommended',
newLine: `${' '.repeat(8)}'jsdoc/${ruleName}': 'off',`,
newLine: `${' '.repeat(8)}'jsdoc/${ruleName}': '${recommended ? 'warn' : 'off'}',`,
oldRegex: /\n\s{8}'jsdoc\/(?<oldRule>[^']*)': '[^']*',/gu,
path: './src/index.js',
});
Expand Down

0 comments on commit f3faaf2

Please sign in to comment.