eslint-doc-generator
Advanced tools
Comparing version 1.7.0 to 1.7.1
@@ -0,1 +1,2 @@ | ||
import { EOL } from 'node:os'; | ||
import { BEGIN_CONFIG_LIST_MARKER, END_CONFIG_LIST_MARKER, } from './comment-markers.js'; | ||
@@ -67,3 +68,3 @@ import { markdownTable } from 'markdown-table'; | ||
const list = generateConfigListMarkdown(plugin, configsToRules, pluginPrefix, configEmojis, configFormat, ignoreConfig); | ||
return `${preList}${BEGIN_CONFIG_LIST_MARKER}\n\n${list}\n\n${END_CONFIG_LIST_MARKER}${postList}`; | ||
return `${preList}${BEGIN_CONFIG_LIST_MARKER}${EOL}${EOL}${list}${EOL}${EOL}${END_CONFIG_LIST_MARKER}${postList}`; | ||
} |
@@ -0,1 +1,2 @@ | ||
import { EOL } from 'node:os'; | ||
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'; | ||
@@ -103,12 +104,14 @@ import { dirname, join, relative, resolve } from 'node:path'; | ||
ruleDocSectionInclude.length > 0 | ||
? ruleDocSectionInclude.map((title) => `## ${title}`).join('\n\n') | ||
? ruleDocSectionInclude | ||
.map((title) => `## ${title}`) | ||
.join(`${EOL}${EOL}`) | ||
: undefined, | ||
ruleHasOptions | ||
? `## Options\n\n${BEGIN_RULE_OPTIONS_LIST_MARKER}\n${END_RULE_OPTIONS_LIST_MARKER}` | ||
? `## Options${EOL}${EOL}${BEGIN_RULE_OPTIONS_LIST_MARKER}${EOL}${END_RULE_OPTIONS_LIST_MARKER}` | ||
: undefined, | ||
] | ||
.filter((section) => section !== undefined) | ||
.join('\n\n'); | ||
.join(`${EOL}${EOL}`); | ||
if (newRuleDocContents !== '') { | ||
newRuleDocContents = `\n${newRuleDocContents}\n`; | ||
newRuleDocContents = `${EOL}${newRuleDocContents}${EOL}`; | ||
} | ||
@@ -115,0 +118,0 @@ mkdirSync(dirname(pathToDoc), { recursive: true }); |
@@ -0,1 +1,2 @@ | ||
import { EOL } from 'node:os'; | ||
// General helpers for dealing with markdown files / content. | ||
@@ -10,3 +11,3 @@ /** | ||
export function replaceOrCreateHeader(markdown, newHeader, marker) { | ||
const lines = markdown.split('\n'); | ||
const lines = markdown.split(EOL); | ||
const titleLineIndex = lines.findIndex((line) => line.startsWith('# ')); | ||
@@ -19,8 +20,8 @@ const markerLineIndex = lines.indexOf(marker); | ||
.slice(0, Math.max(titleLineIndex, dashesLineIndex2 + 1)) | ||
.join('\n'); | ||
.join(EOL); | ||
// 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}`; | ||
.join(EOL); | ||
return `${preHeader ? `${preHeader}${EOL}` : ''}${newHeader}${EOL}${postHeader}`; | ||
} | ||
@@ -32,3 +33,3 @@ /** | ||
// Get all the matching strings. | ||
const regexp = new RegExp(`## .*${str}.*\n`, 'giu'); | ||
const regexp = new RegExp(`## .*${str}.*${EOL}`, 'giu'); | ||
const sectionPotentialMatches = [...markdown.matchAll(regexp)].map((match) => match[0]); | ||
@@ -47,3 +48,3 @@ if (sectionPotentialMatches.length === 0) { | ||
export function findFinalHeaderLevel(str) { | ||
const lines = str.split('\n'); | ||
const lines = str.split(EOL); | ||
const finalHeader = lines.reverse().find((line) => line.match('^(#+) .+$')); | ||
@@ -50,0 +51,0 @@ return finalHeader ? finalHeader.indexOf(' ') : undefined; |
@@ -0,1 +1,2 @@ | ||
import { EOL } from 'node:os'; | ||
import { END_RULE_HEADER_MARKER } from './comment-markers.js'; | ||
@@ -273,3 +274,3 @@ import { EMOJI_DEPRECATED, EMOJI_FIXABLE, EMOJI_HAS_SUGGESTIONS, EMOJI_REQUIRES_TYPE_CHECKING, EMOJI_CONFIG_FROM_SEVERITY, EMOJI_OPTIONS, } from './emojis.js'; | ||
END_RULE_HEADER_MARKER, | ||
].join('\n'); | ||
].join(EOL); | ||
} |
@@ -0,1 +1,2 @@ | ||
import { EOL } from 'node:os'; | ||
import { EMOJI_DEPRECATED, EMOJI_FIXABLE, EMOJI_HAS_SUGGESTIONS, EMOJI_OPTIONS, EMOJI_REQUIRES_TYPE_CHECKING, EMOJI_TYPE, EMOJI_CONFIG_FROM_SEVERITY, } from './emojis.js'; | ||
@@ -157,3 +158,3 @@ import { findConfigEmoji, getConfigsThatSetARule } from './plugin-configs.js'; | ||
} | ||
return legends.join('\\\n'); // Back slash ensures these end up displayed on separate lines. | ||
return legends.join(`\\${EOL}`); // Back slash ensures these end up displayed on separate lines. | ||
} |
@@ -0,1 +1,2 @@ | ||
import { EOL } from 'node:os'; | ||
import { BEGIN_RULE_LIST_MARKER, END_RULE_LIST_MARKER, } from './comment-markers.js'; | ||
@@ -113,3 +114,3 @@ import { EMOJI_DEPRECATED, EMOJI_FIXABLE, EMOJI_HAS_SUGGESTIONS, EMOJI_OPTIONS, EMOJI_REQUIRES_TYPE_CHECKING, } from './emojis.js'; | ||
} | ||
return parts.join('\n\n'); | ||
return parts.join(`${EOL}${EOL}`); | ||
} | ||
@@ -265,4 +266,4 @@ /** | ||
const list = generateRuleListMarkdownForRulesAndHeaders(rulesAndHeaders, ruleListSplitHeaderLevel, columns, configsToRules, plugin, pluginPrefix, pathPlugin, pathRuleDoc, pathRuleList, configEmojis, ignoreConfig, urlRuleDoc); | ||
const newContent = `${legend ? `${legend}\n\n` : ''}${list}`; | ||
return `${preList}${BEGIN_RULE_LIST_MARKER}\n\n${newContent}\n\n${END_RULE_LIST_MARKER}${postList}`; | ||
const newContent = `${legend ? `${legend}${EOL}${EOL}` : ''}${list}`; | ||
return `${preList}${BEGIN_RULE_LIST_MARKER}${EOL}${EOL}${newContent}${EOL}${EOL}${END_RULE_LIST_MARKER}${postList}`; | ||
} |
@@ -0,1 +1,2 @@ | ||
import { EOL } from 'node:os'; | ||
import { BEGIN_RULE_OPTIONS_LIST_MARKER, END_RULE_OPTIONS_LIST_MARKER, } from './comment-markers.js'; | ||
@@ -111,3 +112,3 @@ import { markdownTable } from 'markdown-table'; | ||
const list = generateRuleOptionsListMarkdown(rule); | ||
return `${preList}${BEGIN_RULE_OPTIONS_LIST_MARKER}\n\n${list}\n\n${END_RULE_OPTIONS_LIST_MARKER}${postList}`; | ||
return `${preList}${BEGIN_RULE_OPTIONS_LIST_MARKER}${EOL}${EOL}${list}${EOL}${EOL}${END_RULE_OPTIONS_LIST_MARKER}${postList}`; | ||
} |
@@ -0,1 +1,2 @@ | ||
import { EOL } from 'node:os'; | ||
export function toSentenceCase(str) { | ||
@@ -19,3 +20,3 @@ return str.replace(/^\w/u, function (txt) { | ||
function sanitizeMarkdownTableCell(text) { | ||
return text.replace(/\|/gu, '\\|').replace(/\n/gu, '<br/>'); | ||
return text.replace(/\|/gu, '\\|').replace(new RegExp(EOL, 'gu'), '<br/>'); | ||
} | ||
@@ -22,0 +23,0 @@ export function sanitizeMarkdownTable(text) { |
{ | ||
"name": "eslint-doc-generator", | ||
"version": "1.7.0", | ||
"version": "1.7.1", | ||
"description": "Automatic documentation generator for ESLint plugins and rules.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
155303
2664