eslint-doc-generator
Advanced tools
Comparing version 0.25.0 to 0.26.0
import { Command } from 'commander'; | ||
import { GenerateOptions } from './options.js'; | ||
import { GenerateOptions } from './types.js'; | ||
/** | ||
@@ -4,0 +4,0 @@ * Run the CLI and gather options. |
import { Command, Argument, Option } from 'commander'; | ||
import { readFileSync } from 'node:fs'; | ||
import { RULE_DOC_TITLE_FORMATS } from './rule-doc-title-format.js'; | ||
import { OPTION_DEFAULTS, OPTION_TYPE } from './options.js'; | ||
import { OPTION_DEFAULTS } from './options.js'; | ||
import { cosmiconfig } from 'cosmiconfig'; | ||
import Ajv from 'ajv'; | ||
import merge from 'deepmerge'; | ||
import { COLUMN_TYPE, NOTICE_TYPE } from './types.js'; | ||
function getCurrentPackageVersion() { | ||
// When running as compiled code, use path relative to compiled version of this file in the dist folder. | ||
// When running as TypeScript (in a test), use path relative to this file. | ||
const pathToPackageJson = import.meta.url.endsWith('.ts') | ||
? '../package.json' | ||
: /* istanbul ignore next -- can't test the compiled version in test */ | ||
'../../package.json'; | ||
const packageJson = JSON.parse(readFileSync(new URL(pathToPackageJson, import.meta.url), 'utf8')); | ||
if (!packageJson.version) { | ||
throw new Error('Could not find package.json `version`.'); | ||
} | ||
return packageJson.version; | ||
} | ||
import { COLUMN_TYPE, NOTICE_TYPE, OPTION_TYPE, } from './types.js'; | ||
import { getCurrentPackageVersion } from './package-json.js'; | ||
/** Used for collecting repeated CLI options into an array. */ | ||
@@ -54,3 +41,3 @@ function collect(value, previous) { | ||
pathRuleDoc: { type: 'string' }, | ||
pathRuleList: { type: 'string' }, | ||
pathRuleList: { anyOf: [{ type: 'string' }, schemaStringArray] }, | ||
ruleDocNotices: { type: 'string' }, | ||
@@ -101,3 +88,3 @@ ruleDocSectionExclude: schemaStringArray, | ||
.option('--path-rule-doc <path>', `(optional) Path to markdown file for each rule doc. Use \`{name}\` placeholder for the rule name. (default: ${OPTION_DEFAULTS[OPTION_TYPE.PATH_RULE_DOC]})`) | ||
.option('--path-rule-list <path>', `(optional) Path to markdown file with a rules section where the rules table list should live. (default: ${OPTION_DEFAULTS[OPTION_TYPE.PATH_RULE_LIST]})`) | ||
.option('--path-rule-list <path>', `(optional) Path to markdown file where the rules table list should live. Option can be repeated. Defaults to ${OPTION_DEFAULTS[OPTION_TYPE.PATH_RULE_LIST]} if not provided.`, collect, []) | ||
.option('--rule-doc-notices <notices>', `(optional) Ordered, comma-separated list of notices to display in rule doc. Non-applicable notices will be hidden. (choices: "${Object.values(NOTICE_TYPE).join('", "')}") (default: ${OPTION_DEFAULTS[OPTION_TYPE.RULE_DOC_NOTICES]})`) | ||
@@ -118,2 +105,6 @@ .option('--rule-doc-section-exclude <section>', '(optional) Disallowed section in each rule doc (option can be repeated).', collect, []) | ||
const configFileOptions = await loadConfigFileOptions(); | ||
// Perform any normalization needed ahead of merging. | ||
if (typeof configFileOptions.pathRuleList === 'string') { | ||
configFileOptions.pathRuleList = [configFileOptions.pathRuleList]; | ||
} | ||
const generateOptions = merge(configFileOptions, options); // Recursive merge. | ||
@@ -120,0 +111,0 @@ // Invoke callback. |
@@ -1,2 +0,2 @@ | ||
import { GenerateOptions } from './options.js'; | ||
import type { GenerateOptions } from './types.js'; | ||
export declare function generate(path: string, options?: GenerateOptions): Promise<void>; |
@@ -6,9 +6,10 @@ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'; | ||
import { updateRulesList } from './rule-list.js'; | ||
import { generateRuleHeaderLines } from './rule-notices.js'; | ||
import { generateRuleHeaderLines } from './rule-doc-notices.js'; | ||
import { parseRuleDocNoticesOption, parseRuleListColumnsOption, parseConfigEmojiOptions, } from './option-parsers.js'; | ||
import { END_RULE_HEADER_MARKER } from './markers.js'; | ||
import { END_RULE_HEADER_MARKER } from './comment-markers.js'; | ||
import { findSectionHeader, replaceOrCreateHeader } from './markdown.js'; | ||
import { resolveConfigsToRules } from './config-resolution.js'; | ||
import { OPTION_DEFAULTS, OPTION_TYPE } from './options.js'; | ||
import { resolveConfigsToRules } from './plugin-config-resolution.js'; | ||
import { OPTION_DEFAULTS } from './options.js'; | ||
import { diff } from 'jest-diff'; | ||
import { OPTION_TYPE } from './types.js'; | ||
/** | ||
@@ -109,4 +110,4 @@ * Ensure a rule doc contains (or doesn't contain) some particular content. | ||
(details) => !ignoreDeprecatedRules || !details.deprecated); | ||
// Update rule doc for each rule. | ||
let initializedRuleDoc = false; | ||
// Update rule doc for each rule. | ||
for (const { name, description, schema } of details) { | ||
@@ -153,23 +154,27 @@ const pathToDoc = join(path, pathRuleDoc).replace(/{name}/g, name); | ||
} | ||
// Find the README. | ||
const pathToReadme = getPathWithExactFileNameCasing(join(path, pathRuleList)); | ||
if (!pathToReadme || !existsSync(pathToReadme)) { | ||
throw new Error(`Could not find ${pathRuleList} in ESLint plugin.`); | ||
if (initRuleDocs && !initializedRuleDoc) { | ||
throw new Error('--init-rule-docs was enabled, but no rule doc file needed to be created.'); | ||
} | ||
// Update the rules list in the README. | ||
const readmeContents = readFileSync(pathToReadme, 'utf8'); | ||
const readmeContentsNew = updateRulesList(details, readmeContents, plugin, configsToRules, pluginPrefix, pathRuleDoc, pathToReadme, path, configEmojis, ignoreConfig, ruleListColumns, urlConfigs, urlRuleDoc, splitBy); | ||
if (check) { | ||
if (readmeContentsNew !== readmeContents) { | ||
console.error(`Please run eslint-doc-generator. ${relative(getPluginRoot(path), pathToReadme)} is out-of-date.`); | ||
console.error(diff(readmeContentsNew, readmeContents, { expand: false })); | ||
process.exitCode = 1; | ||
for (const pathRuleListItem of Array.isArray(pathRuleList) | ||
? pathRuleList | ||
: [pathRuleList]) { | ||
// Find the exact filename. | ||
const pathToFile = getPathWithExactFileNameCasing(join(path, pathRuleListItem)); | ||
if (!pathToFile || !existsSync(pathToFile)) { | ||
throw new Error(`Could not find ${pathRuleList} in ESLint plugin.`); | ||
} | ||
// Update the rules list in this file. | ||
const fileContents = readFileSync(pathToFile, 'utf8'); | ||
const fileContentsNew = updateRulesList(details, fileContents, plugin, configsToRules, pluginPrefix, pathRuleDoc, pathToFile, path, configEmojis, ignoreConfig, ruleListColumns, urlConfigs, urlRuleDoc, splitBy); | ||
if (check) { | ||
if (fileContentsNew !== fileContents) { | ||
console.error(`Please run eslint-doc-generator. The rules table in ${relative(getPluginRoot(path), pathToFile)} is out-of-date.`); | ||
console.error(diff(fileContentsNew, fileContents, { expand: false })); | ||
process.exitCode = 1; | ||
} | ||
} | ||
else { | ||
writeFileSync(pathToFile, fileContentsNew, 'utf8'); | ||
} | ||
} | ||
else { | ||
writeFileSync(pathToReadme, readmeContentsNew, 'utf8'); | ||
} | ||
if (initRuleDocs && !initializedRuleDoc) { | ||
throw new Error('--init-rule-docs was enabled, but no rule doc file needed to be created.'); | ||
} | ||
} |
@@ -13,1 +13,2 @@ /** | ||
export declare function findSectionHeader(markdown: string, str: string): string | undefined; | ||
export declare function findFinalHeaderLevel(str: string): number | undefined; |
@@ -11,8 +11,15 @@ // General helpers for dealing with markdown files / content. | ||
const lines = markdown.split('\n'); | ||
const titleLineIndex = lines.findIndex((line) => line.startsWith('# ')); | ||
const markerLineIndex = lines.indexOf(marker); | ||
if (markerLineIndex === -1 && lines.length > 0 && lines[0].startsWith('# ')) { | ||
// No marker present so delete any existing title before we add the new one. | ||
lines.splice(0, 1); | ||
} | ||
return `${newHeader}\n${lines.slice(markerLineIndex + 1).join('\n')}`; | ||
const dashesLineIndex1 = lines.indexOf('---'); | ||
const dashesLineIndex2 = lines.indexOf('---', dashesLineIndex1 + 1); | ||
// Any YAML front matter or anything else above the title should be kept as-is ahead of the new header. | ||
const preHeader = lines | ||
.slice(0, Math.max(titleLineIndex, dashesLineIndex2 + 1)) | ||
.join('\n'); | ||
// Anything after the marker comment, title, or YAML front matter should be kept as-is after the new header. | ||
const postHeader = lines | ||
.slice(Math.max(markerLineIndex + 1, titleLineIndex + 1, dashesLineIndex2 + 1)) | ||
.join('\n'); | ||
return `${preHeader ? `${preHeader}\n` : ''}${newHeader}\n${postHeader}`; | ||
} | ||
@@ -37,1 +44,6 @@ /** | ||
} | ||
export function findFinalHeaderLevel(str) { | ||
const lines = str.split('\n'); | ||
const finalHeader = lines.reverse().find((line) => line.match('^(#+) .+$')); | ||
return finalHeader ? finalHeader.indexOf(' ') : undefined; | ||
} |
@@ -1,2 +0,1 @@ | ||
import { RuleDocTitleFormat } from './rule-doc-title-format.js'; | ||
import { COLUMN_TYPE, NOTICE_TYPE } from './types.js'; | ||
@@ -9,20 +8,2 @@ export declare const COLUMN_TYPE_DEFAULT_PRESENCE_AND_ORDERING: { | ||
}; | ||
export declare enum OPTION_TYPE { | ||
CHECK = "check", | ||
CONFIG_EMOJI = "configEmoji", | ||
IGNORE_CONFIG = "ignoreConfig", | ||
IGNORE_DEPRECATED_RULES = "ignoreDeprecatedRules", | ||
INIT_RULE_DOCS = "initRuleDocs", | ||
PATH_RULE_DOC = "pathRuleDoc", | ||
PATH_RULE_LIST = "pathRuleList", | ||
RULE_DOC_NOTICES = "ruleDocNotices", | ||
RULE_DOC_SECTION_EXCLUDE = "ruleDocSectionExclude", | ||
RULE_DOC_SECTION_INCLUDE = "ruleDocSectionInclude", | ||
RULE_DOC_SECTION_OPTIONS = "ruleDocSectionOptions", | ||
RULE_DOC_TITLE_FORMAT = "ruleDocTitleFormat", | ||
RULE_LIST_COLUMNS = "ruleListColumns", | ||
SPLIT_BY = "splitBy", | ||
URL_CONFIGS = "urlConfigs", | ||
URL_RULE_DOC = "urlRuleDoc" | ||
} | ||
export declare const OPTION_DEFAULTS: { | ||
@@ -46,19 +27,1 @@ check: boolean; | ||
}; | ||
export type GenerateOptions = { | ||
check?: boolean; | ||
configEmoji?: string[]; | ||
ignoreConfig?: string[]; | ||
ignoreDeprecatedRules?: boolean; | ||
initRuleDocs?: boolean; | ||
pathRuleDoc?: string; | ||
pathRuleList?: string; | ||
ruleDocNotices?: string; | ||
ruleDocSectionExclude?: string[]; | ||
ruleDocSectionInclude?: string[]; | ||
ruleDocSectionOptions?: boolean; | ||
ruleDocTitleFormat?: RuleDocTitleFormat; | ||
ruleListColumns?: string; | ||
splitBy?: string; | ||
urlConfigs?: string; | ||
urlRuleDoc?: string; | ||
}; |
@@ -1,2 +0,2 @@ | ||
import { COLUMN_TYPE, NOTICE_TYPE } from './types.js'; | ||
import { COLUMN_TYPE, NOTICE_TYPE, OPTION_TYPE } from './types.js'; | ||
export const COLUMN_TYPE_DEFAULT_PRESENCE_AND_ORDERING = { | ||
@@ -30,21 +30,2 @@ // Object keys ordered in display order. | ||
}; | ||
export var OPTION_TYPE; | ||
(function (OPTION_TYPE) { | ||
OPTION_TYPE["CHECK"] = "check"; | ||
OPTION_TYPE["CONFIG_EMOJI"] = "configEmoji"; | ||
OPTION_TYPE["IGNORE_CONFIG"] = "ignoreConfig"; | ||
OPTION_TYPE["IGNORE_DEPRECATED_RULES"] = "ignoreDeprecatedRules"; | ||
OPTION_TYPE["INIT_RULE_DOCS"] = "initRuleDocs"; | ||
OPTION_TYPE["PATH_RULE_DOC"] = "pathRuleDoc"; | ||
OPTION_TYPE["PATH_RULE_LIST"] = "pathRuleList"; | ||
OPTION_TYPE["RULE_DOC_NOTICES"] = "ruleDocNotices"; | ||
OPTION_TYPE["RULE_DOC_SECTION_EXCLUDE"] = "ruleDocSectionExclude"; | ||
OPTION_TYPE["RULE_DOC_SECTION_INCLUDE"] = "ruleDocSectionInclude"; | ||
OPTION_TYPE["RULE_DOC_SECTION_OPTIONS"] = "ruleDocSectionOptions"; | ||
OPTION_TYPE["RULE_DOC_TITLE_FORMAT"] = "ruleDocTitleFormat"; | ||
OPTION_TYPE["RULE_LIST_COLUMNS"] = "ruleListColumns"; | ||
OPTION_TYPE["SPLIT_BY"] = "splitBy"; | ||
OPTION_TYPE["URL_CONFIGS"] = "urlConfigs"; | ||
OPTION_TYPE["URL_RULE_DOC"] = "urlRuleDoc"; | ||
})(OPTION_TYPE || (OPTION_TYPE = {})); | ||
const DEFAULT_RULE_DOC_TITLE_FORMAT = 'desc-parens-prefix-name'; // Using this variable ensures this default has the correct type (not just a plain string). | ||
@@ -51,0 +32,0 @@ export const OPTION_DEFAULTS = { |
@@ -9,1 +9,2 @@ import type { Plugin } from './types.js'; | ||
export declare function getPathWithExactFileNameCasing(path: string): string | undefined; | ||
export declare function getCurrentPackageVersion(): string; |
@@ -88,1 +88,14 @@ import { join, resolve, basename, dirname, isAbsolute } from 'node:path'; | ||
} | ||
export function getCurrentPackageVersion() { | ||
// When running as compiled code, use path relative to compiled version of this file in the dist folder. | ||
// When running as TypeScript (in a test), use path relative to this file. | ||
const pathToPackageJson = import.meta.url.endsWith('.ts') | ||
? '../package.json' | ||
: /* istanbul ignore next -- can't test the compiled version in test */ | ||
'../../package.json'; | ||
const packageJson = JSON.parse(readFileSync(new URL(pathToPackageJson, import.meta.url), 'utf8')); | ||
if (!packageJson.version) { | ||
throw new Error('Could not find package.json `version`.'); | ||
} | ||
return packageJson.version; | ||
} |
import { EMOJI_DEPRECATED, EMOJI_FIXABLE, EMOJI_HAS_SUGGESTIONS, EMOJI_REQUIRES_TYPE_CHECKING, EMOJI_TYPE, EMOJI_CONFIG_FROM_SEVERITY, EMOJI_OPTIONS, } from './emojis.js'; | ||
import { RULE_TYPES } from './rule-type.js'; | ||
import { COLUMN_TYPE, SEVERITY_TYPE } from './types.js'; | ||
import { getConfigsThatSetARule } from './configs.js'; | ||
import { getConfigsThatSetARule } from './plugin-configs.js'; | ||
import { hasOptions } from './rule-options.js'; | ||
@@ -6,0 +6,0 @@ /** |
import { COLUMN_TYPE } from './types.js'; | ||
import type { Plugin, RuleDetails, ConfigsToRules, ConfigEmojis } from './types.js'; | ||
export declare function updateRulesList(details: RuleDetails[], markdown: string, plugin: Plugin, configsToRules: ConfigsToRules, pluginPrefix: string, pathRuleDoc: string, pathToReadme: string, pathToPlugin: string, configEmojis: ConfigEmojis, ignoreConfig: string[], ruleListColumns: COLUMN_TYPE[], urlConfigs?: string, urlRuleDoc?: string, splitBy?: string): string; | ||
export declare function updateRulesList(details: RuleDetails[], markdown: string, plugin: Plugin, configsToRules: ConfigsToRules, pluginPrefix: string, pathRuleDoc: string, pathRuleList: string, pathToPlugin: string, configEmojis: ConfigEmojis, ignoreConfig: string[], ruleListColumns: COLUMN_TYPE[], urlConfigs?: string, urlRuleDoc?: string, splitBy?: string): string; |
@@ -1,8 +0,8 @@ | ||
import { BEGIN_RULE_LIST_MARKER, END_RULE_LIST_MARKER } from './markers.js'; | ||
import { BEGIN_RULE_LIST_MARKER, END_RULE_LIST_MARKER, } from './comment-markers.js'; | ||
import { EMOJI_DEPRECATED, EMOJI_FIXABLE, EMOJI_HAS_SUGGESTIONS, EMOJI_OPTIONS, EMOJI_REQUIRES_TYPE_CHECKING, } from './emojis.js'; | ||
import { getConfigsForRule, findConfigEmoji } from './configs.js'; | ||
import { getEmojisForConfigsSettingRuleToSeverity } from './plugin-configs.js'; | ||
import { getColumns, COLUMN_HEADER } from './rule-list-columns.js'; | ||
import { findSectionHeader } from './markdown.js'; | ||
import { findSectionHeader, findFinalHeaderLevel } from './markdown.js'; | ||
import { getPluginRoot } from './package-json.js'; | ||
import { generateLegend } from './legend.js'; | ||
import { generateLegend } from './rule-list-legend.js'; | ||
import { relative } from 'node:path'; | ||
@@ -40,21 +40,2 @@ import { COLUMN_TYPE, SEVERITY_TYPE } from './types.js'; | ||
} | ||
/** | ||
* Get the emojis for the configs that set a rule to a certain severity. | ||
*/ | ||
function getEmojisForConfigsSettingRuleToSeverity(ruleName, configsToRulesWithoutIgnored, pluginPrefix, configEmojis, severityType) { | ||
const configsOfThisSeverity = getConfigsForRule(ruleName, configsToRulesWithoutIgnored, pluginPrefix, severityType); | ||
const emojis = []; | ||
for (const configName of configsOfThisSeverity) { | ||
// Find the emoji for each config or otherwise use a badge that can be defined in markdown. | ||
const emoji = findConfigEmoji(configEmojis, configName, { | ||
fallback: 'badge', | ||
}); | ||
/* istanbul ignore next -- this shouldn't happen */ | ||
if (typeof emoji !== 'string') { | ||
throw new TypeError('Emoji will always be a string thanks to fallback'); | ||
} | ||
emojis.push(emoji); | ||
} | ||
return emojis; | ||
} | ||
function getConfigurationColumnValueForRule(rule, configsToRules, pluginPrefix, configEmojis, ignoreConfig, severityType) { | ||
@@ -113,3 +94,3 @@ const configsToRulesWithoutIgnored = Object.fromEntries(Object.entries(configsToRules).filter(([configName]) => !ignoreConfig?.includes(configName))); | ||
*/ | ||
function generateRulesListMarkdownWithSplitBy(columns, details, plugin, configsToRules, pluginPrefix, pathRuleDoc, configEmojis, ignoreConfig, splitBy, urlRuleDoc) { | ||
function generateRulesListMarkdownWithSplitBy(columns, details, plugin, configsToRules, pluginPrefix, pathRuleDoc, configEmojis, ignoreConfig, splitBy, headerLevel, urlRuleDoc) { | ||
const values = new Set(details.map((detail) => getPropertyFromRule(plugin, detail.name, splitBy))); | ||
@@ -149,7 +130,7 @@ // Common values for boolean properties. | ||
: splitByFinalPart; | ||
parts.push(`### ${ENABLED_VALUES.has(value) ? splitByTitle : value}`, generateRulesListMarkdown(columns, rulesForThisValue, configsToRules, pluginPrefix, pathRuleDoc, configEmojis, ignoreConfig, urlRuleDoc)); | ||
parts.push(`${'#'.repeat(headerLevel)} ${ENABLED_VALUES.has(value) ? splitByTitle : value}`, generateRulesListMarkdown(columns, rulesForThisValue, configsToRules, pluginPrefix, pathRuleDoc, configEmojis, ignoreConfig, urlRuleDoc)); | ||
} | ||
return parts.join('\n\n'); | ||
} | ||
export function updateRulesList(details, markdown, plugin, configsToRules, pluginPrefix, pathRuleDoc, pathToReadme, pathToPlugin, configEmojis, ignoreConfig, ruleListColumns, urlConfigs, urlRuleDoc, splitBy) { | ||
export function updateRulesList(details, markdown, plugin, configsToRules, pluginPrefix, pathRuleDoc, pathRuleList, pathToPlugin, configEmojis, ignoreConfig, ruleListColumns, urlConfigs, urlRuleDoc, splitBy) { | ||
let listStartIndex = markdown.indexOf(BEGIN_RULE_LIST_MARKER); | ||
@@ -175,6 +156,11 @@ let listEndIndex = markdown.indexOf(END_RULE_LIST_MARKER); | ||
if (listStartIndex === -1 || listEndIndex === -1) { | ||
throw new Error(`${relative(getPluginRoot(pathToPlugin), pathToReadme)} is missing rules list markers: ${BEGIN_RULE_LIST_MARKER}${END_RULE_LIST_MARKER}`); | ||
throw new Error(`${relative(getPluginRoot(pathToPlugin), pathRuleList)} is missing rules list markers: ${BEGIN_RULE_LIST_MARKER}${END_RULE_LIST_MARKER}`); | ||
} | ||
const preList = markdown.slice(0, Math.max(0, listStartIndex)); | ||
const postList = markdown.slice(Math.max(0, listEndIndex)); | ||
// Determine what header level to use for sub-lists based on the last seen header level. | ||
const preListFinalHeaderLevel = findFinalHeaderLevel(preList); | ||
const splitByHeaderLevel = preListFinalHeaderLevel | ||
? preListFinalHeaderLevel + 1 | ||
: 1; | ||
// Determine columns to include in the rules list. | ||
@@ -186,3 +172,3 @@ const columns = getColumns(plugin, details, configsToRules, ruleListColumns, pluginPrefix, ignoreConfig); | ||
const list = splitBy | ||
? generateRulesListMarkdownWithSplitBy(columns, details, plugin, configsToRules, pluginPrefix, pathRuleDoc, configEmojis, ignoreConfig, splitBy, urlRuleDoc) | ||
? generateRulesListMarkdownWithSplitBy(columns, details, plugin, configsToRules, pluginPrefix, pathRuleDoc, configEmojis, ignoreConfig, splitBy, splitByHeaderLevel, urlRuleDoc) | ||
: generateRulesListMarkdown(columns, details, configsToRules, pluginPrefix, pathRuleDoc, configEmojis, ignoreConfig, urlRuleDoc); | ||
@@ -189,0 +175,0 @@ const newContent = `${legend ? `${legend}\n\n` : ''}${list}`; |
@@ -0,1 +1,2 @@ | ||
import type { RuleDocTitleFormat } from './rule-doc-title-format.js'; | ||
import type { TSESLint, JSONSchema } from '@typescript-eslint/utils'; | ||
@@ -66,1 +67,38 @@ export type RuleModule = TSESLint.RuleModule<string, unknown[]>; | ||
} | ||
export declare enum OPTION_TYPE { | ||
CHECK = "check", | ||
CONFIG_EMOJI = "configEmoji", | ||
IGNORE_CONFIG = "ignoreConfig", | ||
IGNORE_DEPRECATED_RULES = "ignoreDeprecatedRules", | ||
INIT_RULE_DOCS = "initRuleDocs", | ||
PATH_RULE_DOC = "pathRuleDoc", | ||
PATH_RULE_LIST = "pathRuleList", | ||
RULE_DOC_NOTICES = "ruleDocNotices", | ||
RULE_DOC_SECTION_EXCLUDE = "ruleDocSectionExclude", | ||
RULE_DOC_SECTION_INCLUDE = "ruleDocSectionInclude", | ||
RULE_DOC_SECTION_OPTIONS = "ruleDocSectionOptions", | ||
RULE_DOC_TITLE_FORMAT = "ruleDocTitleFormat", | ||
RULE_LIST_COLUMNS = "ruleListColumns", | ||
SPLIT_BY = "splitBy", | ||
URL_CONFIGS = "urlConfigs", | ||
URL_RULE_DOC = "urlRuleDoc" | ||
} | ||
/** The type for the config file and internal generate() function. */ | ||
export type GenerateOptions = { | ||
check?: boolean; | ||
configEmoji?: string[]; | ||
ignoreConfig?: string[]; | ||
ignoreDeprecatedRules?: boolean; | ||
initRuleDocs?: boolean; | ||
pathRuleDoc?: string; | ||
pathRuleList?: string | string[]; | ||
ruleDocNotices?: string; | ||
ruleDocSectionExclude?: string[]; | ||
ruleDocSectionInclude?: string[]; | ||
ruleDocSectionOptions?: boolean; | ||
ruleDocTitleFormat?: RuleDocTitleFormat; | ||
ruleListColumns?: string; | ||
splitBy?: string; | ||
urlConfigs?: string; | ||
urlRuleDoc?: string; | ||
}; |
@@ -48,1 +48,20 @@ // Custom types. | ||
})(COLUMN_TYPE || (COLUMN_TYPE = {})); | ||
export var OPTION_TYPE; | ||
(function (OPTION_TYPE) { | ||
OPTION_TYPE["CHECK"] = "check"; | ||
OPTION_TYPE["CONFIG_EMOJI"] = "configEmoji"; | ||
OPTION_TYPE["IGNORE_CONFIG"] = "ignoreConfig"; | ||
OPTION_TYPE["IGNORE_DEPRECATED_RULES"] = "ignoreDeprecatedRules"; | ||
OPTION_TYPE["INIT_RULE_DOCS"] = "initRuleDocs"; | ||
OPTION_TYPE["PATH_RULE_DOC"] = "pathRuleDoc"; | ||
OPTION_TYPE["PATH_RULE_LIST"] = "pathRuleList"; | ||
OPTION_TYPE["RULE_DOC_NOTICES"] = "ruleDocNotices"; | ||
OPTION_TYPE["RULE_DOC_SECTION_EXCLUDE"] = "ruleDocSectionExclude"; | ||
OPTION_TYPE["RULE_DOC_SECTION_INCLUDE"] = "ruleDocSectionInclude"; | ||
OPTION_TYPE["RULE_DOC_SECTION_OPTIONS"] = "ruleDocSectionOptions"; | ||
OPTION_TYPE["RULE_DOC_TITLE_FORMAT"] = "ruleDocTitleFormat"; | ||
OPTION_TYPE["RULE_LIST_COLUMNS"] = "ruleListColumns"; | ||
OPTION_TYPE["SPLIT_BY"] = "splitBy"; | ||
OPTION_TYPE["URL_CONFIGS"] = "urlConfigs"; | ||
OPTION_TYPE["URL_RULE_DOC"] = "urlRuleDoc"; | ||
})(OPTION_TYPE || (OPTION_TYPE = {})); |
{ | ||
"name": "eslint-doc-generator", | ||
"version": "0.25.0", | ||
"version": "0.26.0", | ||
"description": "Automatic documentation generator for ESLint plugins and rules.", | ||
@@ -24,2 +24,3 @@ "keywords": [ | ||
"type": "module", | ||
"types": "./dist/lib/index.js", | ||
"bin": { | ||
@@ -52,3 +53,3 @@ "eslint-doc-generator": "./dist/bin/eslint-doc-generator.js" | ||
"commander": "^9.4.0", | ||
"cosmiconfig": "^7.1.0", | ||
"cosmiconfig": "^8.0.0", | ||
"deepmerge": "^4.2.2", | ||
@@ -55,0 +56,0 @@ "jest-diff": "^29.2.1", |
@@ -129,3 +129,3 @@ # eslint-doc-generator | ||
| `--path-rule-doc` | Path to markdown file for each rule doc. Use `{name}` placeholder for the rule name (default: `docs/rules/{name}.md`). | | ||
| `--path-rule-list` | Path to markdown file with a rules section where the rules table list should live (default: `README.md`). | | ||
| `--path-rule-list` | Path to markdown file where the rules table list should live. Default: `README.md`. Option can be repeated. | | ||
| `--rule-doc-notices` | Ordered, comma-separated list of notices to display in rule doc. Non-applicable notices will be hidden. Choices: `configs`, `deprecated`, `fixable` (off by default), `fixableAndHasSuggestions`, `hasSuggestions` (off by default), `options` (off by default), `requiresTypeChecking`, `type` (off by default). Default: `deprecated,configs,fixableAndHasSuggestions,requiresTypeChecking`. | | ||
@@ -162,6 +162,6 @@ | `--rule-doc-section-exclude` | Disallowed section in each rule doc. Exit with failure if present. Option can be repeated. | | ||
Example: | ||
Example `.eslint-doc-generatorrc.js`: | ||
```js | ||
// .eslint-doc-generatorrc.js | ||
/** @type {import('eslint-doc-generator').GenerateOptions} */ | ||
module.exports = { | ||
@@ -168,0 +168,0 @@ ignoreConfig: ['all'], |
103804
44
1877
+ Addedcosmiconfig@8.3.6(transitive)
- Removed@types/parse-json@4.0.2(transitive)
- Removedcosmiconfig@7.1.0(transitive)
- Removedyaml@1.10.2(transitive)
Updatedcosmiconfig@^8.0.0