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 0.18.0 to 0.18.1

2

dist/lib/configs.d.ts

@@ -18,2 +18,3 @@ import type { Plugin, ConfigsToRules, ConfigEmojis, RuleSeverity, SEVERITY_TYPE } from './types.js';

* @param options.fallback - if true and no emoji is found, choose whether to fallback to a generic config emoji or a badge
* @param options.noWrap - whether to add styling to ensure the superscript doesn't wrap to a separate line when used in constrained spaces
* @returns the string to display for the config

@@ -24,2 +25,3 @@ */

fallback?: 'badge' | 'emoji';
noWrap?: boolean;
}): string | undefined;

18

dist/lib/configs.js

@@ -58,2 +58,12 @@ import { EMOJI_CONFIGS, EMOJI_CONFIG, EMOJI_CONFIG_WARN, EMOJI_CONFIG_OFF, } from './emojis.js';

}
function emojiWithSuperscript(emoji, superscriptEmoji, noWrap = false) {
if (emoji === superscriptEmoji) {
// Avoid double emoji.
return emoji;
}
// Style is to ensure superscript doesn't wrap to separate line, useful in constrained spaces.
return noWrap
? `<span style="white-space:nowrap">${emoji}<sup>${superscriptEmoji}</sup></span>`
: `${emoji}<sup>${superscriptEmoji}</sup>`;
}
/**

@@ -66,2 +76,3 @@ * Find the representation of a config to display.

* @param options.fallback - if true and no emoji is found, choose whether to fallback to a generic config emoji or a badge
* @param options.noWrap - whether to add styling to ensure the superscript doesn't wrap to a separate line when used in constrained spaces
* @returns the string to display for the config

@@ -85,8 +96,5 @@ */

case 'warn':
return `${emoji}${
// Conditional is to avoid double emoji.
emoji === EMOJI_CONFIG_WARN ? '' : `<sup>${EMOJI_CONFIG_WARN}</sup>`}`;
return emojiWithSuperscript(emoji, EMOJI_CONFIG_WARN, options.noWrap);
case 'off':
// Conditional is to avoid double emoji.
return `${emoji}${emoji === EMOJI_CONFIG_OFF ? '' : `<sup>${EMOJI_CONFIG_OFF}</sup>`}`;
return emojiWithSuperscript(emoji, EMOJI_CONFIG_OFF, options.noWrap);
default:

@@ -93,0 +101,0 @@ return emoji;

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

fallback: 'badge',
noWrap: true,
}));

@@ -61,2 +62,3 @@ }

fallback: 'badge',
noWrap: true,
}));

@@ -70,2 +72,3 @@ }

fallback: 'badge',
noWrap: true,
}));

@@ -72,0 +75,0 @@ }

