Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eslint-doc-generator

Package Overview
Dependencies
Maintainers
1
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-doc-generator - npm Package Compare versions

Comparing version 1.5.0 to 1.5.1

12

dist/lib/config-list.js
import { BEGIN_CONFIG_LIST_MARKER, END_CONFIG_LIST_MARKER, } from './comment-markers.js';
import { markdownTable } from 'markdown-table';
import { configNameToDisplay } from './config-format.js';
import { sanitizeMarkdownTable } from './string.js';
function generateConfigListMarkdown(plugin, configsToRules, pluginPrefix, configEmojis, configFormat, ignoreConfig) {

@@ -14,3 +15,3 @@ /* istanbul ignore next -- configs are sure to exist at this point */

}
return markdownTable([
return markdownTable(sanitizeMarkdownTable([
listHeaderRow,

@@ -21,12 +22,11 @@ ...Object.keys(configsToRules)

.map((configName) => {
const description = // @ts-expect-error -- description is not an official config property.
plugin.configs?.[configName]?.description;
return [
configEmojis.find((obj) => obj.config === configName)?.emoji || '',
`\`${configNameToDisplay(configName, configFormat, pluginPrefix)}\``,
hasDescription
? // @ts-expect-error -- description is not an official config property.
plugin.configs?.[configName]?.description || ''
: undefined,
hasDescription ? description || '' : undefined,
].filter((col) => col !== undefined);
}),
], { align: 'l' } // Left-align headers.
]), { align: 'l' } // Left-align headers.
);

@@ -33,0 +33,0 @@ }

@@ -104,8 +104,8 @@ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';

const newHeaderLines = generateRuleHeaderLines(description, name, plugin, configsToRules, pluginPrefix, path, pathRuleDoc, configEmojis, configFormat, ignoreConfig, ruleDocNotices, ruleDocTitleFormat, urlConfigs, urlRuleDoc);
const contents = readFileSync(pathToDoc).toString();
const contentsNew = await postprocess(updateRuleOptionsList(replaceOrCreateHeader(contents, newHeaderLines, END_RULE_HEADER_MARKER), rule), resolve(pathToDoc));
const contentsOld = readFileSync(pathToDoc).toString();
const contentsNew = await postprocess(updateRuleOptionsList(replaceOrCreateHeader(contentsOld, newHeaderLines, END_RULE_HEADER_MARKER), rule), resolve(pathToDoc));
if (check) {
if (contentsNew !== contents) {
if (contentsNew !== contentsOld) {
console.error(`Please run eslint-doc-generator. A rule doc is out-of-date: ${relative(getPluginRoot(path), pathToDoc)}`);
console.error(diff(contentsNew, contents, { expand: false }));
console.error(diff(contentsNew, contentsOld, { expand: false }));
process.exitCode = 1;

@@ -120,13 +120,13 @@ }

for (const section of ruleDocSectionInclude) {
expectSectionHeaderOrFail(`\`${name}\` rule doc`, contents, [section], true);
expectSectionHeaderOrFail(`\`${name}\` rule doc`, contentsNew, [section], true);
}
// Check for disallowed sections.
for (const section of ruleDocSectionExclude) {
expectSectionHeaderOrFail(`\`${name}\` rule doc`, contents, [section], false);
expectSectionHeaderOrFail(`\`${name}\` rule doc`, contentsNew, [section], false);
}
if (ruleDocSectionOptions) {
// Options section.
expectSectionHeaderOrFail(`\`${name}\` rule doc`, contents, ['Options', 'Config'], hasOptions(schema));
expectSectionHeaderOrFail(`\`${name}\` rule doc`, contentsNew, ['Options', 'Config'], hasOptions(schema));
for (const { name: namedOption } of getAllNamedOptions(schema)) {
expectContentOrFail(`\`${name}\` rule doc`, 'rule option', contents, namedOption, true); // Each rule option is mentioned.
expectContentOrFail(`\`${name}\` rule doc`, 'rule option', contentsNew, namedOption, true); // Each rule option is mentioned.
}

@@ -133,0 +133,0 @@ }

@@ -14,3 +14,3 @@ import { BEGIN_RULE_LIST_MARKER, END_RULE_LIST_MARKER, } from './comment-markers.js';

import { getLinkToRule } from './rule-link.js';
import { capitalizeOnlyFirstLetter } from './string.js';
import { capitalizeOnlyFirstLetter, sanitizeMarkdownTable } from './string.js';
import { noCase } from 'no-case';

@@ -72,3 +72,5 @@ import { getProperty } from 'dot-prop';

: '',
[COLUMN_TYPE.TYPE]: rule.meta?.type ? EMOJIS_TYPE[rule.meta?.type] : '',
[COLUMN_TYPE.TYPE]: rule.meta?.type
? EMOJIS_TYPE[rule.meta?.type] || ''
: '',
};

@@ -99,6 +101,6 @@ // List columns using the ordering and presence of columns specified in columnsEnabled.

});
return markdownTable([
return markdownTable(sanitizeMarkdownTable([
listHeaderRow,
...ruleNamesAndRules.map(([name, rule]) => buildRuleRow(name, rule, columns, configsToRules, plugin, pluginPrefix, pathPlugin, pathRuleDoc, pathRuleList, configEmojis, ignoreConfig, urlRuleDoc)),
], { align: 'l' } // Left-align headers.
]), { align: 'l' } // Left-align headers.
);

@@ -105,0 +107,0 @@ }

