eslint-doc-generator
Version:
Automatic documentation generator for ESLint plugins and rules.
59 lines (58 loc) • 2.78 kB
JavaScript
import { join } from 'node:path';
import { COLUMN_TYPE, NOTICE_TYPE, OPTION_TYPE } from './types.js';
export const COLUMN_TYPE_DEFAULT_PRESENCE_AND_ORDERING = {
// Object keys ordered in display order.
// Object values indicate whether the column is displayed by default.
[ ]: true,
[ ]: true,
[ ]: true,
[ ]: true,
[ ]: true,
[ ]: true,
[ ]: false, // Optional, consolidated column.
[ ]: true,
[ ]: false,
[ ]: true,
[ ]: false,
[ ]: true,
};
export const NOTICE_TYPE_DEFAULT_PRESENCE_AND_ORDERING = {
// Object keys ordered in display order.
// Object values indicate whether the column is displayed by default.
[ ]: true, // Most important.
[ ]: true,
[ ]: false,
[ ]: true, // Default, consolidated notice.
[ ]: false,
[ ]: false,
[ ]: true,
[ ]: false,
[ ]: false,
};
// Using these variables ensures they have the correct type (not just a plain string).
const DEFAULT_RULE_DOC_TITLE_FORMAT = 'desc-parens-prefix-name';
const DEFAULT_CONFIG_FORMAT = 'name';
export const OPTION_DEFAULTS = {
[ ]: false,
[ ]: [],
[ ]: DEFAULT_CONFIG_FORMAT,
[ ]: [],
[ ]: false,
[ ]: false,
[ ]: join('docs', 'rules', '{name}.md'),
[ ]: ['README.md'],
[ ]: (content) => content,
[ ]: Object.entries(NOTICE_TYPE_DEFAULT_PRESENCE_AND_ORDERING)
.filter(([_col, enabled]) => enabled)
.map(([col]) => col),
[ ]: [],
[ ]: [],
[ ]: true,
[ ]: DEFAULT_RULE_DOC_TITLE_FORMAT,
[ ]: Object.entries(COLUMN_TYPE_DEFAULT_PRESENCE_AND_ORDERING)
.filter(([_col, enabled]) => enabled)
.map(([col]) => col),
[ ]: [],
[ ]: undefined,
[ ]: undefined,
}; // Satisfies is used to ensure all options are included, but without losing type information.