@@ -18,2 +18,34 @@ import { END_RULE_HEADER_MARKER } from './markers.js';

};
function severityToTerminology(severity) {
switch (severity) {
case SEVERITY_TYPE.error:
return 'is enabled';
case SEVERITY_TYPE.warn:
return '_warns_';
case SEVERITY_TYPE.off:
return 'is _disabled_';
/* istanbul ignore next -- this shouldn't happen */
default:
throw new Error(`Unknown severity: ${severity}`);
}
}
function configsToNoticeSentence(configs, severity, configsLinkOrWord, configLinkOrWord, configEmojis, useGenericConfigEmoji) {
// Create CSV list of configs with their emojis.
const csv = configs
.map((config) => {
const emoji = findConfigEmoji(configEmojis, config);
return `${emoji ? `${emoji} ` : ''}\`${config}\``;
})
.join(', ');
const term = severityToTerminology(severity);
const sentence = configs.length > 1
? `This rule ${term} in the following ${configsLinkOrWord}: ${csv}.`
: configs.length === 1
? `This rule ${term} in the ${
// If the config's emoji isn't already being used at the front of the notice, include it here by using the CSV.
// If the config's emoji IS already being used, just use the config name only here.
useGenericConfigEmoji ? csv : `\`${configs?.[0]}\``} ${configLinkOrWord}.`
: undefined;
return sentence;
}
/**

@@ -38,4 +70,4 @@ * An object containing the text for each notice type (as a string or function to generate the string).

let emoji = '';
if (configsEnabled.length + configsWarn.length + configsDisabled.length >
1) {
const useGenericConfigEmoji = configsEnabled.length + configsWarn.length + configsDisabled.length > 1;
if (useGenericConfigEmoji) {
emoji = EMOJI_CONFIG;

@@ -64,44 +96,10 @@ }

}
// List of configs that enable the rule.
const configsEnabledCSV = configsEnabled
.map((configEnabled) => {
const emoji = configEmojis.find((configEmoji) => configEmoji.config === configEnabled)?.emoji;
return `${emoji ? `${emoji} ` : ''}\`${configEnabled}\``;
})
.join(', ');
// List of configs that warn for the rule.
const configsWarnCSV = configsWarn
.map((configWarn) => {
const emoji = configEmojis.find((configEmoji) => configEmoji.config === configWarn)?.emoji;
return `${emoji ? `${emoji} ` : ''}\`${configWarn}\``;
})
.join(', ');
// List of configs that disable the rule.
const configsDisabledCSV = configsDisabled
.map((configDisabled) => {
const emoji = configEmojis.find((configEmoji) => configEmoji.config === configDisabled)?.emoji;
return `${emoji ? `${emoji} ` : ''}\`${configDisabled}\``;
})
.join(', ');
// Complete sentence for configs that enable the rule.
const SENTENCE_ENABLED = configsEnabled.length > 1
? `This rule is enabled in the following ${configsLinkOrWord}: ${configsEnabledCSV}.`
: configsEnabled.length === 1
? `This rule is enabled in the \`${configsEnabled?.[0]}\` ${configLinkOrWord}.`
: undefined;
// Complete sentence for configs that warn for the rule.
const SENTENCE_WARN = configsWarn.length > 1
? `This rule _warns_ in the following ${configsLinkOrWord}: ${configsWarnCSV}.`
: configsWarn.length === 1
? `This rule _warns_ in the \`${configsWarn?.[0]}\` ${configLinkOrWord}.`
: undefined;
// Complete sentence for configs that disable the rule.
const SENTENCE_DISABLED = configsDisabled.length > 1
? `This rule is _disabled_ in the following ${configsLinkOrWord}: ${configsDisabledCSV}.`
: configsDisabled.length === 1
? `This rule is _disabled_ in the \`${configsDisabled?.[0]}\` ${configLinkOrWord}.`
: undefined;
return `${emoji} ${[SENTENCE_ENABLED, SENTENCE_WARN, SENTENCE_DISABLED]
.filter((sentence) => sentence !== undefined)
.join(' ')}`;
const sentences = [
configsToNoticeSentence(configsEnabled, SEVERITY_TYPE.error, configsLinkOrWord, configLinkOrWord, configEmojis, useGenericConfigEmoji),
configsToNoticeSentence(configsWarn, SEVERITY_TYPE.warn, configsLinkOrWord, configLinkOrWord, configEmojis, useGenericConfigEmoji),
configsToNoticeSentence(configsDisabled, SEVERITY_TYPE.off, configsLinkOrWord, configLinkOrWord, configEmojis, useGenericConfigEmoji),
]
.filter(Boolean)
.join(' ');
return `${emoji} ${sentences}`;
},

@@ -108,0 +106,0 @@ // Deprecated notice has optional "replaced by" rules list.

{
"name": "eslint-doc-generator",
"version": "0.18.0",
"version": "0.18.1",
"description": "Automatic documentation generator for ESLint plugins and rules.",

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

@@ -222,7 +222,7 @@ # eslint-doc-generator

The output of this tool should be compatible with [markdownlint](https://github.com/DavidAnson/markdownlint) which you might use to lint your markdown. However, if any of your ESLint configs disable your rules or set them to warn, you'll need to exempt the [`<sup>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/sup) (superscript) element from [no-inline-html](https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#md033---inline-html):
The output of this tool should be compatible with [markdownlint](https://github.com/DavidAnson/markdownlint) which you might use to lint your markdown. However, if any of your ESLint configs disable your rules or set them to warn, you'll need to exempt some elements used for the emoji superscript from [no-inline-html](https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#md033---inline-html):
```json
{
"no-inline-html": { "allowed_elements": ["sup"] }
"no-inline-html": { "allowed_elements": ["span", "sup"] }
}

@@ -229,0 +229,0 @@ ```

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