import { BEGIN_RULE_OPTIONS_LIST_MARKER, END_RULE_OPTIONS_LIST_MARKER, } from './comment-markers.js';
import { markdownTable } from 'markdown-table';
import { getAllNamedOptions } from './rule-options.js';
import { capitalizeOnlyFirstLetter } from './string.js';
import { capitalizeOnlyFirstLetter, sanitizeMarkdownTable } from './string.js';
export var COLUMN_TYPE;

@@ -59,3 +59,3 @@ (function (COLUMN_TYPE) {

// Alphabetical order.
[COLUMN_TYPE.DEFAULT]: ruleOptions.some((ruleOption) => ruleOption.default),
[COLUMN_TYPE.DEFAULT]: ruleOptions.some((ruleOption) => ruleOption.default !== undefined),
[COLUMN_TYPE.DEPRECATED]: ruleOptions.some((ruleOption) => ruleOption.deprecated),

@@ -86,5 +86,5 @@ [COLUMN_TYPE.DESCRIPTION]: ruleOptions.some((ruleOption) => ruleOption.description),

.filter((type) => columnsToDisplay[type])
.map((type) => ruleOptionColumnValues[type]);
.map((type) => ruleOptionColumnValues[type] || '');
});
return markdownTable([listHeaderRow, ...rows], { align: 'l' } // Left-align headers.
return markdownTable(sanitizeMarkdownTable([listHeaderRow, ...rows]), { align: 'l' } // Left-align headers.
);

@@ -91,0 +91,0 @@ }

@@ -8,1 +8,2 @@ export declare function toSentenceCase(str: string): string;

export declare function capitalizeOnlyFirstLetter(str: string): string;
export declare function sanitizeMarkdownTable(text: readonly (readonly string[])[]): readonly (readonly string[])[];

@@ -18,1 +18,7 @@ export function toSentenceCase(str) {

}
function sanitizeMarkdownTableCell(text) {
return text.replace(/\|/gu, '\\|').replace(/\n/gu, '<br/>');
}
export function sanitizeMarkdownTable(text) {
return text.map((row) => row.map((col) => sanitizeMarkdownTableCell(col)));
}
{
"name": "eslint-doc-generator",
"version": "1.5.0",
"version": "1.5.1",
"description": "Automatic documentation generator for ESLint plugins and rules.",

@@ -5,0 +5,0 @@ "keywords": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc