From 9b02e477c6febda6e572eaa94f688f0bb6e483ce Mon Sep 17 00:00:00 2001
From: Tony Brix
Date: Sun, 14 Jul 2024 18:54:46 -0600
Subject: [PATCH] chore: consolidate eslint rules (#3368)
---
api/dingus.js | 4 +-
bin/main.js | 6 +-
docs/build.js | 2 +-
docs/demo/demo.js | 10 +-
docs/demo/worker.js | 6 +-
eslint-config-standard.js | 256 --------
eslint.config.js | 242 ++++++--
package-lock.json | 428 ++++++++++++-
package.json | 1 +
rollup.config.js | 18 +-
src/Hooks.ts | 2 +-
src/Instance.ts | 18 +-
src/Lexer.ts | 10 +-
src/Parser.ts | 2 +-
src/Renderer.ts | 4 +-
src/Tokenizer.ts | 70 +--
src/Tokens.ts | 359 +++++------
src/defaults.ts | 2 +-
src/helpers.ts | 6 +-
src/marked.ts | 2 +-
src/rules.ts | 20 +-
test/bench.js | 12 +-
test/recheck.js | 2 +-
test/rules.js | 2 +-
test/run-spec-tests.js | 12 +-
test/specs/redos/cubic_def.cjs | 2 +-
test/specs/redos/quadratic_br.cjs | 2 +-
test/specs/redos/quadratic_em_mask.cjs | 10 +-
test/specs/redos/quadratic_email.cjs | 2 +-
test/specs/redos/quadratic_heading.cjs | 2 +-
test/specs/redos/quadratic_lists.cjs | 2 +-
test/specs/redos/quadratic_underscores.cjs | 2 +-
test/unit/Hooks.test.js | 44 +-
test/unit/Lexer.test.js | 676 ++++++++++-----------
test/unit/Parser.test.js | 204 +++----
test/unit/bin.test.js | 26 +-
test/unit/fixtures/bin-config.js | 2 +-
test/unit/instance.test.js | 26 +-
test/unit/marked.test.js | 144 ++---
test/update-specs.js | 2 +-
40 files changed, 1494 insertions(+), 1148 deletions(-)
delete mode 100644 eslint-config-standard.js
diff --git a/api/dingus.js b/api/dingus.js
index 958f6c6aee..5304a13442 100644
--- a/api/dingus.js
+++ b/api/dingus.js
@@ -9,8 +9,8 @@ export default function dingus(req, res) {
return res.status(405).json({
error: {
code: 'method_not_allowed',
- message: 'Only GET requests are supported for this endpoint.'
- }
+ message: 'Only GET requests are supported for this endpoint.',
+ },
});
}
const { text = '' } = req.query;
diff --git a/bin/main.js b/bin/main.js
index 79787e2ca5..76051eb626 100644
--- a/bin/main.js
+++ b/bin/main.js
@@ -28,7 +28,7 @@ export async function main(nodeProcess) {
const options = {
cwd: nodeProcess.cwd(),
env: nodeProcess.env,
- stdio: 'inherit'
+ stdio: 'inherit',
};
const __dirname = dirname(fileURLToPath(import.meta.url));
@@ -127,7 +127,7 @@ export async function main(nodeProcess) {
default:
if (arg.indexOf('--') === 0) {
opt = camelize(arg.replace(/^--(no-)?/, ''));
- if (!marked.defaults.hasOwnProperty(opt)) {
+ if (!(opt in marked.defaults)) {
continue;
}
if (arg.indexOf('--no-') === 0) {
@@ -204,7 +204,7 @@ export async function main(nodeProcess) {
const defaultConfig = [
'~/.marked.json',
'~/.marked.js',
- '~/.marked/index.js'
+ '~/.marked/index.js',
];
for (const configFile of defaultConfig) {
diff --git a/docs/build.js b/docs/build.js
index e9ce68b77e..aa11ae1c85 100644
--- a/docs/build.js
+++ b/docs/build.js
@@ -38,7 +38,7 @@ async function init() {
const ignoredFiles = [
join(cwd, 'docs', 'build.js'),
join(cwd, 'docs', '.eslintrc.json'),
- join(cwd, 'docs', '_document.html')
+ join(cwd, 'docs', '_document.html'),
];
async function build(currentDir, tmpl) {
diff --git a/docs/demo/demo.js b/docs/demo/demo.js
index f6a50c82cd..83d227b3f5 100644
--- a/docs/demo/demo.js
+++ b/docs/demo/demo.js
@@ -24,7 +24,7 @@ let $activeOutputElem = null;
let latestVersion = 'master';
const search = searchToObject();
const markedVersions = {
- master: '../'
+ master: '../',
};
let delayTime = 1;
let checkChangeTimeout = null;
@@ -55,7 +55,7 @@ Promise.all([
setInitialOutputType(),
setInitialText(),
setInitialVersion()
- .then(setInitialOptions)
+ .then(setInitialOptions),
]).then(() => {
handleInputChange();
handleOutputChange();
@@ -177,7 +177,7 @@ function handleChange(panes, visiblePane) {
function setDefaultOptions() {
return messageWorker({
task: 'defaults',
- version: markedVersions[$markedVerElem.value]
+ version: markedVersions[$markedVerElem.value],
});
}
@@ -282,7 +282,7 @@ function checkForChanges() {
task: 'parse',
version,
markdown,
- options
+ options,
});
}
}
@@ -305,7 +305,7 @@ function setResponseTime(ms) {
$responseTimeElem.textContent = amount + suffix;
$responseTimeElem.animate([
{ transform: 'scale(1.2)' },
- { transform: 'scale(1)' }
+ { transform: 'scale(1)' },
], 200);
}
diff --git a/docs/demo/worker.js b/docs/demo/worker.js
index ef995730e0..d239bf5383 100644
--- a/docs/demo/worker.js
+++ b/docs/demo/worker.js
@@ -40,7 +40,7 @@ function mergeOptions(options) {
'walkTokens',
'extensions',
'highlight',
- 'sanitizer'
+ 'sanitizer',
];
for (const prop in defaults) {
opts[prop] = invalidOptions.includes(prop) || !(prop in options)
@@ -56,7 +56,7 @@ function parse(e) {
postMessage({
id: e.data.id,
task: e.data.task,
- defaults: getDefaults()
+ defaults: getDefaults(),
});
break;
}
@@ -74,7 +74,7 @@ function parse(e) {
task: e.data.task,
lexed: lexedList,
parsed,
- time: endTime - startTime
+ time: endTime - startTime,
});
break;
}
diff --git a/eslint-config-standard.js b/eslint-config-standard.js
deleted file mode 100644
index 3f5e150707..0000000000
--- a/eslint-config-standard.js
+++ /dev/null
@@ -1,256 +0,0 @@
-/*! eslint-config-standard. MIT License. Feross Aboukhadijeh */
-
-import pluginN from 'eslint-plugin-n';
-import globals from 'globals';
-
-const config = {
- languageOptions: {
- ecmaVersion: 2022,
- sourceType: 'module',
-
- parserOptions: {
- ecmaFeatures: { jsx: true }
- },
-
- globals: {
- ...globals.es2021,
- ...globals.node,
- document: 'readonly',
- navigator: 'readonly',
- window: 'readonly'
- }
- },
-
- plugins: {
- n: pluginN
- },
-
- rules: {
- 'no-var': 'warn',
- 'object-shorthand': ['warn', 'properties'],
-
- 'accessor-pairs': ['error', { setWithoutGet: true, enforceForClassMembers: true }],
- 'array-bracket-spacing': ['error', 'never'],
- 'array-callback-return': ['error', {
- allowImplicit: false,
- checkForEach: false
- }],
- 'arrow-spacing': ['error', { before: true, after: true }],
- 'block-spacing': ['error', 'always'],
- 'brace-style': ['error', '1tbs', { allowSingleLine: true }],
- camelcase: ['error', {
- allow: ['^UNSAFE_'],
- properties: 'never',
- ignoreGlobals: true
- }],
- 'comma-dangle': ['error', {
- arrays: 'never',
- objects: 'never',
- imports: 'never',
- exports: 'never',
- functions: 'never'
- }],
- 'comma-spacing': ['error', { before: false, after: true }],
- 'comma-style': ['error', 'last'],
- 'computed-property-spacing': ['error', 'never', { enforceForClassMembers: true }],
- 'constructor-super': 'error',
- curly: ['error', 'multi-line'],
- 'default-case-last': 'error',
- 'dot-location': ['error', 'property'],
- 'dot-notation': ['error', { allowKeywords: true }],
- 'eol-last': 'error',
- eqeqeq: ['error', 'always', { null: 'ignore' }],
- 'func-call-spacing': ['error', 'never'],
- 'generator-star-spacing': ['error', { before: true, after: true }],
- indent: ['error', 2, {
- SwitchCase: 1,
- VariableDeclarator: 1,
- outerIIFEBody: 1,
- MemberExpression: 1,
- FunctionDeclaration: { parameters: 1, body: 1 },
- FunctionExpression: { parameters: 1, body: 1 },
- CallExpression: { arguments: 1 },
- ArrayExpression: 1,
- ObjectExpression: 1,
- ImportDeclaration: 1,
- flatTernaryExpressions: false,
- ignoreComments: false,
- ignoredNodes: [
- 'TemplateLiteral *',
- 'JSXElement',
- 'JSXElement > *',
- 'JSXAttribute',
- 'JSXIdentifier',
- 'JSXNamespacedName',
- 'JSXMemberExpression',
- 'JSXSpreadAttribute',
- 'JSXExpressionContainer',
- 'JSXOpeningElement',
- 'JSXClosingElement',
- 'JSXFragment',
- 'JSXOpeningFragment',
- 'JSXClosingFragment',
- 'JSXText',
- 'JSXEmptyExpression',
- 'JSXSpreadChild'
- ],
- offsetTernaryExpressions: true
- }],
- 'key-spacing': ['error', { beforeColon: false, afterColon: true }],
- 'keyword-spacing': ['error', { before: true, after: true }],
- 'lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: true }],
- 'multiline-ternary': ['error', 'always-multiline'],
- 'new-cap': ['error', { newIsCap: true, capIsNew: false, properties: true }],
- 'new-parens': 'error',
- 'no-array-constructor': 'error',
- 'no-async-promise-executor': 'error',
- 'no-caller': 'error',
- 'no-case-declarations': 'error',
- 'no-class-assign': 'error',
- 'no-compare-neg-zero': 'error',
- 'no-cond-assign': 'error',
- 'no-const-assign': 'error',
- 'no-constant-condition': ['error', { checkLoops: false }],
- 'no-control-regex': 'error',
- 'no-debugger': 'error',
- 'no-delete-var': 'error',
- 'no-dupe-args': 'error',
- 'no-dupe-class-members': 'error',
- 'no-dupe-keys': 'error',
- 'no-duplicate-case': 'error',
- 'no-useless-backreference': 'error',
- 'no-empty': ['error', { allowEmptyCatch: true }],
- 'no-empty-character-class': 'error',
- 'no-empty-pattern': 'error',
- 'no-eval': 'error',
- 'no-ex-assign': 'error',
- 'no-extend-native': 'error',
- 'no-extra-bind': 'error',
- 'no-extra-boolean-cast': 'error',
- 'no-extra-parens': ['error', 'functions'],
- 'no-fallthrough': 'error',
- 'no-floating-decimal': 'error',
- 'no-func-assign': 'error',
- 'no-global-assign': 'error',
- 'no-implied-eval': 'error',
- 'no-import-assign': 'error',
- 'no-invalid-regexp': 'error',
- 'no-irregular-whitespace': 'error',
- 'no-iterator': 'error',
- 'no-labels': ['error', { allowLoop: false, allowSwitch: false }],
- 'no-lone-blocks': 'error',
- 'no-loss-of-precision': 'error',
- 'no-misleading-character-class': 'error',
- 'no-prototype-builtins': 'error',
- 'no-useless-catch': 'error',
- 'no-mixed-operators': ['error', {
- groups: [
- ['==', '!=', '===', '!==', '>', '>=', '<', '<='],
- ['&&', '||'],
- ['in', 'instanceof']
- ],
- allowSamePrecedence: true
- }],
- 'no-mixed-spaces-and-tabs': 'error',
- 'no-multi-spaces': 'error',
- 'no-multi-str': 'error',
- 'no-multiple-empty-lines': ['error', { max: 1, maxBOF: 0, maxEOF: 0 }],
- 'no-new': 'error',
- 'no-new-func': 'error',
- 'no-new-object': 'error',
- 'no-new-symbol': 'error',
- 'no-new-wrappers': 'error',
- 'no-obj-calls': 'error',
- 'no-octal': 'error',
- 'no-octal-escape': 'error',
- 'no-proto': 'error',
- 'no-redeclare': ['error', { builtinGlobals: false }],
- 'no-regex-spaces': 'error',
- 'no-return-assign': ['error', 'except-parens'],
- 'no-self-assign': ['error', { props: true }],
- 'no-self-compare': 'error',
- 'no-sequences': 'error',
- 'no-shadow-restricted-names': 'error',
- 'no-sparse-arrays': 'error',
- 'no-tabs': 'error',
- 'no-template-curly-in-string': 'error',
- 'no-this-before-super': 'error',
- 'no-throw-literal': 'error',
- 'no-trailing-spaces': 'error',
- 'no-undef': 'error',
- 'no-undef-init': 'error',
- 'no-unexpected-multiline': 'error',
- 'no-unmodified-loop-condition': 'error',
- 'no-unneeded-ternary': ['error', { defaultAssignment: false }],
- 'no-unreachable': 'error',
- 'no-unreachable-loop': 'error',
- 'no-unsafe-finally': 'error',
- 'no-unsafe-negation': 'error',
- 'no-unused-expressions': ['error', {
- allowShortCircuit: true,
- allowTernary: true,
- allowTaggedTemplates: true
- }],
- 'no-unused-vars': ['error', {
- args: 'none',
- caughtErrors: 'none',
- ignoreRestSiblings: true,
- vars: 'all'
- }],
- 'no-use-before-define': ['error', { functions: false, classes: false, variables: false }],
- 'no-useless-call': 'error',
- 'no-useless-computed-key': 'error',
- 'no-useless-constructor': 'error',
- 'no-useless-escape': 'error',
- 'no-useless-rename': 'error',
- 'no-useless-return': 'error',
- 'no-void': 'error',
- 'no-whitespace-before-property': 'error',
- 'no-with': 'error',
- 'object-curly-newline': ['error', { multiline: true, consistent: true }],
- 'object-curly-spacing': ['error', 'always'],
- 'object-property-newline': ['error', { allowMultiplePropertiesPerLine: true }],
- 'one-var': ['error', { initialized: 'never' }],
- 'operator-linebreak': ['error', 'after', { overrides: { '?': 'before', ':': 'before', '|>': 'before' } }],
- 'padded-blocks': ['error', { blocks: 'never', switches: 'never', classes: 'never' }],
- 'prefer-const': ['error', { destructuring: 'all' }],
- 'prefer-promise-reject-errors': 'error',
- 'prefer-regex-literals': ['error', { disallowRedundantWrapping: true }],
- 'quote-props': ['error', 'as-needed'],
- quotes: ['error', 'single', { avoidEscape: true, allowTemplateLiterals: false }],
- 'rest-spread-spacing': ['error', 'never'],
- semi: ['error', 'never'],
- 'semi-spacing': ['error', { before: false, after: true }],
- 'space-before-blocks': ['error', 'always'],
- 'space-before-function-paren': ['error', 'always'],
- 'space-in-parens': ['error', 'never'],
- 'space-infix-ops': 'error',
- 'space-unary-ops': ['error', { words: true, nonwords: false }],
- 'spaced-comment': ['error', 'always', {
- line: { markers: ['*package', '!', '/', ',', '='] },
- block: { balanced: true, markers: ['*package', '!', ',', ':', '::', 'flow-include'], exceptions: ['*'] }
- }],
- 'symbol-description': 'error',
- 'template-curly-spacing': ['error', 'never'],
- 'template-tag-spacing': ['error', 'never'],
- 'unicode-bom': ['error', 'never'],
- 'use-isnan': ['error', {
- enforceForSwitchCase: true,
- enforceForIndexOf: true
- }],
- 'valid-typeof': ['error', { requireStringLiterals: true }],
- 'wrap-iife': ['error', 'any', { functionPrototypeMethods: true }],
- 'yield-star-spacing': ['error', 'both'],
- yoda: ['error', 'never'],
-
- 'n/handle-callback-err': ['error', '^(err|error)$'],
- 'n/no-callback-literal': 'error',
- 'n/no-deprecated-api': 'error',
- 'n/no-exports-assign': 'error',
- 'n/no-new-require': 'error',
- 'n/no-path-concat': 'error',
- 'n/process-exit-as-throw': 'error'
- }
-};
-
-export default config;
diff --git a/eslint.config.js b/eslint.config.js
index a7d24fcf73..36b92a878f 100644
--- a/eslint.config.js
+++ b/eslint.config.js
@@ -1,58 +1,232 @@
import globals from 'globals';
-import standardConfig from './eslint-config-standard.js';
-import tseslint from 'typescript-eslint';
+import pluginN from 'eslint-plugin-n';
+import tsEslint from 'typescript-eslint';
+import stylistic from '@stylistic/eslint-plugin';
export default [
{
- ignores: ['**/lib', '**/*.min.js', '**/public']
+ ignores: ['**/lib', '**/*.min.js', '**/public'],
},
- standardConfig,
- ...tseslint.configs.recommended,
+ ...tsEslint.configs.recommended,
{
+ plugins: {
+ '@n': pluginN,
+ '@stylistic': stylistic,
+ },
+
languageOptions: {
+ ecmaVersion: 2024,
+ sourceType: 'module',
+
globals: {
+ ...globals.es2024,
...globals.node,
- ...globals.browser
- }
+ ...globals.browser,
+ document: 'readonly',
+ navigator: 'readonly',
+ window: 'readonly',
+ },
},
rules: {
- semi: ['error', 'always'],
+ 'accessor-pairs': ['error', { setWithoutGet: true, enforceForClassMembers: true }],
+ 'array-callback-return': ['error', {
+ allowImplicit: false,
+ checkForEach: false,
+ }],
+ 'constructor-super': 'error',
+ curly: ['error', 'multi-line'],
+ 'default-case-last': 'error',
+ 'dot-notation': ['error', { allowKeywords: true }],
+ eqeqeq: ['error', 'always', { null: 'ignore' }],
+ 'new-cap': ['error', { newIsCap: true, capIsNew: false, properties: true }],
+ 'no-array-constructor': 'error',
+ 'no-async-promise-executor': 'error',
+ 'no-caller': 'error',
+ 'no-case-declarations': 'error',
+ 'no-class-assign': 'error',
+ 'no-compare-neg-zero': 'error',
+ 'no-const-assign': 'error',
+ 'no-constant-condition': ['error', { checkLoops: false }],
+ 'no-debugger': 'error',
+ 'no-delete-var': 'error',
+ 'no-dupe-args': 'error',
+ 'no-dupe-keys': 'error',
+ 'no-duplicate-case': 'error',
+ 'no-useless-backreference': 'error',
+ 'no-empty': ['error', { allowEmptyCatch: true }],
+ 'no-empty-character-class': 'error',
+ 'no-empty-pattern': 'error',
+ 'no-eval': 'error',
+ 'no-ex-assign': 'error',
+ 'no-extend-native': 'error',
+ 'no-extra-bind': 'error',
+ 'no-extra-boolean-cast': 'error',
+ 'no-fallthrough': 'error',
+ 'no-func-assign': 'error',
+ 'no-global-assign': 'error',
+ 'no-implied-eval': 'error',
+ 'no-import-assign': 'error',
+ 'no-invalid-regexp': 'error',
+ 'no-irregular-whitespace': 'error',
+ 'no-iterator': 'error',
+ 'no-labels': ['error', { allowLoop: false, allowSwitch: false }],
+ 'no-lone-blocks': 'error',
+ 'no-loss-of-precision': 'error',
+ 'no-misleading-character-class': 'error',
+ 'no-prototype-builtins': 'error',
+ 'no-useless-catch': 'error',
+ 'no-multi-str': 'error',
+ 'no-new': 'error',
+ 'no-new-func': 'error',
+ 'no-new-object': 'error',
+ 'no-new-symbol': 'error',
+ 'no-new-wrappers': 'error',
+ 'no-obj-calls': 'error',
+ 'no-octal': 'error',
+ 'no-octal-escape': 'error',
+ 'no-proto': 'error',
+ 'no-regex-spaces': 'error',
+ 'no-return-assign': ['error', 'except-parens'],
+ 'no-self-assign': ['error', { props: true }],
+ 'no-self-compare': 'error',
+ 'no-sequences': 'error',
+ 'no-shadow-restricted-names': 'error',
+ 'no-sparse-arrays': 'error',
+ 'no-template-curly-in-string': 'error',
+ 'no-this-before-super': 'error',
+ 'no-throw-literal': 'error',
+ 'no-undef': 'error',
+ 'no-undef-init': 'error',
+ 'no-unexpected-multiline': 'error',
+ 'no-unmodified-loop-condition': 'error',
+ 'no-unneeded-ternary': ['error', { defaultAssignment: false }],
+ 'no-unreachable': 'error',
+ 'no-unreachable-loop': 'error',
+ 'no-unsafe-finally': 'error',
+ 'no-unsafe-negation': 'error',
+ 'no-unused-expressions': ['error', {
+ allowShortCircuit: true,
+ allowTernary: true,
+ allowTaggedTemplates: true,
+ }],
+ 'no-unused-vars': ['error', {
+ args: 'none',
+ caughtErrors: 'none',
+ ignoreRestSiblings: true,
+ vars: 'all',
+ }],
+ 'no-use-before-define': ['error', { functions: false, classes: false, variables: false }],
+ 'no-useless-call': 'error',
+ 'no-useless-computed-key': 'error',
+ 'no-useless-constructor': 'error',
+ 'no-useless-rename': 'error',
+ 'no-useless-return': 'error',
+ 'no-var': 'error',
+ 'no-void': 'error',
+ 'no-with': 'error',
+ 'object-shorthand': ['warn', 'properties'],
+ 'prefer-const': ['error', { destructuring: 'all' }],
+ 'prefer-promise-reject-errors': 'error',
+ 'prefer-regex-literals': ['error', { disallowRedundantWrapping: true }],
+ 'symbol-description': 'error',
+ 'unicode-bom': ['error', 'never'],
+ 'use-isnan': ['error', {
+ enforceForSwitchCase: true,
+ enforceForIndexOf: true,
+ }],
+ 'valid-typeof': ['error', { requireStringLiterals: true }],
+ yoda: ['error', 'never'],
- indent: ['error', 2, {
+ '@stylistic/array-bracket-spacing': ['error', 'never'],
+ '@stylistic/arrow-spacing': ['error', { before: true, after: true }],
+ '@stylistic/block-spacing': ['error', 'always'],
+ '@stylistic/brace-style': ['error', '1tbs', { allowSingleLine: true }],
+ camelcase: ['error', {
+ allow: ['^UNSAFE_'],
+ properties: 'never',
+ ignoreGlobals: true,
+ }],
+ '@stylistic/comma-dangle': ['error', 'always-multiline'],
+ '@stylistic/comma-spacing': ['error', { before: false, after: true }],
+ '@stylistic/comma-style': ['error', 'last'],
+ '@stylistic/computed-property-spacing': ['error', 'never', { enforceForClassMembers: true }],
+ '@stylistic/dot-location': ['error', 'property'],
+ '@stylistic/eol-last': 'error',
+ '@stylistic/func-call-spacing': ['error', 'never'],
+ '@stylistic/generator-star-spacing': ['error', { before: true, after: true }],
+ '@stylistic/indent': ['error', 2, {
SwitchCase: 1,
VariableDeclarator: {
- var: 2
+ var: 2,
},
- outerIIFEBody: 0
+ outerIIFEBody: 0,
}],
-
- 'operator-linebreak': ['error', 'before', {
+ '@stylistic/key-spacing': ['error', { beforeColon: false, afterColon: true }],
+ '@stylistic/keyword-spacing': ['error', { before: true, after: true }],
+ '@stylistic/lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: true }],
+ '@stylistic/multiline-ternary': ['error', 'always-multiline'],
+ '@stylistic/new-parens': 'error',
+ '@stylistic/no-extra-semi': 'error',
+ '@stylistic/no-extra-parens': ['error', 'functions'],
+ '@stylistic/no-floating-decimal': 'error',
+ '@stylistic/no-mixed-operators': ['error', {
+ groups: [
+ ['==', '!=', '===', '!==', '>', '>=', '<', '<='],
+ ['&&', '||'],
+ ['in', 'instanceof'],
+ ],
+ allowSamePrecedence: true,
+ }],
+ '@stylistic/no-mixed-spaces-and-tabs': 'error',
+ '@stylistic/no-multi-spaces': 'error',
+ '@stylistic/no-multiple-empty-lines': ['error', { max: 1, maxBOF: 0, maxEOF: 0 }],
+ '@stylistic/no-tabs': 'error',
+ '@stylistic/no-trailing-spaces': 'error',
+ '@stylistic/no-whitespace-before-property': 'error',
+ '@stylistic/object-curly-newline': ['error', { multiline: true, consistent: true }],
+ '@stylistic/object-curly-spacing': ['error', 'always'],
+ '@stylistic/object-property-newline': ['error', { allowMultiplePropertiesPerLine: true }],
+ '@stylistic/operator-linebreak': ['error', 'before', {
overrides: {
- '=': 'after'
- }
- }],
-
- 'space-before-function-paren': ['error', 'never'],
- 'no-cond-assign': 'off',
- 'no-useless-escape': 'off',
- 'one-var': 'off',
- 'no-control-regex': 'off',
- 'no-prototype-builtins': 'off',
- 'no-extra-semi': 'error',
- 'prefer-const': 'error',
- 'no-var': 'error',
+ '=': 'after',
+ },
+ }],
+ '@stylistic/padded-blocks': ['error', { blocks: 'never', switches: 'never', classes: 'never' }],
+ '@stylistic/quote-props': ['error', 'as-needed'],
+ '@stylistic/quotes': ['error', 'single', { avoidEscape: true, allowTemplateLiterals: false }],
+ '@stylistic/rest-spread-spacing': ['error', 'never'],
+ '@stylistic/semi': ['error', 'always'],
+ '@stylistic/semi-spacing': ['error', { before: false, after: true }],
+ '@stylistic/space-before-blocks': ['error', 'always'],
+ '@stylistic/space-before-function-paren': ['error', 'never'],
+ '@stylistic/space-in-parens': ['error', 'never'],
+ '@stylistic/space-infix-ops': 'error',
+ '@stylistic/space-unary-ops': ['error', { words: true, nonwords: false }],
+ '@stylistic/spaced-comment': ['error', 'always', {
+ line: { markers: ['*package', '!', '/', ',', '='] },
+ block: { balanced: true, markers: ['*package', '!', ',', ':', '::', 'flow-include'], exceptions: ['*'] },
+ }],
+ '@stylistic/template-curly-spacing': ['error', 'never'],
+ '@stylistic/template-tag-spacing': ['error', 'never'],
+ '@stylistic/wrap-iife': ['error', 'any', { functionPrototypeMethods: true }],
+ '@stylistic/yield-star-spacing': ['error', 'both'],
+
+ '@n/handle-callback-err': ['error', '^(err|error)$'],
+ '@n/no-callback-literal': 'error',
+ '@n/no-deprecated-api': 'error',
+ '@n/no-exports-assign': 'error',
+ '@n/no-new-require': 'error',
+ '@n/no-path-concat': 'error',
+ '@n/process-exit-as-throw': 'error',
+
'@typescript-eslint/ban-ts-comment': 'off',
- '@typescript-eslint/no-explicit-any': 'off',
- '@typescript-eslint/no-non-null-assertion': 'off',
- '@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-namespace': 'off',
-
'@typescript-eslint/no-unused-vars': ['error', {
- args: 'none'
- }]
- }
- }
+ args: 'none',
+ }],
+ },
+ },
];
diff --git a/package-lock.json b/package-lock.json
index 780cccbabd..aa6e72abbb 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -21,6 +21,7 @@
"@semantic-release/github": "^10.1.0",
"@semantic-release/npm": "^12.0.1",
"@semantic-release/release-notes-generator": "^14.0.1",
+ "@stylistic/eslint-plugin": "^2.3.0",
"cheerio": "1.0.0-rc.12",
"commonmark": "0.31.0",
"cross-env": "^7.0.3",
@@ -39,7 +40,7 @@
"titleize": "^4.0.0",
"ts-expect": "^1.3.0",
"tslib": "^2.6.3",
- "typescript": "^5.5.2",
+ "typescript": "5.5.2",
"typescript-eslint": "8.0.0-alpha.41"
},
"engines": {
@@ -1407,12 +1408,437 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
+ "node_modules/@stylistic/eslint-plugin": {
+ "version": "2.3.0",
+ "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin/-/eslint-plugin-2.3.0.tgz",
+ "integrity": "sha512-rtiz6u5gRyyEZp36FcF1/gHJbsbT3qAgXZ1qkad6Nr/xJ9wrSJkiSFFQhpYVTIZ7FJNRJurEcumZDCwN9dEI4g==",
+ "dev": true,
+ "dependencies": {
+ "@stylistic/eslint-plugin-js": "2.3.0",
+ "@stylistic/eslint-plugin-jsx": "2.3.0",
+ "@stylistic/eslint-plugin-plus": "2.3.0",
+ "@stylistic/eslint-plugin-ts": "2.3.0",
+ "@types/eslint": "^8.56.10"
+ },
+ "engines": {
+ "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
+ },
+ "peerDependencies": {
+ "eslint": ">=8.40.0"
+ }
+ },
+ "node_modules/@stylistic/eslint-plugin-js": {
+ "version": "2.3.0",
+ "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin-js/-/eslint-plugin-js-2.3.0.tgz",
+ "integrity": "sha512-lQwoiYb0Fs6Yc5QS3uT8+T9CPKK2Eoxc3H8EnYJgM26v/DgtW+1lvy2WNgyBflU+ThShZaHm3a6CdD9QeKx23w==",
+ "dev": true,
+ "dependencies": {
+ "@types/eslint": "^8.56.10",
+ "acorn": "^8.11.3",
+ "eslint-visitor-keys": "^4.0.0",
+ "espree": "^10.0.1"
+ },
+ "engines": {
+ "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
+ },
+ "peerDependencies": {
+ "eslint": ">=8.40.0"
+ }
+ },
+ "node_modules/@stylistic/eslint-plugin-js/node_modules/eslint-visitor-keys": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.0.0.tgz",
+ "integrity": "sha512-OtIRv/2GyiF6o/d8K7MYKKbXrOUBIK6SfkIRM4Z0dY3w+LiQ0vy3F57m0Z71bjbyeiWFiHJ8brqnmE6H6/jEuw==",
+ "dev": true,
+ "engines": {
+ "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/eslint"
+ }
+ },
+ "node_modules/@stylistic/eslint-plugin-jsx": {
+ "version": "2.3.0",
+ "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin-jsx/-/eslint-plugin-jsx-2.3.0.tgz",
+ "integrity": "sha512-tsQ0IEKB195H6X9A4iUSgLLLKBc8gUBWkBIU8tp1/3g2l8stu+PtMQVV/VmK1+3bem5FJCyvfcZIQ/WF1fsizA==",
+ "dev": true,
+ "dependencies": {
+ "@stylistic/eslint-plugin-js": "^2.3.0",
+ "@types/eslint": "^8.56.10",
+ "estraverse": "^5.3.0",
+ "picomatch": "^4.0.2"
+ },
+ "engines": {
+ "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
+ },
+ "peerDependencies": {
+ "eslint": ">=8.40.0"
+ }
+ },
+ "node_modules/@stylistic/eslint-plugin-jsx/node_modules/picomatch": {
+ "version": "4.0.2",
+ "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.2.tgz",
+ "integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==",
+ "dev": true,
+ "engines": {
+ "node": ">=12"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/jonschlinkert"
+ }
+ },
+ "node_modules/@stylistic/eslint-plugin-plus": {
+ "version": "2.3.0",
+ "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin-plus/-/eslint-plugin-plus-2.3.0.tgz",
+ "integrity": "sha512-xboPWGUU5yaPlR+WR57GwXEuY4PSlPqA0C3IdNA/+1o2MuBi95XgDJcZiJ9N+aXsqBXAPIpFFb+WQ7QEHo4f7g==",
+ "dev": true,
+ "dependencies": {
+ "@types/eslint": "^8.56.10",
+ "@typescript-eslint/utils": "^7.12.0"
+ },
+ "peerDependencies": {
+ "eslint": "*"
+ }
+ },
+ "node_modules/@stylistic/eslint-plugin-plus/node_modules/@typescript-eslint/scope-manager": {
+ "version": "7.16.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.16.0.tgz",
+ "integrity": "sha512-8gVv3kW6n01Q6TrI1cmTZ9YMFi3ucDT7i7aI5lEikk2ebk1AEjrwX8MDTdaX5D7fPXMBLvnsaa0IFTAu+jcfOw==",
+ "dev": true,
+ "dependencies": {
+ "@typescript-eslint/types": "7.16.0",
+ "@typescript-eslint/visitor-keys": "7.16.0"
+ },
+ "engines": {
+ "node": "^18.18.0 || >=20.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/typescript-eslint"
+ }
+ },
+ "node_modules/@stylistic/eslint-plugin-plus/node_modules/@typescript-eslint/types": {
+ "version": "7.16.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.16.0.tgz",
+ "integrity": "sha512-fecuH15Y+TzlUutvUl9Cc2XJxqdLr7+93SQIbcZfd4XRGGKoxyljK27b+kxKamjRkU7FYC6RrbSCg0ALcZn/xw==",
+ "dev": true,
+ "engines": {
+ "node": "^18.18.0 || >=20.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/typescript-eslint"
+ }
+ },
+ "node_modules/@stylistic/eslint-plugin-plus/node_modules/@typescript-eslint/typescript-estree": {
+ "version": "7.16.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.16.0.tgz",
+ "integrity": "sha512-a5NTvk51ZndFuOLCh5OaJBELYc2O3Zqxfl3Js78VFE1zE46J2AaVuW+rEbVkQznjkmlzWsUI15BG5tQMixzZLw==",
+ "dev": true,
+ "dependencies": {
+ "@typescript-eslint/types": "7.16.0",
+ "@typescript-eslint/visitor-keys": "7.16.0",
+ "debug": "^4.3.4",
+ "globby": "^11.1.0",
+ "is-glob": "^4.0.3",
+ "minimatch": "^9.0.4",
+ "semver": "^7.6.0",
+ "ts-api-utils": "^1.3.0"
+ },
+ "engines": {
+ "node": "^18.18.0 || >=20.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/typescript-eslint"
+ },
+ "peerDependenciesMeta": {
+ "typescript": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@stylistic/eslint-plugin-plus/node_modules/@typescript-eslint/utils": {
+ "version": "7.16.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.16.0.tgz",
+ "integrity": "sha512-PqP4kP3hb4r7Jav+NiRCntlVzhxBNWq6ZQ+zQwII1y/G/1gdIPeYDCKr2+dH6049yJQsWZiHU6RlwvIFBXXGNA==",
+ "dev": true,
+ "dependencies": {
+ "@eslint-community/eslint-utils": "^4.4.0",
+ "@typescript-eslint/scope-manager": "7.16.0",
+ "@typescript-eslint/types": "7.16.0",
+ "@typescript-eslint/typescript-estree": "7.16.0"
+ },
+ "engines": {
+ "node": "^18.18.0 || >=20.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/typescript-eslint"
+ },
+ "peerDependencies": {
+ "eslint": "^8.56.0"
+ }
+ },
+ "node_modules/@stylistic/eslint-plugin-plus/node_modules/@typescript-eslint/visitor-keys": {
+ "version": "7.16.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.16.0.tgz",
+ "integrity": "sha512-rMo01uPy9C7XxG7AFsxa8zLnWXTF8N3PYclekWSrurvhwiw1eW88mrKiAYe6s53AUY57nTRz8dJsuuXdkAhzCg==",
+ "dev": true,
+ "dependencies": {
+ "@typescript-eslint/types": "7.16.0",
+ "eslint-visitor-keys": "^3.4.3"
+ },
+ "engines": {
+ "node": "^18.18.0 || >=20.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/typescript-eslint"
+ }
+ },
+ "node_modules/@stylistic/eslint-plugin-plus/node_modules/brace-expansion": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz",
+ "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==",
+ "dev": true,
+ "dependencies": {
+ "balanced-match": "^1.0.0"
+ }
+ },
+ "node_modules/@stylistic/eslint-plugin-plus/node_modules/globby": {
+ "version": "11.1.0",
+ "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz",
+ "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==",
+ "dev": true,
+ "dependencies": {
+ "array-union": "^2.1.0",
+ "dir-glob": "^3.0.1",
+ "fast-glob": "^3.2.9",
+ "ignore": "^5.2.0",
+ "merge2": "^1.4.1",
+ "slash": "^3.0.0"
+ },
+ "engines": {
+ "node": ">=10"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/@stylistic/eslint-plugin-plus/node_modules/minimatch": {
+ "version": "9.0.5",
+ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz",
+ "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==",
+ "dev": true,
+ "dependencies": {
+ "brace-expansion": "^2.0.1"
+ },
+ "engines": {
+ "node": ">=16 || 14 >=14.17"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/isaacs"
+ }
+ },
+ "node_modules/@stylistic/eslint-plugin-plus/node_modules/slash": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz",
+ "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==",
+ "dev": true,
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/@stylistic/eslint-plugin-ts": {
+ "version": "2.3.0",
+ "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin-ts/-/eslint-plugin-ts-2.3.0.tgz",
+ "integrity": "sha512-wqOR38/uz/0XPnHX68ftp8sNMSAqnYGjovOTN7w00xnjS6Lxr3Sk7q6AaxWWqbMvOj7V2fQiMC5HWAbTruJsCg==",
+ "dev": true,
+ "dependencies": {
+ "@stylistic/eslint-plugin-js": "2.3.0",
+ "@types/eslint": "^8.56.10",
+ "@typescript-eslint/utils": "^7.12.0"
+ },
+ "engines": {
+ "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
+ },
+ "peerDependencies": {
+ "eslint": ">=8.40.0"
+ }
+ },
+ "node_modules/@stylistic/eslint-plugin-ts/node_modules/@typescript-eslint/scope-manager": {
+ "version": "7.16.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.16.0.tgz",
+ "integrity": "sha512-8gVv3kW6n01Q6TrI1cmTZ9YMFi3ucDT7i7aI5lEikk2ebk1AEjrwX8MDTdaX5D7fPXMBLvnsaa0IFTAu+jcfOw==",
+ "dev": true,
+ "dependencies": {
+ "@typescript-eslint/types": "7.16.0",
+ "@typescript-eslint/visitor-keys": "7.16.0"
+ },
+ "engines": {
+ "node": "^18.18.0 || >=20.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/typescript-eslint"
+ }
+ },
+ "node_modules/@stylistic/eslint-plugin-ts/node_modules/@typescript-eslint/types": {
+ "version": "7.16.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.16.0.tgz",
+ "integrity": "sha512-fecuH15Y+TzlUutvUl9Cc2XJxqdLr7+93SQIbcZfd4XRGGKoxyljK27b+kxKamjRkU7FYC6RrbSCg0ALcZn/xw==",
+ "dev": true,
+ "engines": {
+ "node": "^18.18.0 || >=20.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/typescript-eslint"
+ }
+ },
+ "node_modules/@stylistic/eslint-plugin-ts/node_modules/@typescript-eslint/typescript-estree": {
+ "version": "7.16.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.16.0.tgz",
+ "integrity": "sha512-a5NTvk51ZndFuOLCh5OaJBELYc2O3Zqxfl3Js78VFE1zE46J2AaVuW+rEbVkQznjkmlzWsUI15BG5tQMixzZLw==",
+ "dev": true,
+ "dependencies": {
+ "@typescript-eslint/types": "7.16.0",
+ "@typescript-eslint/visitor-keys": "7.16.0",
+ "debug": "^4.3.4",
+ "globby": "^11.1.0",
+ "is-glob": "^4.0.3",
+ "minimatch": "^9.0.4",
+ "semver": "^7.6.0",
+ "ts-api-utils": "^1.3.0"
+ },
+ "engines": {
+ "node": "^18.18.0 || >=20.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/typescript-eslint"
+ },
+ "peerDependenciesMeta": {
+ "typescript": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@stylistic/eslint-plugin-ts/node_modules/@typescript-eslint/utils": {
+ "version": "7.16.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.16.0.tgz",
+ "integrity": "sha512-PqP4kP3hb4r7Jav+NiRCntlVzhxBNWq6ZQ+zQwII1y/G/1gdIPeYDCKr2+dH6049yJQsWZiHU6RlwvIFBXXGNA==",
+ "dev": true,
+ "dependencies": {
+ "@eslint-community/eslint-utils": "^4.4.0",
+ "@typescript-eslint/scope-manager": "7.16.0",
+ "@typescript-eslint/types": "7.16.0",
+ "@typescript-eslint/typescript-estree": "7.16.0"
+ },
+ "engines": {
+ "node": "^18.18.0 || >=20.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/typescript-eslint"
+ },
+ "peerDependencies": {
+ "eslint": "^8.56.0"
+ }
+ },
+ "node_modules/@stylistic/eslint-plugin-ts/node_modules/@typescript-eslint/visitor-keys": {
+ "version": "7.16.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.16.0.tgz",
+ "integrity": "sha512-rMo01uPy9C7XxG7AFsxa8zLnWXTF8N3PYclekWSrurvhwiw1eW88mrKiAYe6s53AUY57nTRz8dJsuuXdkAhzCg==",
+ "dev": true,
+ "dependencies": {
+ "@typescript-eslint/types": "7.16.0",
+ "eslint-visitor-keys": "^3.4.3"
+ },
+ "engines": {
+ "node": "^18.18.0 || >=20.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/typescript-eslint"
+ }
+ },
+ "node_modules/@stylistic/eslint-plugin-ts/node_modules/brace-expansion": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz",
+ "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==",
+ "dev": true,
+ "dependencies": {
+ "balanced-match": "^1.0.0"
+ }
+ },
+ "node_modules/@stylistic/eslint-plugin-ts/node_modules/globby": {
+ "version": "11.1.0",
+ "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz",
+ "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==",
+ "dev": true,
+ "dependencies": {
+ "array-union": "^2.1.0",
+ "dir-glob": "^3.0.1",
+ "fast-glob": "^3.2.9",
+ "ignore": "^5.2.0",
+ "merge2": "^1.4.1",
+ "slash": "^3.0.0"
+ },
+ "engines": {
+ "node": ">=10"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/@stylistic/eslint-plugin-ts/node_modules/minimatch": {
+ "version": "9.0.5",
+ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz",
+ "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==",
+ "dev": true,
+ "dependencies": {
+ "brace-expansion": "^2.0.1"
+ },
+ "engines": {
+ "node": ">=16 || 14 >=14.17"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/isaacs"
+ }
+ },
+ "node_modules/@stylistic/eslint-plugin-ts/node_modules/slash": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz",
+ "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==",
+ "dev": true,
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/@types/eslint": {
+ "version": "8.56.10",
+ "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.56.10.tgz",
+ "integrity": "sha512-Shavhk87gCtY2fhXDctcfS3e6FdxWkCx1iUZ9eEUbh7rTqlZT0/IzOkCOVt0fCjcFuZ9FPYfuezTBImfHCDBGQ==",
+ "dev": true,
+ "dependencies": {
+ "@types/estree": "*",
+ "@types/json-schema": "*"
+ }
+ },
"node_modules/@types/estree": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz",
"integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==",
"dev": true
},
+ "node_modules/@types/json-schema": {
+ "version": "7.0.15",
+ "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz",
+ "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==",
+ "dev": true
+ },
"node_modules/@types/normalize-package-data": {
"version": "2.4.4",
"resolved": "https://registry.npmjs.org/@types/normalize-package-data/-/normalize-package-data-2.4.4.tgz",
diff --git a/package.json b/package.json
index 30daec186d..7f071b5a7b 100644
--- a/package.json
+++ b/package.json
@@ -62,6 +62,7 @@
"@semantic-release/github": "^10.1.0",
"@semantic-release/npm": "^12.0.1",
"@semantic-release/release-notes-generator": "^14.0.1",
+ "@stylistic/eslint-plugin": "^2.3.0",
"cheerio": "1.0.0-rc.12",
"commonmark": "0.31.0",
"cross-env": "^7.0.3",
diff --git a/rollup.config.js b/rollup.config.js
index db14a6a97e..e17def9feb 100644
--- a/rollup.config.js
+++ b/rollup.config.js
@@ -26,14 +26,14 @@ export default defineConfig([
file: 'lib/marked.esm.js',
format: 'esm',
sourcemap: true,
- banner
+ banner,
},
{
file: 'lib/marked.umd.js',
format: 'umd',
name: 'marked',
sourcemap: true,
- banner
+ banner,
},
{
file: 'marked.min.js',
@@ -47,19 +47,19 @@ export default defineConfig([
if (comment.type === 'comment2') {
return comment.value.includes('Copyright (c)');
}
- }
- }
- })]
+ },
+ },
+ })],
},
{
file: 'lib/marked.cjs',
format: 'cjs',
name: 'marked',
sourcemap: true,
- banner
+ banner,
}],
plugins: [
- typescript()
- ]
- }
+ typescript(),
+ ],
+ },
]);
diff --git a/src/Hooks.ts b/src/Hooks.ts
index 49a80e8f65..967a05e8f0 100644
--- a/src/Hooks.ts
+++ b/src/Hooks.ts
@@ -12,7 +12,7 @@ export class _Hooks {
static passThroughHooks = new Set([
'preprocess',
'postprocess',
- 'processAllTokens'
+ 'processAllTokens',
]);
/**
diff --git a/src/Instance.ts b/src/Instance.ts
index 6788d3ddab..61aa6ef3fe 100644
--- a/src/Instance.ts
+++ b/src/Instance.ts
@@ -7,7 +7,7 @@ import { _Tokenizer } from './Tokenizer.ts';
import { _TextRenderer } from './TextRenderer.ts';
import {
escape,
- unescape
+ unescape,
} from './helpers.ts';
import type { MarkedExtension, MarkedOptions } from './MarkedOptions.ts';
import type { Token, Tokens, TokensList } from './Tokens.ts';
@@ -270,7 +270,7 @@ export class Marked {
this,
renderer.parser.parseInline(token.tokens),
token.depth,
- unescape(renderer.parser.parseInline(token.tokens, renderer.parser.textRenderer))
+ unescape(renderer.parser.parseInline(token.tokens, renderer.parser.textRenderer)),
);
};
case 'code':
@@ -285,7 +285,7 @@ export class Marked {
this,
token.text,
token.lang,
- !!token.escaped
+ !!token.escaped,
);
};
case 'table':
@@ -305,8 +305,8 @@ export class Marked {
text: token.header[j].text,
tokens: token.header[j].tokens,
header: true,
- align: token.align[j]
- }
+ align: token.align[j],
+ },
);
}
header += this.tablerow({ text: cell });
@@ -322,8 +322,8 @@ export class Marked {
text: row[k].text,
tokens: row[k].tokens,
header: false,
- align: token.align[k]
- }
+ align: token.align[k],
+ },
);
}
@@ -373,7 +373,7 @@ export class Marked {
} else {
item.tokens.unshift({
type: 'text',
- text: checkbox + ' '
+ text: checkbox + ' ',
} as Tokens.Text);
}
} else {
@@ -389,7 +389,7 @@ export class Marked {
task,
checked: !!checked,
loose,
- tokens: item.tokens
+ tokens: item.tokens,
});
}
diff --git a/src/Lexer.ts b/src/Lexer.ts
index dc2cea1231..d600922bd7 100644
--- a/src/Lexer.ts
+++ b/src/Lexer.ts
@@ -17,7 +17,7 @@ export class _Lexer {
};
private tokenizer: _Tokenizer;
- private inlineQueue: {src: string, tokens: Token[]}[];
+ private inlineQueue: { src: string, tokens: Token[] }[];
constructor(options?: MarkedOptions) {
// TokenList cannot be created in one go
@@ -32,12 +32,12 @@ export class _Lexer {
this.state = {
inLink: false,
inRawBlock: false,
- top: true
+ top: true,
};
const rules = {
block: block.normal,
- inline: inline.normal
+ inline: inline.normal,
};
if (this.options.pedantic) {
@@ -60,7 +60,7 @@ export class _Lexer {
static get rules() {
return {
block,
- inline
+ inline,
};
}
@@ -211,7 +211,7 @@ export class _Lexer {
} else if (!this.tokens.links[token.tag]) {
this.tokens.links[token.tag] = {
href: token.href,
- title: token.title
+ title: token.title,
};
}
continue;
diff --git a/src/Parser.ts b/src/Parser.ts
index dfac9b6d54..8a6716196d 100644
--- a/src/Parser.ts
+++ b/src/Parser.ts
@@ -106,7 +106,7 @@ export class _Parser {
type: 'paragraph',
raw: body,
text: body,
- tokens: [{ type: 'text', raw: body, text: body }]
+ tokens: [{ type: 'text', raw: body, text: body }],
});
} else {
out += body;
diff --git a/src/Renderer.ts b/src/Renderer.ts
index b790803a90..c2a2645ced 100644
--- a/src/Renderer.ts
+++ b/src/Renderer.ts
@@ -1,7 +1,7 @@
import { _defaults } from './defaults.ts';
import {
cleanUrl,
- escape
+ escape,
} from './helpers.ts';
import type { MarkedOptions } from './MarkedOptions.ts';
import type { Tokens } from './Tokens.ts';
@@ -85,7 +85,7 @@ export class _Renderer {
item.tokens.unshift({
type: 'text',
raw: checkbox + ' ',
- text: checkbox + ' '
+ text: checkbox + ' ',
});
}
} else {
diff --git a/src/Tokenizer.ts b/src/Tokenizer.ts
index b4516148ef..5ad91c61e1 100644
--- a/src/Tokenizer.ts
+++ b/src/Tokenizer.ts
@@ -3,7 +3,7 @@ import {
rtrim,
splitCells,
escape,
- findClosingBracket
+ findClosingBracket,
} from './helpers.ts';
import type { Rules } from './rules.ts';
import type { _Lexer } from './Lexer.ts';
@@ -23,7 +23,7 @@ function outputLink(cap: string[], link: Pick, ra
href,
title,
text,
- tokens: lexer.inlineTokens(text)
+ tokens: lexer.inlineTokens(text),
};
lexer.state.inLink = false;
return token;
@@ -33,7 +33,7 @@ function outputLink(cap: string[], link: Pick, ra
raw,
href,
title,
- text: escape(text)
+ text: escape(text),
};
}
@@ -82,7 +82,7 @@ export class _Tokenizer {
if (cap && cap[0].length > 0) {
return {
type: 'space',
- raw: cap[0]
+ raw: cap[0],
};
}
}
@@ -97,7 +97,7 @@ export class _Tokenizer {
codeBlockStyle: 'indented',
text: !this.options.pedantic
? rtrim(text, '\n')
- : text
+ : text,
};
}
}
@@ -112,7 +112,7 @@ export class _Tokenizer {
type: 'code',
raw,
lang: cap[2] ? cap[2].trim().replace(this.rules.inline.anyPunctuation, '$1') : cap[2],
- text
+ text,
};
}
}
@@ -138,7 +138,7 @@ export class _Tokenizer {
raw: cap[0],
depth: cap[1].length,
text,
- tokens: this.lexer.inline(text)
+ tokens: this.lexer.inline(text),
};
}
}
@@ -148,7 +148,7 @@ export class _Tokenizer {
if (cap) {
return {
type: 'hr',
- raw: rtrim(cap[0], '\n')
+ raw: rtrim(cap[0], '\n'),
};
}
}
@@ -232,7 +232,7 @@ export class _Tokenizer {
type: 'blockquote',
raw,
tokens,
- text
+ text,
};
}
}
@@ -249,7 +249,7 @@ export class _Tokenizer {
ordered: isordered,
start: isordered ? +bull.slice(0, -1) : '',
loose: false,
- items: []
+ items: [],
};
bull = isordered ? `\\d{1,9}\\${bull.slice(-1)}` : `\\${bull}`;
@@ -398,7 +398,7 @@ export class _Tokenizer {
checked: ischecked,
loose: false,
text: itemContents,
- tokens: []
+ tokens: [],
});
list.raw += raw;
@@ -442,7 +442,7 @@ export class _Tokenizer {
block: true,
raw: cap[0],
pre: cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style',
- text: cap[0]
+ text: cap[0],
};
return token;
}
@@ -459,7 +459,7 @@ export class _Tokenizer {
tag,
raw: cap[0],
href,
- title
+ title,
};
}
}
@@ -484,7 +484,7 @@ export class _Tokenizer {
raw: cap[0],
header: [],
align: [],
- rows: []
+ rows: [],
};
if (headers.length !== aligns.length) {
@@ -509,7 +509,7 @@ export class _Tokenizer {
text: headers[i],
tokens: this.lexer.inline(headers[i]),
header: true,
- align: item.align[i]
+ align: item.align[i],
});
}
@@ -519,7 +519,7 @@ export class _Tokenizer {
text: cell,
tokens: this.lexer.inline(cell),
header: false,
- align: item.align[i]
+ align: item.align[i],
};
}));
}
@@ -535,7 +535,7 @@ export class _Tokenizer {
raw: cap[0],
depth: cap[2].charAt(0) === '=' ? 1 : 2,
text: cap[1],
- tokens: this.lexer.inline(cap[1])
+ tokens: this.lexer.inline(cap[1]),
};
}
}
@@ -550,7 +550,7 @@ export class _Tokenizer {
type: 'paragraph',
raw: cap[0],
text,
- tokens: this.lexer.inline(text)
+ tokens: this.lexer.inline(text),
};
}
}
@@ -562,7 +562,7 @@ export class _Tokenizer {
type: 'text',
raw: cap[0],
text: cap[0],
- tokens: this.lexer.inline(cap[0])
+ tokens: this.lexer.inline(cap[0]),
};
}
}
@@ -573,7 +573,7 @@ export class _Tokenizer {
return {
type: 'escape',
raw: cap[0],
- text: escape(cap[1])
+ text: escape(cap[1]),
};
}
}
@@ -598,7 +598,7 @@ export class _Tokenizer {
inLink: this.lexer.state.inLink,
inRawBlock: this.lexer.state.inRawBlock,
block: false,
- text: cap[0]
+ text: cap[0],
};
}
}
@@ -654,7 +654,7 @@ export class _Tokenizer {
}
return outputLink(cap, {
href: href ? href.replace(this.rules.inline.anyPunctuation, '$1') : href,
- title: title ? title.replace(this.rules.inline.anyPunctuation, '$1') : title
+ title: title ? title.replace(this.rules.inline.anyPunctuation, '$1') : title,
}, cap[0], this.lexer);
}
}
@@ -670,7 +670,7 @@ export class _Tokenizer {
return {
type: 'text',
raw: text,
- text
+ text,
};
}
return outputLink(cap, link, cap[0], this.lexer);
@@ -731,7 +731,7 @@ export class _Tokenizer {
type: 'em',
raw,
text,
- tokens: this.lexer.inlineTokens(text)
+ tokens: this.lexer.inlineTokens(text),
};
}
@@ -741,7 +741,7 @@ export class _Tokenizer {
type: 'strong',
raw,
text,
- tokens: this.lexer.inlineTokens(text)
+ tokens: this.lexer.inlineTokens(text),
};
}
}
@@ -760,7 +760,7 @@ export class _Tokenizer {
return {
type: 'codespan',
raw: cap[0],
- text
+ text,
};
}
}
@@ -770,7 +770,7 @@ export class _Tokenizer {
if (cap) {
return {
type: 'br',
- raw: cap[0]
+ raw: cap[0],
};
}
}
@@ -782,7 +782,7 @@ export class _Tokenizer {
type: 'del',
raw: cap[0],
text: cap[2],
- tokens: this.lexer.inlineTokens(cap[2])
+ tokens: this.lexer.inlineTokens(cap[2]),
};
}
}
@@ -808,9 +808,9 @@ export class _Tokenizer {
{
type: 'text',
raw: text,
- text
- }
- ]
+ text,
+ },
+ ],
};
}
}
@@ -845,9 +845,9 @@ export class _Tokenizer {
{
type: 'text',
raw: text,
- text
- }
- ]
+ text,
+ },
+ ],
};
}
}
@@ -864,7 +864,7 @@ export class _Tokenizer {
return {
type: 'text',
raw: cap[0],
- text
+ text,
};
}
}
diff --git a/src/Tokens.ts b/src/Tokens.ts
index 1dd5a9ea3f..e5f8402e6a 100644
--- a/src/Tokens.ts
+++ b/src/Tokens.ts
@@ -28,188 +28,189 @@ export type Token = (
| Tokens.Generic);
export namespace Tokens {
- export interface Space {
- type: 'space';
- raw: string;
- }
-
- export interface Code {
- type: 'code';
- raw: string;
- codeBlockStyle?: 'indented' | undefined;
- lang?: string | undefined;
- text: string;
- escaped?: boolean;
- }
-
- export interface Heading {
- type: 'heading';
- raw: string;
- depth: number;
- text: string;
- tokens: Token[];
- }
-
- export interface Table {
- type: 'table';
- raw: string;
- align: Array<'center' | 'left' | 'right' | null>;
- header: TableCell[];
- rows: TableCell[][];
- }
-
- export interface TableRow {
- text: string;
- }
-
- export interface TableCell {
- text: string;
- tokens: Token[];
- header: boolean;
- align: 'center' | 'left' | 'right' | null;
- }
-
- export interface Hr {
- type: 'hr';
- raw: string;
- }
-
- export interface Blockquote {
- type: 'blockquote';
- raw: string;
- text: string;
- tokens: Token[];
- }
-
- export interface List {
- type: 'list';
- raw: string;
- ordered: boolean;
- start: number | '';
- loose: boolean;
- items: ListItem[];
- }
-
- export interface ListItem {
- type: 'list_item';
- raw: string;
- task: boolean;
- checked?: boolean | undefined;
- loose: boolean;
- text: string;
- tokens: Token[];
- }
-
- export interface Checkbox {
- checked: boolean;
- }
-
- export interface Paragraph {
- type: 'paragraph';
- raw: string;
- pre?: boolean | undefined;
- text: string;
- tokens: Token[];
- }
-
- export interface HTML {
- type: 'html';
- raw: string;
- pre: boolean;
- text: string;
- block: boolean;
- }
-
- export interface Text {
- type: 'text';
- raw: string;
- text: string;
- tokens?: Token[];
- }
-
- export interface Def {
- type: 'def';
- raw: string;
- tag: string;
- href: string;
- title: string;
- }
-
- export interface Escape {
- type: 'escape';
- raw: string;
- text: string;
- }
-
- export interface Tag {
- type: 'text' | 'html';
- raw: string;
- inLink: boolean;
- inRawBlock: boolean;
- text: string;
- block: boolean;
- }
-
- export interface Link {
- type: 'link';
- raw: string;
- href: string;
- title?: string | null;
- text: string;
- tokens: Token[];
- }
-
- export interface Image {
- type: 'image';
- raw: string;
- href: string;
- title: string | null;
- text: string;
- }
-
- export interface Strong {
- type: 'strong';
- raw: string;
- text: string;
- tokens: Token[];
- }
-
- export interface Em {
- type: 'em';
- raw: string;
- text: string;
- tokens: Token[];
- }
-
- export interface Codespan {
- type: 'codespan';
- raw: string;
- text: string;
- }
-
- export interface Br {
- type: 'br';
- raw: string;
- }
-
- export interface Del {
- type: 'del';
- raw: string;
- text: string;
- tokens: Token[];
- }
-
- export interface Generic {
- [index: string]: any;
-
- type: string;
- raw: string;
- tokens?: Token[] | undefined;
- }
+ export interface Space {
+ type: 'space';
+ raw: string;
+ }
+
+ export interface Code {
+ type: 'code';
+ raw: string;
+ codeBlockStyle?: 'indented' | undefined;
+ lang?: string | undefined;
+ text: string;
+ escaped?: boolean;
+ }
+
+ export interface Heading {
+ type: 'heading';
+ raw: string;
+ depth: number;
+ text: string;
+ tokens: Token[];
+ }
+
+ export interface Table {
+ type: 'table';
+ raw: string;
+ align: Array<'center' | 'left' | 'right' | null>;
+ header: TableCell[];
+ rows: TableCell[][];
+ }
+
+ export interface TableRow {
+ text: string;
+ }
+
+ export interface TableCell {
+ text: string;
+ tokens: Token[];
+ header: boolean;
+ align: 'center' | 'left' | 'right' | null;
+ }
+
+ export interface Hr {
+ type: 'hr';
+ raw: string;
+ }
+
+ export interface Blockquote {
+ type: 'blockquote';
+ raw: string;
+ text: string;
+ tokens: Token[];
+ }
+
+ export interface List {
+ type: 'list';
+ raw: string;
+ ordered: boolean;
+ start: number | '';
+ loose: boolean;
+ items: ListItem[];
+ }
+
+ export interface ListItem {
+ type: 'list_item';
+ raw: string;
+ task: boolean;
+ checked?: boolean | undefined;
+ loose: boolean;
+ text: string;
+ tokens: Token[];
+ }
+
+ export interface Checkbox {
+ checked: boolean;
+ }
+
+ export interface Paragraph {
+ type: 'paragraph';
+ raw: string;
+ pre?: boolean | undefined;
+ text: string;
+ tokens: Token[];
+ }
+
+ export interface HTML {
+ type: 'html';
+ raw: string;
+ pre: boolean;
+ text: string;
+ block: boolean;
+ }
+
+ export interface Text {
+ type: 'text';
+ raw: string;
+ text: string;
+ tokens?: Token[];
+ }
+
+ export interface Def {
+ type: 'def';
+ raw: string;
+ tag: string;
+ href: string;
+ title: string;
+ }
+
+ export interface Escape {
+ type: 'escape';
+ raw: string;
+ text: string;
+ }
+
+ export interface Tag {
+ type: 'text' | 'html';
+ raw: string;
+ inLink: boolean;
+ inRawBlock: boolean;
+ text: string;
+ block: boolean;
+ }
+
+ export interface Link {
+ type: 'link';
+ raw: string;
+ href: string;
+ title?: string | null;
+ text: string;
+ tokens: Token[];
+ }
+
+ export interface Image {
+ type: 'image';
+ raw: string;
+ href: string;
+ title: string | null;
+ text: string;
+ }
+
+ export interface Strong {
+ type: 'strong';
+ raw: string;
+ text: string;
+ tokens: Token[];
+ }
+
+ export interface Em {
+ type: 'em';
+ raw: string;
+ text: string;
+ tokens: Token[];
+ }
+
+ export interface Codespan {
+ type: 'codespan';
+ raw: string;
+ text: string;
+ }
+
+ export interface Br {
+ type: 'br';
+ raw: string;
+ }
+
+ export interface Del {
+ type: 'del';
+ raw: string;
+ text: string;
+ tokens: Token[];
+ }
+
+ export interface Generic {
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ [index: string]: any;
+
+ type: string;
+ raw: string;
+ tokens?: Token[] | undefined;
+ }
}
export type Links = Record>;
export type TokensList = Token[] & {
- links: Links;
+ links: Links;
};
diff --git a/src/defaults.ts b/src/defaults.ts
index c99b4013a4..81b6fba90f 100644
--- a/src/defaults.ts
+++ b/src/defaults.ts
@@ -14,7 +14,7 @@ export function _getDefaults(): MarkedOptions {
renderer: null,
silent: false,
tokenizer: null,
- walkTokens: null
+ walkTokens: null,
};
}
diff --git a/src/helpers.ts b/src/helpers.ts
index 8ebac8f5c7..812fd22563 100644
--- a/src/helpers.ts
+++ b/src/helpers.ts
@@ -5,12 +5,12 @@ const escapeTest = /[&<>"']/;
const escapeReplace = new RegExp(escapeTest.source, 'g');
const escapeTestNoEncode = /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/;
const escapeReplaceNoEncode = new RegExp(escapeTestNoEncode.source, 'g');
-const escapeReplacements: {[index: string]: string} = {
+const escapeReplacements: { [index: string]: string } = {
'&': '&',
'<': '<',
'>': '>',
'"': '"',
- "'": '''
+ "'": ''',
};
const getEscapeReplacement = (ch: string) => escapeReplacements[ch];
@@ -58,7 +58,7 @@ export function edit(regex: string | RegExp, opt?: string) {
},
getRegex: () => {
return new RegExp(source, opt);
- }
+ },
};
return obj;
}
diff --git a/src/marked.ts b/src/marked.ts
index 51fe97ee78..ac83640ae5 100644
--- a/src/marked.ts
+++ b/src/marked.ts
@@ -8,7 +8,7 @@ import { Marked } from './Instance.ts';
import {
_getDefaults,
changeDefaults,
- _defaults
+ _defaults,
} from './defaults.ts';
import type { MarkedExtension, MarkedOptions } from './MarkedOptions.ts';
import type { Token, TokensList } from './Tokens.ts';
diff --git a/src/rules.ts b/src/rules.ts
index 07f0990e84..d6f330ed39 100644
--- a/src/rules.ts
+++ b/src/rules.ts
@@ -1,5 +1,5 @@
import {
- edit, noopTest
+ edit, noopTest,
} from './helpers.ts';
/**
@@ -88,7 +88,7 @@ const blockNormal = {
newline,
paragraph,
table: noopTest,
- text: blockText
+ text: blockText,
};
type BlockKeys = keyof typeof blockNormal;
@@ -124,7 +124,7 @@ const blockGfm: Record = {
.replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
.replace('html', '?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)')
.replace('tag', _tag) // pars can be interrupted by type (6) html blocks
- .getRegex()
+ .getRegex(),
};
/**
@@ -157,7 +157,7 @@ const blockPedantic: Record = {
.replace('|list', '')
.replace('|html', '')
.replace('|tag', '')
- .getRegex()
+ .getRegex(),
};
/**
@@ -271,7 +271,7 @@ const inlineNormal = {
reflinkSearch,
tag,
text: inlineText,
- url: noopTest
+ url: noopTest,
};
type InlineKeys = keyof typeof inlineNormal;
@@ -287,7 +287,7 @@ const inlinePedantic: Record = {
.getRegex(),
reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/)
.replace('label', _inlineLabel)
- .getRegex()
+ .getRegex(),
};
/**
@@ -302,7 +302,7 @@ const inlineGfm: Record = {
.getRegex(),
_backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
del: /^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,
- text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\ = {
text: edit(inlineGfm.text)
.replace('\\b_', '\\b_| {2,}\\n')
.replace(/\{2,\}/g, '*')
- .getRegex()
+ .getRegex(),
};
/**
@@ -325,14 +325,14 @@ const inlineBreaks: Record = {
export const block = {
normal: blockNormal,
gfm: blockGfm,
- pedantic: blockPedantic
+ pedantic: blockPedantic,
};
export const inline = {
normal: inlineNormal,
gfm: inlineGfm,
breaks: inlineBreaks,
- pedantic: inlinePedantic
+ pedantic: inlinePedantic,
};
export interface Rules {
diff --git a/test/bench.js b/test/bench.js
index e878a333cc..d7455215fc 100644
--- a/test/bench.js
+++ b/test/bench.js
@@ -36,7 +36,7 @@ export async function runBench(options) {
cjsMarked.setOptions({
gfm: false,
breaks: false,
- pedantic: false
+ pedantic: false,
});
if (options.marked) {
cjsMarked.setOptions(options.marked);
@@ -46,7 +46,7 @@ export async function runBench(options) {
esmMarked.setOptions({
gfm: false,
breaks: false,
- pedantic: false
+ pedantic: false,
});
if (options.marked) {
esmMarked.setOptions(options.marked);
@@ -84,7 +84,7 @@ export async function bench(tests, specs) {
for (const name in tests) {
stats[name] = {
elapsed: 0n,
- correct: 0
+ correct: 0,
};
}
@@ -94,7 +94,7 @@ export async function bench(tests, specs) {
process.stdout.write(
`${((i * 100) / specs.length).toFixed(1).padStart(5)}% ${i
.toString()
- .padStart(specs.length.toString().length)} of ${specs.length}\r`
+ .padStart(specs.length.toString().length)} of ${specs.length}\r`,
);
for (const name in tests) {
const test = tests[name];
@@ -106,7 +106,7 @@ export async function bench(tests, specs) {
stats[name].elapsed += after - before;
stats[name].correct += (await htmlIsEqual(
spec.html,
- await test(spec.markdown)
+ await test(spec.markdown),
))
? 1
: 0;
@@ -165,7 +165,7 @@ function parseArg(argv) {
const arg = getArg();
if (arg.indexOf('--') === 0) {
const opt = camelize(arg.replace(/^--(no-)?/, ''));
- if (!defaults.hasOwnProperty(opt)) {
+ if (!(opt in defaults)) {
continue;
}
options.marked = options.marked || {};
diff --git a/test/recheck.js b/test/recheck.js
index 35deec9190..adb2a11e41 100644
--- a/test/recheck.js
+++ b/test/recheck.js
@@ -34,7 +34,7 @@ const start = Date.now();
await Promise.all([
checkRegexp(inline, 'inline'),
- checkRegexp(block, 'block')
+ checkRegexp(block, 'block'),
]);
console.log(`
diff --git a/test/rules.js b/test/rules.js
index 930edf706c..0072dcf92b 100644
--- a/test/rules.js
+++ b/test/rules.js
@@ -26,7 +26,7 @@ const COLOR = {
bgBlue: '\x1b[44m',
bgMagenta: '\x1b[45m',
bgCyan: '\x1b[46m',
- bgWhite: '\x1b[47m'
+ bgWhite: '\x1b[47m',
};
function propsToString(obj) {
diff --git a/test/run-spec-tests.js b/test/run-spec-tests.js
index d42bfcb9f8..d586d6b8d9 100644
--- a/test/run-spec-tests.js
+++ b/test/run-spec-tests.js
@@ -16,35 +16,35 @@ const [commonMarkTests, gfmTests, newTests, originalTests, redosTests] =
resolve(__dirname, './specs/gfm'),
resolve(__dirname, './specs/new'),
resolve(__dirname, './specs/original'),
- resolve(__dirname, './specs/redos')
+ resolve(__dirname, './specs/redos'),
]);
outputCompletionTable('CommonMark', commonMarkTests);
runTests({
tests: commonMarkTests,
parse,
- defaultMarkedOptions: { gfm: false, pedantic: false }
+ defaultMarkedOptions: { gfm: false, pedantic: false },
});
outputCompletionTable('GFM', gfmTests);
runTests({
tests: gfmTests,
parse,
- defaultMarkedOptions: { gfm: true, pedantic: false }
+ defaultMarkedOptions: { gfm: true, pedantic: false },
});
runTests({
tests: newTests,
- parse
+ parse,
});
runTests({
tests: originalTests,
parse,
- defaultMarkedOptions: { gfm: false, pedantic: true }
+ defaultMarkedOptions: { gfm: false, pedantic: true },
});
runTests({
tests: redosTests,
- parse
+ parse,
});
diff --git a/test/specs/redos/cubic_def.cjs b/test/specs/redos/cubic_def.cjs
index 9cc38ef567..eb3110bc86 100644
--- a/test/specs/redos/cubic_def.cjs
+++ b/test/specs/redos/cubic_def.cjs
@@ -1,4 +1,4 @@
module.exports = {
markdown: `[x]:${' '.repeat(1500)}x ${' '.repeat(1500)} x`,
- html: `[x]:${' '.repeat(1500)}x ${' '.repeat(1500)} x
`
+ html: `[x]:${' '.repeat(1500)}x ${' '.repeat(1500)} x
`,
};
diff --git a/test/specs/redos/quadratic_br.cjs b/test/specs/redos/quadratic_br.cjs
index 48456b8a14..4845c2333c 100644
--- a/test/specs/redos/quadratic_br.cjs
+++ b/test/specs/redos/quadratic_br.cjs
@@ -1,4 +1,4 @@
module.exports = {
markdown: `a${' '.repeat(50000)}`,
- html: `a${' '.repeat(50000)}
`
+ html: `a${' '.repeat(50000)}
`,
};
diff --git a/test/specs/redos/quadratic_em_mask.cjs b/test/specs/redos/quadratic_em_mask.cjs
index e71155e1a4..9cee0ac60e 100644
--- a/test/specs/redos/quadratic_em_mask.cjs
+++ b/test/specs/redos/quadratic_em_mask.cjs
@@ -1,18 +1,18 @@
module.exports = [
{
markdown: '['.repeat(100000),
- html: `${'['.repeat(100000)}
`
+ html: `${'['.repeat(100000)}
`,
},
{
markdown: '[.'.repeat(50000),
- html: `${'[.'.repeat(50000)}
`
+ html: `${'[.'.repeat(50000)}
`,
},
{
markdown: '<'.repeat(100000),
- html: `${'<'.repeat(100000)}
`
+ html: `${'<'.repeat(100000)}
`,
},
{
markdown: '<.'.repeat(50000),
- html: `${'<.'.repeat(50000)}
`
- }
+ html: `${'<.'.repeat(50000)}
`,
+ },
];
diff --git a/test/specs/redos/quadratic_email.cjs b/test/specs/redos/quadratic_email.cjs
index 08243fe5fa..cc458b5043 100644
--- a/test/specs/redos/quadratic_email.cjs
+++ b/test/specs/redos/quadratic_email.cjs
@@ -1,4 +1,4 @@
module.exports = {
markdown: 'a'.repeat(50000),
- html: `${'a'.repeat(50000)}
`
+ html: `${'a'.repeat(50000)}
`,
};
diff --git a/test/specs/redos/quadratic_heading.cjs b/test/specs/redos/quadratic_heading.cjs
index 7aab963155..73de9cfec1 100644
--- a/test/specs/redos/quadratic_heading.cjs
+++ b/test/specs/redos/quadratic_heading.cjs
@@ -1,4 +1,4 @@
module.exports = {
markdown: `# #${' '.repeat(50000)}a`,
- html: '# a
'
+ html: '# a
',
};
diff --git a/test/specs/redos/quadratic_lists.cjs b/test/specs/redos/quadratic_lists.cjs
index 8d230ca5af..a96aa5cd23 100644
--- a/test/specs/redos/quadratic_lists.cjs
+++ b/test/specs/redos/quadratic_lists.cjs
@@ -1,4 +1,4 @@
module.exports = {
markdown: '- a\n'.repeat(10000),
- html: ``
+ html: ``,
};
diff --git a/test/specs/redos/quadratic_underscores.cjs b/test/specs/redos/quadratic_underscores.cjs
index a695488e09..692f3cff25 100644
--- a/test/specs/redos/quadratic_underscores.cjs
+++ b/test/specs/redos/quadratic_underscores.cjs
@@ -1,4 +1,4 @@
module.exports = {
markdown: `${'_'.repeat(101)} a`,
- html: `${'_'.repeat(101)} a
`
+ html: `${'_'.repeat(101)} a
`,
};
diff --git a/test/unit/Hooks.test.js b/test/unit/Hooks.test.js
index f3dfaf9035..8907633069 100644
--- a/test/unit/Hooks.test.js
+++ b/test/unit/Hooks.test.js
@@ -10,8 +10,8 @@ function createHeadingToken(text) {
depth: 1,
text,
tokens: [
- { type: 'text', raw: text, text }
- ]
+ { type: 'text', raw: text, text },
+ ],
};
}
@@ -26,8 +26,8 @@ describe('Hooks', () => {
hooks: {
preprocess(markdown) {
return `# preprocess\n\n${markdown}`;
- }
- }
+ },
+ },
});
const html = marked.parse('*text*');
assert.strictEqual(html.trim(), 'preprocess
\ntext
');
@@ -40,8 +40,8 @@ describe('Hooks', () => {
async preprocess(markdown) {
await timeout();
return `# preprocess async\n\n${markdown}`;
- }
- }
+ },
+ },
});
const promise = marked.parse('*text*');
assert.ok(promise instanceof Promise);
@@ -55,8 +55,8 @@ describe('Hooks', () => {
preprocess(markdown) {
this.options.breaks = true;
return markdown;
- }
- }
+ },
+ },
});
const html = marked.parse('line1\nline2');
assert.strictEqual(html.trim(), 'line1
line2
');
@@ -70,8 +70,8 @@ describe('Hooks', () => {
await timeout();
this.options.breaks = true;
return markdown;
- }
- }
+ },
+ },
});
const html = await marked.parse('line1\nline2');
assert.strictEqual(html.trim(), 'line1
line2
');
@@ -82,8 +82,8 @@ describe('Hooks', () => {
hooks: {
postprocess(html) {
return html + 'postprocess
';
- }
- }
+ },
+ },
});
const html = marked.parse('*text*');
assert.strictEqual(html.trim(), 'text
\npostprocess
');
@@ -96,8 +96,8 @@ describe('Hooks', () => {
async postprocess(html) {
await timeout();
return html + 'postprocess async
\n';
- }
- }
+ },
+ },
});
const promise = marked.parse('*text*');
assert.ok(promise instanceof Promise);
@@ -111,14 +111,14 @@ describe('Hooks', () => {
processAllTokens(tokens) {
tokens.push(createHeadingToken('processAllTokens'));
return tokens;
- }
+ },
},
walkTokens(token) {
if (token.type === 'heading') {
token.tokens[0].text += ' walked';
}
return token;
- }
+ },
});
const html = marked.parse('*text*');
assert.strictEqual(html.trim(), 'text
\nprocessAllTokens walked
');
@@ -132,14 +132,14 @@ describe('Hooks', () => {
await timeout();
tokens.push(createHeadingToken('processAllTokens async'));
return tokens;
- }
+ },
},
walkTokens(token) {
if (token.type === 'heading') {
token.tokens[0].text += ' walked';
}
return token;
- }
+ },
});
const promise = marked.parse('*text*');
assert.ok(promise instanceof Promise);
@@ -159,8 +159,8 @@ describe('Hooks', () => {
processAllTokens(tokens) {
tokens.push(createHeadingToken('processAllTokens1'));
return tokens;
- }
- }
+ },
+ },
});
marked.use({
async: true,
@@ -175,8 +175,8 @@ describe('Hooks', () => {
processAllTokens(tokens) {
tokens.push(createHeadingToken('processAllTokens2'));
return tokens;
- }
- }
+ },
+ },
});
const promise = marked.parse('*text*');
assert.ok(promise instanceof Promise);
diff --git a/test/unit/Lexer.test.js b/test/unit/Lexer.test.js
index fbf932090a..82a2d6df65 100644
--- a/test/unit/Lexer.test.js
+++ b/test/unit/Lexer.test.js
@@ -11,7 +11,7 @@ function expectTokens({ md, options, tokens = [], links = {}, log = false }) {
console.log(JSON.stringify(
actual,
(k, v) => v === undefined ? null : v,
- 2
+ 2,
));
}
assert.deepEqual(actual, expected);
@@ -35,16 +35,16 @@ describe('Lexer', () => {
type: 'paragraph',
raw: 'paragraph 1',
text: 'paragraph 1',
- tokens: [{ type: 'text', raw: 'paragraph 1', text: 'paragraph 1' }]
+ tokens: [{ type: 'text', raw: 'paragraph 1', text: 'paragraph 1' }],
},
{ type: 'space', raw: '\n\n' },
{
type: 'paragraph',
raw: 'paragraph 2',
text: 'paragraph 2',
- tokens: [{ type: 'text', raw: 'paragraph 2', text: 'paragraph 2' }]
- }
- ]
+ tokens: [{ type: 'text', raw: 'paragraph 2', text: 'paragraph 2' }],
+ },
+ ],
});
});
});
@@ -54,8 +54,8 @@ describe('Lexer', () => {
expectTokens({
md: ' code',
tokens: [
- { type: 'code', raw: ' code', text: 'code', codeBlockStyle: 'indented' }
- ]
+ { type: 'code', raw: ' code', text: 'code', codeBlockStyle: 'indented' },
+ ],
});
});
@@ -63,8 +63,8 @@ describe('Lexer', () => {
expectTokens({
md: '```\ncode\n```',
tokens: [
- { type: 'code', raw: '```\ncode\n```', text: 'code', lang: '' }
- ]
+ { type: 'code', raw: '```\ncode\n```', text: 'code', lang: '' },
+ ],
});
});
@@ -72,8 +72,8 @@ describe('Lexer', () => {
expectTokens({
md: '```text\ncode\n```',
tokens: [
- { type: 'code', raw: '```text\ncode\n```', text: 'code', lang: 'text' }
- ]
+ { type: 'code', raw: '```text\ncode\n```', text: 'code', lang: 'text' },
+ ],
});
});
});
@@ -103,65 +103,65 @@ lheading 2
tokens: [
{
type: 'space',
- raw: '\n'
+ raw: '\n',
},
{
type: 'heading',
raw: '# heading 1\n\n',
depth: 1,
text: 'heading 1',
- tokens: [{ type: 'text', raw: 'heading 1', text: 'heading 1' }]
+ tokens: [{ type: 'text', raw: 'heading 1', text: 'heading 1' }],
},
{
type: 'heading',
raw: '## heading 2\n\n',
depth: 2,
text: 'heading 2',
- tokens: [{ type: 'text', raw: 'heading 2', text: 'heading 2' }]
+ tokens: [{ type: 'text', raw: 'heading 2', text: 'heading 2' }],
},
{
type: 'heading',
raw: '### heading 3\n\n',
depth: 3,
text: 'heading 3',
- tokens: [{ type: 'text', raw: 'heading 3', text: 'heading 3' }]
+ tokens: [{ type: 'text', raw: 'heading 3', text: 'heading 3' }],
},
{
type: 'heading',
raw: '#### heading 4\n\n',
depth: 4,
text: 'heading 4',
- tokens: [{ type: 'text', raw: 'heading 4', text: 'heading 4' }]
+ tokens: [{ type: 'text', raw: 'heading 4', text: 'heading 4' }],
},
{
type: 'heading',
raw: '##### heading 5\n\n',
depth: 5,
text: 'heading 5',
- tokens: [{ type: 'text', raw: 'heading 5', text: 'heading 5' }]
+ tokens: [{ type: 'text', raw: 'heading 5', text: 'heading 5' }],
},
{
type: 'heading',
raw: '###### heading 6\n\n',
depth: 6,
text: 'heading 6',
- tokens: [{ type: 'text', raw: 'heading 6', text: 'heading 6' }]
+ tokens: [{ type: 'text', raw: 'heading 6', text: 'heading 6' }],
},
{
type: 'heading',
raw: 'lheading 1\n==========\n\n',
depth: 1,
text: 'lheading 1',
- tokens: [{ type: 'text', raw: 'lheading 1', text: 'lheading 1' }]
+ tokens: [{ type: 'text', raw: 'lheading 1', text: 'lheading 1' }],
},
{
type: 'heading',
raw: 'lheading 2\n----------\n',
depth: 2,
text: 'lheading 2',
- tokens: [{ type: 'text', raw: 'lheading 2', text: 'lheading 2' }]
- }
- ]
+ tokens: [{ type: 'text', raw: 'lheading 2', text: 'lheading 2' }],
+ },
+ ],
});
});
@@ -172,8 +172,8 @@ lheading 2
type: 'paragraph',
raw: '####### heading 7',
text: '####### heading 7',
- tokens: [{ type: 'text', raw: '####### heading 7', text: '####### heading 7' }]
- }]
+ tokens: [{ type: 'text', raw: '####### heading 7', text: '####### heading 7' }],
+ }],
});
});
});
@@ -188,7 +188,7 @@ lheading 2
`,
tokens: [{
type: 'space',
- raw: '\n'
+ raw: '\n',
}, {
type: 'table',
align: [null, null],
@@ -198,14 +198,14 @@ lheading 2
text: 'a',
tokens: [{ type: 'text', raw: 'a', text: 'a' }],
header: true,
- align: null
+ align: null,
},
{
text: 'b',
tokens: [{ type: 'text', raw: 'b', text: 'b' }],
header: true,
- align: null
- }
+ align: null,
+ },
],
rows: [
[
@@ -213,17 +213,17 @@ lheading 2
text: '1',
tokens: [{ type: 'text', raw: '1', text: '1' }],
header: false,
- align: null
+ align: null,
},
{
text: '2',
tokens: [{ type: 'text', raw: '2', text: '2' }],
header: false,
- align: null
- }
- ]
- ]
- }]
+ align: null,
+ },
+ ],
+ ],
+ }],
});
});
@@ -237,12 +237,12 @@ paragraph 1
`,
tokens: [{
type: 'space',
- raw: '\n'
+ raw: '\n',
}, {
type: 'paragraph',
raw: 'paragraph 1\n',
text: 'paragraph 1',
- tokens: [{ type: 'text', raw: 'paragraph 1', text: 'paragraph 1' }]
+ tokens: [{ type: 'text', raw: 'paragraph 1', text: 'paragraph 1' }],
},
{
type: 'table',
@@ -253,14 +253,14 @@ paragraph 1
text: 'a',
tokens: [{ type: 'text', raw: 'a', text: 'a' }],
header: true,
- align: null
+ align: null,
},
{
text: 'b',
tokens: [{ type: 'text', raw: 'b', text: 'b' }],
header: true,
- align: null
- }
+ align: null,
+ },
],
rows: [
[
@@ -268,18 +268,18 @@ paragraph 1
text: '1',
tokens: [{ type: 'text', raw: '1', text: '1' }],
header: false,
- align: null
+ align: null,
},
{
text: '2',
tokens: [{ type: 'text', raw: '2', text: '2' }],
header: false,
- align: null
- }
- ]
- ]
- }
- ]
+ align: null,
+ },
+ ],
+ ],
+ },
+ ],
});
});
@@ -292,7 +292,7 @@ paragraph 1
`,
tokens: [{
type: 'space',
- raw: '\n'
+ raw: '\n',
}, {
type: 'table',
align: ['left', 'center', 'right'],
@@ -302,20 +302,20 @@ paragraph 1
text: 'a',
tokens: [{ type: 'text', raw: 'a', text: 'a' }],
header: true,
- align: 'left'
+ align: 'left',
},
{
text: 'b',
tokens: [{ type: 'text', raw: 'b', text: 'b' }],
header: true,
- align: 'center'
+ align: 'center',
},
{
text: 'c',
tokens: [{ type: 'text', raw: 'c', text: 'c' }],
header: true,
- align: 'right'
- }
+ align: 'right',
+ },
],
rows: [
[
@@ -323,23 +323,23 @@ paragraph 1
text: '1',
tokens: [{ type: 'text', raw: '1', text: '1' }],
header: false,
- align: 'left'
+ align: 'left',
},
{
text: '2',
tokens: [{ type: 'text', raw: '2', text: '2' }],
header: false,
- align: 'center'
+ align: 'center',
},
{
text: '3',
tokens: [{ type: 'text', raw: '3', text: '3' }],
header: false,
- align: 'right'
- }
- ]
- ]
- }]
+ align: 'right',
+ },
+ ],
+ ],
+ }],
});
});
@@ -353,7 +353,7 @@ a | b
tokens: [
{
type: 'space',
- raw: '\n'
+ raw: '\n',
}, {
type: 'table',
align: [null, null],
@@ -363,14 +363,14 @@ a | b
text: 'a',
tokens: [{ type: 'text', raw: 'a', text: 'a' }],
header: true,
- align: null
+ align: null,
},
{
text: 'b',
tokens: [{ type: 'text', raw: 'b', text: 'b' }],
header: true,
- align: null
- }
+ align: null,
+ },
],
rows: [
[
@@ -378,17 +378,17 @@ a | b
text: '1',
tokens: [{ type: 'text', raw: '1', text: '1' }],
header: false,
- align: null
+ align: null,
},
{
text: '2',
tokens: [{ type: 'text', raw: '2', text: '2' }],
header: false,
- align: null
- }
- ]
- ]
- }]
+ align: null,
+ },
+ ],
+ ],
+ }],
});
});
});
@@ -398,8 +398,8 @@ a | b
expectTokens({
md: '---',
tokens: [
- { type: 'hr', raw: '---' }
- ]
+ { type: 'hr', raw: '---' },
+ ],
});
});
});
@@ -418,11 +418,11 @@ a | b
raw: 'blockquote',
text: 'blockquote',
tokens: [
- { type: 'text', raw: 'blockquote', text: 'blockquote' }
- ]
- }]
- }
- ]
+ { type: 'text', raw: 'blockquote', text: 'blockquote' },
+ ],
+ }],
+ },
+ ],
});
});
@@ -439,11 +439,11 @@ a | b
raw: 'blockquote',
text: 'blockquote',
tokens: [
- { type: 'text', raw: 'blockquote', text: 'blockquote' }
- ]
- }]
- }
- ]
+ { type: 'text', raw: 'blockquote', text: 'blockquote' },
+ ],
+ }],
+ },
+ ],
});
});
@@ -475,17 +475,17 @@ a | b
raw: 'blockquote',
text: 'blockquote',
tokens: [
- { type: 'text', raw: 'blockquote', text: 'blockquote' }
- ]
- }
+ { type: 'text', raw: 'blockquote', text: 'blockquote' },
+ ],
+ },
],
- text: 'blockquote'
- }
- ]
- }
- ]
- }
- ]
+ text: 'blockquote',
+ },
+ ],
+ },
+ ],
+ },
+ ],
});
});
});
@@ -500,7 +500,7 @@ a | b
tokens: [
{
type: 'space',
- raw: '\n'
+ raw: '\n',
}, {
type: 'list',
raw: '- item 1\n- item 2\n',
@@ -519,8 +519,8 @@ a | b
type: 'text',
raw: 'item 1',
text: 'item 1',
- tokens: [{ type: 'text', raw: 'item 1', text: 'item 1' }]
- }]
+ tokens: [{ type: 'text', raw: 'item 1', text: 'item 1' }],
+ }],
},
{
type: 'list_item',
@@ -533,12 +533,12 @@ a | b
type: 'text',
raw: 'item 2',
text: 'item 2',
- tokens: [{ type: 'text', raw: 'item 2', text: 'item 2' }]
- }]
- }
- ]
- }
- ]
+ tokens: [{ type: 'text', raw: 'item 2', text: 'item 2' }],
+ }],
+ },
+ ],
+ },
+ ],
});
});
@@ -551,7 +551,7 @@ a | b
tokens: [
{
type: 'space',
- raw: '\n'
+ raw: '\n',
},
{
type: 'list',
@@ -576,11 +576,11 @@ a | b
{
type: 'text',
raw: 'item 1',
- text: 'item 1'
- }
- ]
- }
- ]
+ text: 'item 1',
+ },
+ ],
+ },
+ ],
},
{
type: 'list_item',
@@ -598,15 +598,15 @@ a | b
{
type: 'text',
raw: 'item 2',
- text: 'item 2'
- }
- ]
- }
- ]
- }
- ]
- }
- ]
+ text: 'item 2',
+ },
+ ],
+ },
+ ],
+ },
+ ],
+ },
+ ],
});
});
@@ -619,7 +619,7 @@ a | b
tokens: [
{
type: 'space',
- raw: '\n'
+ raw: '\n',
},
{
type: 'list',
@@ -644,11 +644,11 @@ a | b
{
type: 'text',
raw: 'item 1',
- text: 'item 1'
- }
- ]
- }
- ]
+ text: 'item 1',
+ },
+ ],
+ },
+ ],
},
{
type: 'list_item',
@@ -666,15 +666,15 @@ a | b
{
type: 'text',
raw: 'item 2',
- text: 'item 2'
- }
- ]
- }
- ]
- }
- ]
- }
- ]
+ text: 'item 2',
+ },
+ ],
+ },
+ ],
+ },
+ ],
+ },
+ ],
});
});
@@ -689,7 +689,7 @@ paragraph
tokens: [
{
type: 'space',
- raw: '\n'
+ raw: '\n',
},
{
type: 'list',
@@ -714,11 +714,11 @@ paragraph
{
type: 'text',
raw: 'item 1',
- text: 'item 1'
- }
- ]
- }
- ]
+ text: 'item 1',
+ },
+ ],
+ },
+ ],
},
{
type: 'list_item',
@@ -736,17 +736,17 @@ paragraph
{
type: 'text',
raw: 'item 2',
- text: 'item 2'
- }
- ]
- }
- ]
- }
- ]
+ text: 'item 2',
+ },
+ ],
+ },
+ ],
+ },
+ ],
},
{
type: 'space',
- raw: '\n\n'
+ raw: '\n\n',
},
{
type: 'paragraph',
@@ -756,11 +756,11 @@ paragraph
{
type: 'text',
raw: 'paragraph',
- text: 'paragraph'
- }
- ]
- }
- ]
+ text: 'paragraph',
+ },
+ ],
+ },
+ ],
});
});
@@ -773,7 +773,7 @@ paragraph
tokens: [
{
type: 'space',
- raw: '\n'
+ raw: '\n',
},
{
type: 'list',
@@ -798,11 +798,11 @@ paragraph
{
type: 'text',
raw: 'item 1',
- text: 'item 1'
- }
- ]
- }
- ]
+ text: 'item 1',
+ },
+ ],
+ },
+ ],
},
{
type: 'list_item',
@@ -820,15 +820,15 @@ paragraph
{
type: 'text',
raw: 'item 2',
- text: 'item 2'
- }
- ]
- }
- ]
- }
- ]
- }
- ]
+ text: 'item 2',
+ },
+ ],
+ },
+ ],
+ },
+ ],
+ },
+ ],
});
});
@@ -842,7 +842,7 @@ paragraph
tokens: [
{
type: 'space',
- raw: '\n'
+ raw: '\n',
},
{
type: 'list',
@@ -867,11 +867,11 @@ paragraph
{
type: 'text',
raw: 'item 1',
- text: 'item 1'
- }
- ]
- }
- ]
+ text: 'item 1',
+ },
+ ],
+ },
+ ],
},
{
type: 'list_item',
@@ -889,15 +889,15 @@ paragraph
{
type: 'text',
raw: 'item 2',
- text: 'item 2'
- }
- ]
- }
- ]
- }
- ]
- }
- ]
+ text: 'item 2',
+ },
+ ],
+ },
+ ],
+ },
+ ],
+ },
+ ],
});
});
@@ -913,7 +913,7 @@ paragraph
tokens: [
{
type: 'space',
- raw: '\n'
+ raw: '\n',
},
{
type: 'list',
@@ -938,11 +938,11 @@ paragraph
{
type: 'text',
raw: 'item 1',
- text: 'item 1'
- }
- ]
- }
- ]
+ text: 'item 1',
+ },
+ ],
+ },
+ ],
},
{
type: 'list_item',
@@ -960,13 +960,13 @@ paragraph
{
type: 'text',
raw: 'item 2',
- text: 'item 2'
- }
- ]
+ text: 'item 2',
+ },
+ ],
},
{
type: 'space',
- raw: '\n\n'
+ raw: '\n\n',
},
{
type: 'text',
@@ -976,11 +976,11 @@ paragraph
{
type: 'text',
raw: 'item 2a',
- text: 'item 2a'
- }
- ]
- }
- ]
+ text: 'item 2a',
+ },
+ ],
+ },
+ ],
},
{
type: 'list_item',
@@ -998,15 +998,15 @@ paragraph
{
type: 'text',
raw: 'item 3',
- text: 'item 3'
- }
- ]
- }
- ]
- }
- ]
- }
- ]
+ text: 'item 3',
+ },
+ ],
+ },
+ ],
+ },
+ ],
+ },
+ ],
});
});
@@ -1019,7 +1019,7 @@ paragraph
tokens: [
{
type: 'space',
- raw: '\n'
+ raw: '\n',
},
{
type: 'list',
@@ -1044,9 +1044,9 @@ paragraph
{
type: 'text',
raw: 'item 1',
- text: 'item 1'
- }
- ]
+ text: 'item 1',
+ },
+ ],
},
{
type: 'list',
@@ -1071,19 +1071,19 @@ paragraph
{
type: 'text',
raw: 'item 2',
- text: 'item 2'
- }
- ]
- }
- ]
- }
- ]
- }
- ]
- }
- ]
- }
- ]
+ text: 'item 2',
+ },
+ ],
+ },
+ ],
+ },
+ ],
+ },
+ ],
+ },
+ ],
+ },
+ ],
});
});
@@ -1096,7 +1096,7 @@ paragraph
tokens: [
{
type: 'space',
- raw: '\n'
+ raw: '\n',
},
{
type: 'list',
@@ -1121,11 +1121,11 @@ paragraph
{
type: 'text',
raw: 'item 1',
- text: 'item 1'
- }
- ]
- }
- ]
+ text: 'item 1',
+ },
+ ],
+ },
+ ],
},
{
type: 'list_item',
@@ -1143,15 +1143,15 @@ paragraph
{
type: 'text',
raw: 'item 2',
- text: 'item 2'
- }
- ]
- }
- ]
- }
- ]
- }
- ]
+ text: 'item 2',
+ },
+ ],
+ },
+ ],
+ },
+ ],
+ },
+ ],
});
});
});
@@ -1166,9 +1166,9 @@ paragraph
raw: 'html
',
pre: false,
block: true,
- text: 'html
'
- }
- ]
+ text: 'html
',
+ },
+ ],
});
});
@@ -1181,9 +1181,9 @@ paragraph
raw: 'html
',
pre: true,
block: true,
- text: 'html
'
- }
- ]
+ text: 'html
',
+ },
+ ],
});
});
});
@@ -1193,8 +1193,8 @@ paragraph
expectTokens({
md: '[link]: https://example.com',
links: {
- link: { href: 'https://example.com', title: undefined }
- }
+ link: { href: 'https://example.com', title: undefined },
+ },
});
});
@@ -1202,8 +1202,8 @@ paragraph
expectTokens({
md: '[link]: https://example.com "title"',
links: {
- link: { href: 'https://example.com', title: 'title' }
- }
+ link: { href: 'https://example.com', title: 'title' },
+ },
});
});
});
@@ -1214,8 +1214,8 @@ paragraph
expectInlineTokens({
md: '\\>',
tokens: [
- { type: 'escape', raw: '\\>', text: '>' }
- ]
+ { type: 'escape', raw: '\\>', text: '>' },
+ ],
});
});
@@ -1229,11 +1229,11 @@ paragraph
text: 'strong text\\[',
tokens: [
{ type: 'text', raw: 'strong text', text: 'strong text' },
- { type: 'escape', raw: '\\[', text: '[' }
- ]
+ { type: 'escape', raw: '\\[', text: '[' },
+ ],
},
- { type: 'escape', raw: '\\]', text: ']' }
- ]
+ { type: 'escape', raw: '\\]', text: ']' },
+ ],
});
expectInlineTokens({
md: '_em\\sis_',
@@ -1247,10 +1247,10 @@ paragraph
{ type: 'escape', raw: '\\<', text: '<' },
{ type: 'text', raw: 'pha', text: 'pha' },
{ type: 'escape', raw: '\\>', text: '>' },
- { type: 'text', raw: 'sis', text: 'sis' }
- ]
- }
- ]
+ { type: 'text', raw: 'sis', text: 'sis' },
+ ],
+ },
+ ],
});
});
@@ -1260,8 +1260,8 @@ paragraph
tokens: [
{ type: 'html', raw: '', inLink: false, inRawBlock: false, block: false, text: '
' },
{ type: 'text', raw: 'html', text: 'html' },
- { type: 'html', raw: '
', inLink: false, inRawBlock: false, block: false, text: '
' }
- ]
+ { type: 'html', raw: '', inLink: false, inRawBlock: false, block: false, text: '' },
+ ],
});
});
@@ -1276,10 +1276,10 @@ paragraph
title: null,
text: 'link',
tokens: [
- { type: 'text', raw: 'link', text: 'link' }
- ]
- }
- ]
+ { type: 'text', raw: 'link', text: 'link' },
+ ],
+ },
+ ],
});
});
@@ -1294,10 +1294,10 @@ paragraph
title: 'title',
text: 'link',
tokens: [
- { type: 'text', raw: 'link', text: 'link' }
- ]
- }
- ]
+ { type: 'text', raw: 'link', text: 'link' },
+ ],
+ },
+ ],
});
});
@@ -1310,9 +1310,9 @@ paragraph
raw: '![image](https://example.com/image.png)',
text: 'image',
href: 'https://example.com/image.png',
- title: null
- }
- ]
+ title: null,
+ },
+ ],
});
});
@@ -1325,9 +1325,9 @@ paragraph
raw: '![image](https://example.com/image.png "title")',
text: 'image',
href: 'https://example.com/image.png',
- title: 'title'
- }
- ]
+ title: 'title',
+ },
+ ],
});
});
@@ -1336,7 +1336,7 @@ paragraph
expectInlineTokens({
md: '[link][]',
links: {
- link: { href: 'https://example.com', title: 'title' }
+ link: { href: 'https://example.com', title: 'title' },
},
tokens: [
{
@@ -1348,10 +1348,10 @@ paragraph
tokens: [{
type: 'text',
raw: 'link',
- text: 'link'
- }]
- }
- ]
+ text: 'link',
+ }],
+ },
+ ],
});
});
@@ -1359,7 +1359,7 @@ paragraph
expectInlineTokens({
md: '[link]',
links: {
- link: { href: 'https://example.com', title: 'title' }
+ link: { href: 'https://example.com', title: 'title' },
},
tokens: [
{
@@ -1371,10 +1371,10 @@ paragraph
tokens: [{
type: 'text',
raw: 'link',
- text: 'link'
- }]
- }
- ]
+ text: 'link',
+ }],
+ },
+ ],
});
});
@@ -1382,8 +1382,8 @@ paragraph
expectInlineTokens({
md: '[link]',
tokens: [
- { type: 'text', raw: '[link]', text: '[link]' }
- ]
+ { type: 'text', raw: '[link]', text: '[link]' },
+ ],
});
});
});
@@ -1397,10 +1397,10 @@ paragraph
raw: '**strong**',
text: 'strong',
tokens: [
- { type: 'text', raw: 'strong', text: 'strong' }
- ]
- }
- ]
+ { type: 'text', raw: 'strong', text: 'strong' },
+ ],
+ },
+ ],
});
});
@@ -1413,10 +1413,10 @@ paragraph
raw: '*em*',
text: 'em',
tokens: [
- { type: 'text', raw: 'em', text: 'em' }
- ]
- }
- ]
+ { type: 'text', raw: 'em', text: 'em' },
+ ],
+ },
+ ],
});
});
@@ -1425,8 +1425,8 @@ paragraph
expectInlineTokens({
md: '`code`',
tokens: [
- { type: 'codespan', raw: '`code`', text: 'code' }
- ]
+ { type: 'codespan', raw: '`code`', text: 'code' },
+ ],
});
});
@@ -1434,8 +1434,8 @@ paragraph
expectInlineTokens({
md: '` `',
tokens: [
- { type: 'codespan', raw: '` `', text: ' ' }
- ]
+ { type: 'codespan', raw: '` `', text: ' ' },
+ ],
});
});
@@ -1443,8 +1443,8 @@ paragraph
expectInlineTokens({
md: '` a`',
tokens: [
- { type: 'codespan', raw: '` a`', text: ' a' }
- ]
+ { type: 'codespan', raw: '` a`', text: ' a' },
+ ],
});
});
@@ -1452,8 +1452,8 @@ paragraph
expectInlineTokens({
md: '`a `',
tokens: [
- { type: 'codespan', raw: '`a `', text: 'a ' }
- ]
+ { type: 'codespan', raw: '`a `', text: 'a ' },
+ ],
});
});
@@ -1461,8 +1461,8 @@ paragraph
expectInlineTokens({
md: '` a `',
tokens: [
- { type: 'codespan', raw: '` a `', text: 'a' }
- ]
+ { type: 'codespan', raw: '` a `', text: 'a' },
+ ],
});
});
@@ -1470,8 +1470,8 @@ paragraph
expectInlineTokens({
md: '`\na\n`',
tokens: [
- { type: 'codespan', raw: '`\na\n`', text: 'a' }
- ]
+ { type: 'codespan', raw: '`\na\n`', text: 'a' },
+ ],
});
});
@@ -1479,8 +1479,8 @@ paragraph
expectInlineTokens({
md: '`\ta\t`',
tokens: [
- { type: 'codespan', raw: '`\ta\t`', text: '\ta\t' }
- ]
+ { type: 'codespan', raw: '`\ta\t`', text: '\ta\t' },
+ ],
});
});
@@ -1488,8 +1488,8 @@ paragraph
expectInlineTokens({
md: '`\na\n`',
tokens: [
- { type: 'codespan', raw: '`\na\n`', text: 'a' }
- ]
+ { type: 'codespan', raw: '`\na\n`', text: 'a' },
+ ],
});
});
@@ -1497,8 +1497,8 @@ paragraph
expectInlineTokens({
md: '` a `',
tokens: [
- { type: 'codespan', raw: '` a `', text: ' a ' }
- ]
+ { type: 'codespan', raw: '` a `', text: ' a ' },
+ ],
});
});
@@ -1506,8 +1506,8 @@ paragraph
expectInlineTokens({
md: '`a\nb`',
tokens: [
- { type: 'codespan', raw: '`a\nb`', text: 'a b' }
- ]
+ { type: 'codespan', raw: '`a\nb`', text: 'a b' },
+ ],
});
});
});
@@ -1520,18 +1520,18 @@ paragraph
{
raw: 'a',
text: 'a',
- type: 'text'
+ type: 'text',
},
{
raw: '\n',
- type: 'br'
+ type: 'br',
},
{
raw: 'b',
text: 'b',
- type: 'text'
- }
- ]
+ type: 'text',
+ },
+ ],
});
});
@@ -1544,10 +1544,10 @@ paragraph
raw: '~~del~~',
text: 'del',
tokens: [
- { type: 'text', raw: 'del', text: 'del' }
- ]
- }
- ]
+ { type: 'text', raw: 'del', text: 'del' },
+ ],
+ },
+ ],
});
});
@@ -1562,10 +1562,10 @@ paragraph
text: 'https://example.com',
href: 'https://example.com',
tokens: [
- { type: 'text', raw: 'https://example.com', text: 'https://example.com' }
- ]
- }
- ]
+ { type: 'text', raw: 'https://example.com', text: 'https://example.com' },
+ ],
+ },
+ ],
});
});
@@ -1580,10 +1580,10 @@ paragraph
text: 'test@example.com',
href: 'mailto:test@example.com',
tokens: [
- { type: 'text', raw: 'test@example.com', text: 'test@example.com' }
- ]
- }
- ]
+ { type: 'text', raw: 'test@example.com', text: 'test@example.com' },
+ ],
+ },
+ ],
});
});
@@ -1597,10 +1597,10 @@ paragraph
text: 'https://example.com',
href: 'https://example.com',
tokens: [
- { type: 'text', raw: 'https://example.com', text: 'https://example.com' }
- ]
- }
- ]
+ { type: 'text', raw: 'https://example.com', text: 'https://example.com' },
+ ],
+ },
+ ],
});
});
@@ -1615,10 +1615,10 @@ paragraph
text: 'test@example.com',
href: 'mailto:test@example.com',
tokens: [
- { type: 'text', raw: 'test@example.com', text: 'test@example.com' }
- ]
- }
- ]
+ { type: 'text', raw: 'test@example.com', text: 'test@example.com' },
+ ],
+ },
+ ],
});
});
});
@@ -1630,9 +1630,9 @@ paragraph
{
type: 'text',
raw: 'text',
- text: 'text'
- }
- ]
+ text: 'text',
+ },
+ ],
});
});
});
diff --git a/test/unit/Parser.test.js b/test/unit/Parser.test.js
index c8b151c2ea..a45f428c97 100644
--- a/test/unit/Parser.test.js
+++ b/test/unit/Parser.test.js
@@ -18,16 +18,16 @@ describe('Parser', () => {
{
type: 'paragraph',
text: 'paragraph 1',
- tokens: [{ type: 'text', text: 'paragraph 1' }]
+ tokens: [{ type: 'text', text: 'paragraph 1' }],
},
{ type: 'space' },
{
type: 'paragraph',
text: 'paragraph 2',
- tokens: [{ type: 'text', text: 'paragraph 2' }]
- }
+ tokens: [{ type: 'text', text: 'paragraph 2' }],
+ },
],
- html: 'paragraph 1
paragraph 2
'
+ html: 'paragraph 1
paragraph 2
',
});
});
@@ -35,10 +35,10 @@ describe('Parser', () => {
await expectHtml({
tokens: [
{
- type: 'hr'
- }
+ type: 'hr',
+ },
],
- html: '
'
+ html: '
',
});
});
@@ -49,10 +49,10 @@ describe('Parser', () => {
type: 'heading',
depth: 1,
text: 'heading',
- tokens: [{ type: 'text', text: 'heading' }]
- }
+ tokens: [{ type: 'text', text: 'heading' }],
+ },
],
- html: 'heading
'
+ html: 'heading
',
});
});
@@ -61,10 +61,10 @@ describe('Parser', () => {
tokens: [
{
type: 'code',
- text: 'code'
- }
+ text: 'code',
+ },
],
- html: 'code
'
+ html: 'code
',
});
});
@@ -79,14 +79,14 @@ describe('Parser', () => {
text: 'a',
tokens: [{ type: 'text', raw: 'a', text: 'a' }],
header: true,
- align: 'left'
+ align: 'left',
},
{
text: 'b',
tokens: [{ type: 'text', raw: 'b', text: 'b' }],
header: true,
- align: 'right'
- }
+ align: 'right',
+ },
],
rows: [
[
@@ -94,17 +94,17 @@ describe('Parser', () => {
text: '1',
tokens: [{ type: 'text', raw: '1', text: '1' }],
header: false,
- align: 'left'
+ align: 'left',
},
{
text: '2',
tokens: [{ type: 'text', raw: '2', text: '2' }],
header: false,
- align: 'right'
- }
- ]
- ]
- }
+ align: 'right',
+ },
+ ],
+ ],
+ },
],
html: `
@@ -120,7 +120,7 @@ describe('Parser', () => {
2 |
-
`
+`,
});
});
@@ -133,12 +133,12 @@ describe('Parser', () => {
{
type: 'paragraph',
text: 'blockquote',
- tokens: [{ type: 'text', text: 'blockquote' }]
- }
- ]
- }
+ tokens: [{ type: 'text', text: 'blockquote' }],
+ },
+ ],
+ },
],
- html: 'blockquote
'
+ html: 'blockquote
',
});
});
@@ -159,9 +159,9 @@ describe('Parser', () => {
{
type: 'text',
text: 'item 1',
- tokens: [{ type: 'text', text: 'item 1' }]
- }
- ]
+ tokens: [{ type: 'text', text: 'item 1' }],
+ },
+ ],
},
{
task: false,
@@ -170,18 +170,18 @@ describe('Parser', () => {
{
type: 'text',
text: 'item 2',
- tokens: [{ type: 'text', text: 'item 2' }]
- }
- ]
- }
- ]
- }
+ tokens: [{ type: 'text', text: 'item 2' }],
+ },
+ ],
+ },
+ ],
+ },
],
html: `
`
+`,
});
});
@@ -201,9 +201,9 @@ describe('Parser', () => {
{
type: 'text',
text: 'item 1',
- tokens: [{ type: 'text', text: 'item 1' }]
- }
- ]
+ tokens: [{ type: 'text', text: 'item 1' }],
+ },
+ ],
},
{
task: false,
@@ -212,18 +212,18 @@ describe('Parser', () => {
{
type: 'text',
text: 'item 2',
- tokens: [{ type: 'text', text: 'item 2' }]
- }
- ]
- }
- ]
- }
+ tokens: [{ type: 'text', text: 'item 2' }],
+ },
+ ],
+ },
+ ],
+ },
],
html: `
- item 1
- item 2
-
`
+`,
});
});
@@ -243,9 +243,9 @@ describe('Parser', () => {
{
type: 'text',
text: 'item 1',
- tokens: [{ type: 'text', text: 'item 1' }]
- }
- ]
+ tokens: [{ type: 'text', text: 'item 1' }],
+ },
+ ],
},
{
task: true,
@@ -254,18 +254,18 @@ describe('Parser', () => {
{
type: 'text',
text: 'item 2',
- tokens: [{ type: 'text', text: 'item 2' }]
- }
- ]
- }
- ]
- }
+ tokens: [{ type: 'text', text: 'item 2' }],
+ },
+ ],
+ },
+ ],
+ },
],
html: `
`
+`,
});
});
@@ -286,9 +286,9 @@ describe('Parser', () => {
{
type: 'text',
text: 'item 1',
- tokens: [{ type: 'text', text: 'item 1' }]
- }
- ]
+ tokens: [{ type: 'text', text: 'item 1' }],
+ },
+ ],
},
{
task: false,
@@ -298,18 +298,18 @@ describe('Parser', () => {
{
type: 'text',
text: 'item 2',
- tokens: [{ type: 'text', text: 'item 2' }]
- }
- ]
- }
- ]
- }
+ tokens: [{ type: 'text', text: 'item 2' }],
+ },
+ ],
+ },
+ ],
+ },
],
html: `
`
+ `,
});
});
});
@@ -319,10 +319,10 @@ describe('Parser', () => {
tokens: [
{
type: 'html',
- text: 'html
'
- }
+ text: 'html
',
+ },
],
- html: 'html
'
+ html: 'html
',
});
});
@@ -332,10 +332,10 @@ describe('Parser', () => {
{
type: 'paragraph',
text: 'paragraph 1',
- tokens: [{ type: 'text', text: 'paragraph 1' }]
- }
+ tokens: [{ type: 'text', text: 'paragraph 1' }],
+ },
],
- html: 'paragraph 1
'
+ html: 'paragraph 1
',
});
});
@@ -343,9 +343,9 @@ describe('Parser', () => {
await expectHtml({
tokens: [
{ type: 'text', text: 'text 1' },
- { type: 'text', text: 'text 2' }
+ { type: 'text', text: 'text 2' },
],
- html: 'text 1\ntext 2
'
+ html: 'text 1\ntext 2
',
});
});
});
@@ -355,7 +355,7 @@ describe('Parser', () => {
await expectHtml({
inline: true,
tokens: [{ type: 'escape', text: '>' }],
- html: '>'
+ html: '>',
});
});
@@ -365,9 +365,9 @@ describe('Parser', () => {
tokens: [
{ type: 'html', text: '' },
{ type: 'text', text: 'html' },
- { type: 'html', text: '
' }
+ { type: 'html', text: '' },
],
- html: 'html
'
+ html: 'html
',
});
});
@@ -380,10 +380,10 @@ describe('Parser', () => {
text: 'link',
href: 'https://example.com',
title: 'title',
- tokens: [{ type: 'text', text: 'link' }]
- }
+ tokens: [{ type: 'text', text: 'link' }],
+ },
],
- html: 'link'
+ html: 'link',
});
});
@@ -395,10 +395,10 @@ describe('Parser', () => {
type: 'image',
text: 'image',
href: 'image.png',
- title: 'title'
- }
+ title: 'title',
+ },
],
- html: ''
+ html: '',
});
});
@@ -409,10 +409,10 @@ describe('Parser', () => {
{
type: 'strong',
text: 'strong',
- tokens: [{ type: 'text', text: 'strong' }]
- }
+ tokens: [{ type: 'text', text: 'strong' }],
+ },
],
- html: 'strong'
+ html: 'strong',
});
});
@@ -423,10 +423,10 @@ describe('Parser', () => {
{
type: 'em',
text: 'em',
- tokens: [{ type: 'text', text: 'em' }]
- }
+ tokens: [{ type: 'text', text: 'em' }],
+ },
],
- html: 'em'
+ html: 'em',
});
});
@@ -436,10 +436,10 @@ describe('Parser', () => {
tokens: [
{
type: 'codespan',
- text: 'code'
- }
+ text: 'code',
+ },
],
- html: 'code
'
+ html: 'code
',
});
});
@@ -448,10 +448,10 @@ describe('Parser', () => {
inline: true,
tokens: [
{
- type: 'br'
- }
+ type: 'br',
+ },
],
- html: '
'
+ html: '
',
});
});
@@ -462,10 +462,10 @@ describe('Parser', () => {
{
type: 'del',
text: 'del',
- tokens: [{ type: 'text', text: 'del' }]
- }
+ tokens: [{ type: 'text', text: 'del' }],
+ },
],
- html: 'del'
+ html: 'del',
});
});
@@ -474,9 +474,9 @@ describe('Parser', () => {
inline: true,
tokens: [
{ type: 'text', text: 'text 1' },
- { type: 'text', text: 'text 2' }
+ { type: 'text', text: 'text 2' },
],
- html: 'text 1text 2'
+ html: 'text 1text 2',
});
});
});
diff --git a/test/unit/bin.test.js b/test/unit/bin.test.js
index 00c3fa06f7..70990114d0 100644
--- a/test/unit/bin.test.js
+++ b/test/unit/bin.test.js
@@ -15,27 +15,27 @@ function createMocks() {
stdin: {
data: null,
error: null,
- end: null
+ end: null,
},
process: {
cwd: mock.fn(() => '/cwd'),
env: [],
argv: [],
stdout: {
- write: mock.fn((str) => { mocks.stdout += str; })
+ write: mock.fn((str) => { mocks.stdout += str; }),
},
stderr: {
- write: mock.fn((str) => { mocks.stderr += str; })
+ write: mock.fn((str) => { mocks.stderr += str; }),
},
stdin: {
setEncoding: mock.fn(),
on: mock.fn((method, func) => {
mocks.stdin[method] = func;
}),
- resume: mock.fn()
+ resume: mock.fn(),
},
- exit: mock.fn((code) => { mocks.code = code; })
- }
+ exit: mock.fn((code) => { mocks.code = code; }),
+ },
};
return mocks;
@@ -71,30 +71,30 @@ describe('bin/marked', () => {
describe('string', () => {
it('-s', testInput({
args: ['-s', '# test'],
- stdout: 'test
'
+ stdout: 'test
',
}));
it('--string', testInput({
args: ['--string', '# test'],
- stdout: 'test
'
+ stdout: 'test
',
}));
});
describe('config', () => {
it('-c', testInput({
args: ['-c', fixturePath('bin-config.js'), '-s', 'line1\nline2'],
- stdout: 'line1
line2
'
+ stdout: 'line1
line2
',
}));
it('--config', testInput({
args: ['--config', fixturePath('bin-config.js'), '-s', 'line1\nline2'],
- stdout: 'line1
line2
'
+ stdout: 'line1
line2
',
}));
it('config not found', testInput({
args: ['--config', fixturePath('does-not-exist.js'), '-s', 'line1\nline2'],
stderr: `Cannot load config file '${fixturePath('does-not-exist.js')}'`,
- code: 1
+ code: 1,
}));
});
@@ -102,13 +102,13 @@ describe('bin/marked', () => {
it('input file not found', testInput({
args: [fixturePath('does-not-exist.md')],
stderr: `marked: ${fixturePath('does-not-exist.md')}: No such file or directory`,
- code: 1
+ code: 1,
}));
it('input file not found --input', testInput({
args: ['--input', fixturePath('does-not-exist.md')],
stderr: `marked: ${fixturePath('does-not-exist.md')}: No such file or directory`,
- code: 1
+ code: 1,
}));
});
});
diff --git a/test/unit/fixtures/bin-config.js b/test/unit/fixtures/bin-config.js
index b0b356c510..a8d4bcbeb2 100644
--- a/test/unit/fixtures/bin-config.js
+++ b/test/unit/fixtures/bin-config.js
@@ -1,3 +1,3 @@
export default {
- breaks: true
+ breaks: true,
};
diff --git a/test/unit/instance.test.js b/test/unit/instance.test.js
index d00e533a01..c99fdcdc8e 100644
--- a/test/unit/instance.test.js
+++ b/test/unit/instance.test.js
@@ -9,8 +9,8 @@ describe('Marked', () => {
renderer: {
heading() {
return 'im marked1';
- }
- }
+ },
+ },
});
const marked2 = new Marked({
@@ -18,8 +18,8 @@ describe('Marked', () => {
renderer: {
heading() {
return 'im marked2';
- }
- }
+ },
+ },
});
assert.strictEqual(marked1.parse('# header'), 'im marked1');
@@ -34,8 +34,8 @@ describe('Marked', () => {
renderer: {
heading() {
return 'im marked1';
- }
- }
+ },
+ },
});
const marked2 = new Marked();
@@ -44,8 +44,8 @@ describe('Marked', () => {
renderer: {
heading() {
return 'im marked2';
- }
- }
+ },
+ },
});
assert.strictEqual(marked1.parse('# header'), 'im marked1');
@@ -59,7 +59,7 @@ describe('Marked', () => {
marked1Renderer.heading = () => 'im marked1';
marked1.setOptions({
silent: true,
- renderer: marked1Renderer
+ renderer: marked1Renderer,
});
const marked2 = new Marked();
@@ -67,7 +67,7 @@ describe('Marked', () => {
marked2Renderer.heading = () => 'im marked2';
marked2.setOptions({
silent: true,
- renderer: marked2Renderer
+ renderer: marked2Renderer,
});
assert.strictEqual(marked1.parse('# header'), 'im marked1');
@@ -81,8 +81,8 @@ describe('Marked', () => {
renderer: {
heading() {
return 'test';
- }
- }
+ },
+ },
});
const tokens = marked1.lexer('# hi');
const html = marked1.parser(tokens);
@@ -116,7 +116,7 @@ describe('Marked', () => {
raw: src,
depth: 1,
text: 'im marked tokenizer',
- tokens: this.lexer.inlineTokens('im marked tokenizer')
+ tokens: this.lexer.inlineTokens('im marked tokenizer'),
};
};
diff --git a/test/unit/marked.test.js b/test/unit/marked.test.js
index 0277039843..6d2854f299 100644
--- a/test/unit/marked.test.js
+++ b/test/unit/marked.test.js
@@ -84,13 +84,13 @@ describe('marked unit', () => {
return {
type: 'underline',
raw: match[0], // This is the text that you want your token to consume from the source
- text: match[1].trim() // You can add additional properties to your tokens to pass along to the renderer
+ text: match[1].trim(), // You can add additional properties to your tokens to pass along to the renderer
};
}
},
renderer(token) {
return `${token.text}\n`;
- }
+ },
};
marked.use({ extensions: [underline] });
let html = marked.parse('Not Underlined\n:Underlined\nNot Underlined');
@@ -113,14 +113,14 @@ describe('marked unit', () => {
return {
type: 'underline',
raw: match[0], // This is the text that you want your token to consume from the source
- text: match[1].trim() // You can add additional properties to your tokens to pass along to the renderer
+ text: match[1].trim(), // You can add additional properties to your tokens to pass along to the renderer
};
}
},
renderer(token) {
return `${token.text}\n`;
- }
- }]
+ },
+ }],
};
marked.use(underline);
const html = marked.parse('Not Underlined A\n:Underlined B:\nNot Underlined C\n:Not Underlined D');
@@ -139,13 +139,13 @@ describe('marked unit', () => {
return {
type: 'underline',
raw: match[0], // This is the text that you want your token to consume from the source
- text: match[1].trim() // You can add additional properties to your tokens to pass along to the renderer
+ text: match[1].trim(), // You can add additional properties to your tokens to pass along to the renderer
};
}
},
renderer(token) {
return `${token.text}`;
- }
+ },
};
marked.use({ extensions: [underline] });
const html = marked.parse('Not Underlined =Underlined= Not Underlined');
@@ -170,7 +170,7 @@ describe('marked unit', () => {
type: 'descriptionList',
raw: match[0], // This is the text that you want your token to consume from the source
text: match[0].trim(), // You can add additional properties to your tokens to pass along to the renderer
- tokens: []
+ tokens: [],
};
this.lexer.inlineTokens(token.text, token.tokens);
return token;
@@ -178,7 +178,7 @@ describe('marked unit', () => {
},
renderer(token) {
return `${this.parser.parseInline(token.tokens)}\n
`;
- }
+ },
};
const description = {
@@ -193,7 +193,7 @@ describe('marked unit', () => {
type: 'description',
raw: match[0],
dt: [],
- dd: []
+ dd: [],
};
this.lexer.inline(match[1].trim(), token.dt);
this.lexer.inline(match[2].trim(), token.dd);
@@ -202,7 +202,7 @@ describe('marked unit', () => {
},
renderer(token) {
return `\n${this.parser.parseInline(token.dt)}${this.parser.parseInline(token.dd)}`;
- }
+ },
};
marked.use({ extensions: [descriptionlist, description] });
const html = marked.parse('A Description List with One Description:\n'
@@ -227,13 +227,13 @@ describe('marked unit', () => {
return {
type: 'underline',
raw: match[0], // This is the text that you want your token to consume from the source
- text: match[1].trim() // You can add additional properties to your tokens to pass along to the renderer
+ text: match[1].trim(), // You can add additional properties to your tokens to pass along to the renderer
};
}
},
renderer(token) {
return `${token.text}\n`;
- }
+ },
};
marked.use({ silent: true, extensions: [extension] });
const html = marked.parse(':test:\ntest\n');
@@ -251,7 +251,7 @@ describe('marked unit', () => {
return {
type: 'test',
raw: match[0], // This is the text that you want your token to consume from the source
- text: match[1].trim() // You can add additional properties to your tokens to pass along to the renderer
+ text: match[1].trim(), // You can add additional properties to your tokens to pass along to the renderer
};
}
},
@@ -260,7 +260,7 @@ describe('marked unit', () => {
return 'test';
}
return false;
- }
+ },
};
const fallbackRenderer = {
name: 'test',
@@ -270,7 +270,7 @@ describe('marked unit', () => {
return 'fallback';
}
return false;
- }
+ },
};
marked.use({ extensions: [fallbackRenderer, extension] });
const html = marked.parse(':Test:\n\n:test:\n\n:none:');
@@ -288,14 +288,14 @@ describe('marked unit', () => {
return {
type: 'test',
raw: match[0], // This is the text that you want your token to consume from the source
- text: match[1].trim() // You can add additional properties to your tokens to pass along to the renderer
+ text: match[1].trim(), // You can add additional properties to your tokens to pass along to the renderer
};
}
return false;
},
renderer(token) {
return token.text;
- }
+ },
};
const extension2 = {
name: 'test',
@@ -308,12 +308,12 @@ describe('marked unit', () => {
return {
type: 'test',
raw: match[0],
- text: match[1].trim().toUpperCase()
+ text: match[1].trim().toUpperCase(),
};
}
}
return false;
- }
+ },
};
marked.use({ extensions: [extension, extension2] });
const html = marked.parse(':Test:\n\n:test:');
@@ -330,7 +330,7 @@ describe('marked unit', () => {
},
renderer(token) {
return '' + token.text + ' RENDERER EXTENSION\n';
- }
+ },
},
{
name: 'code',
@@ -342,14 +342,14 @@ describe('marked unit', () => {
return {
type: 'code',
raw: match[0],
- text: match[1].trim() + ' TOKENIZER EXTENSION'
+ text: match[1].trim() + ' TOKENIZER EXTENSION',
};
}
},
renderer(token) {
return false; // fall back to default `code` renderer
- }
- }]
+ },
+ }],
};
marked.use(extension);
const html = marked.parse('# extension1\n:extension2:');
@@ -371,7 +371,7 @@ describe('marked unit', () => {
raw: match[0],
dt: this.lexer.inline(match[1].trim()),
dd: [],
- tokens: []
+ tokens: [],
};
this.lexer.inline(match[2].trim(), token.dd);
this.lexer.inline('unwalked', token.tokens);
@@ -381,13 +381,13 @@ describe('marked unit', () => {
renderer(token) {
return `\n${this.parser.parseInline(token.dt)} - ${this.parser.parseInline(token.tokens)}${this.parser.parseInline(token.dd)}`;
},
- childTokens: ['dd', 'dt']
+ childTokens: ['dd', 'dt'],
}],
walkTokens(token) {
if (token.type === 'text') {
token.text += ' walked';
}
- }
+ },
};
marked.use(walkableDescription);
const html = marked.parse(': Topic 1 : Description 1\n'
@@ -410,7 +410,7 @@ describe('marked unit', () => {
type: 'walkableDescription',
raw: match[0],
dt: [this.lexer.inline(match[1].trim())],
- dd: [[this.lexer.inline(match[2].trim())]]
+ dd: [[this.lexer.inline(match[2].trim())]],
};
return token;
}
@@ -418,13 +418,13 @@ describe('marked unit', () => {
renderer(token) {
return `\n${this.parser.parseInline(token.dt[0])}${this.parser.parseInline(token.dd[0][0])}`;
},
- childTokens: ['dd', 'dt']
+ childTokens: ['dd', 'dt'],
}],
walkTokens(token) {
if (token.type === 'text') {
token.text += ' walked';
}
- }
+ },
};
marked.use(walkableDescription);
const html = marked.parse(': Topic 1 : Description 1\n'
@@ -447,7 +447,7 @@ describe('marked unit', () => {
type: `block-${name}`,
raw: `::${name}\n`,
text,
- tokens: []
+ tokens: [],
};
this.lexer.inline(token.text, token.tokens);
return token;
@@ -455,7 +455,7 @@ describe('marked unit', () => {
},
renderer(token) {
return `<${token.type}>${this.parser.parseInline(token.tokens)}${token.type}>\n`;
- }
+ },
}, {
name: `inline-${name}`,
level: 'inline',
@@ -465,13 +465,13 @@ describe('marked unit', () => {
return {
type: `inline-${name}`,
raw: `:${name}`,
- text: `used ${name}`
+ text: `used ${name}`,
};
}
},
renderer(token) {
return token.text;
- }
+ },
}],
tokenizer: {
heading(src) {
@@ -481,13 +481,13 @@ describe('marked unit', () => {
raw: `# ${name}`,
text: `used ${name}`,
depth: 1,
- tokens: []
+ tokens: [],
};
this.lexer.inline(token.text, token.tokens);
return token;
}
return false;
- }
+ },
},
useNewRenderer: true,
renderer: {
@@ -496,13 +496,13 @@ describe('marked unit', () => {
return `${text}\n`;
}
return false;
- }
+ },
},
walkTokens(token) {
if (token.text === `used ${name}`) {
token.text += ' walked';
}
- }
+ },
};
}
@@ -517,7 +517,7 @@ describe('marked unit', () => {
},
renderer(token) {
return false;
- }
+ },
}, {
name: `inline-${name}`,
level: 'inline',
@@ -527,8 +527,8 @@ describe('marked unit', () => {
},
renderer(token) {
return false;
- }
- }]
+ },
+ }],
};
}
@@ -568,7 +568,7 @@ used extension2 walked
it('should merge extensions when calling marked.use with multiple extensions', () => {
marked.use(
createExtension('extension1'),
- createExtension('extension2')
+ createExtension('extension2'),
);
runTest();
@@ -579,7 +579,7 @@ used extension2 walked
createExtension('extension1'),
createExtension('extension2'),
createFalseExtension('extension1'),
- createFalseExtension('extension2')
+ createFalseExtension('extension2'),
);
runTest();
@@ -591,7 +591,7 @@ used extension2 walked
{ tokenizer: {} },
{ renderer: {} },
{ walkTokens: () => {} },
- { extensions: [] }
+ { extensions: [] },
);
// should not throw
@@ -602,7 +602,7 @@ used extension2 walked
it('should be async if any extension in use args is async', () => {
marked.use(
{ async: true },
- { async: false }
+ { async: false },
);
assert.ok(marked.defaults.async);
@@ -654,10 +654,10 @@ used extension2 walked
return {
type: 'inlineStyleTag',
raw: match[0], // This is the text that you want your token to consume from the source
- text: match[1]
+ text: match[1],
};
}
- }
+ },
},
{
name: 'styled',
@@ -669,7 +669,7 @@ used extension2 walked
return `${openingTag[1]} ${token.style}${openingTag[2]}`;
}
return text;
- }
+ },
}],
walkTokens(token) {
if (token.tokens) {
@@ -681,7 +681,7 @@ used extension2 walked
token.tokens.pop();
}
}
- }
+ },
};
marked.use(styleTags);
const html = marked.parse('This is a *paragraph* with blue text. {blue}\n'
@@ -696,8 +696,8 @@ used extension2 walked
renderer: {
paragraph() {
return 'extension';
- }
- }
+ },
+ },
};
mock.method(extension.renderer, 'paragraph');
marked.use(extension);
@@ -714,12 +714,12 @@ used extension2 walked
type: 'paragraph',
raw: text,
text: 'extension',
- tokens: []
+ tokens: [],
};
this.lexer.inline(token.text, token.tokens);
return token;
- }
- }
+ },
+ },
};
mock.method(extension.tokenizer, 'paragraph');
marked.use(extension);
@@ -733,7 +733,7 @@ used extension2 walked
const extension = {
walkTokens(token) {
walked++;
- }
+ },
};
marked.use(extension);
marked.parse('text');
@@ -742,7 +742,7 @@ used extension2 walked
it('should use options from extension', () => {
const extension = {
- breaks: true
+ breaks: true,
};
marked.use(extension);
const html = marked.parse('line1\nline2');
@@ -757,13 +757,13 @@ used extension2 walked
if (token.walkedOnce) {
walkedTwice++;
}
- }
+ },
};
const extension2 = {
walkTokens(token) {
walkedOnce++;
token.walkedOnce = true;
- }
+ },
};
marked.use(extension1);
marked.use(extension2);
@@ -781,16 +781,16 @@ used extension2 walked
},
html() {
return 'extension1 html\n';
- }
- }
+ },
+ },
};
const extension2 = {
useNewRenderer: true,
renderer: {
paragraph() {
return 'extension2 paragraph\n';
- }
- }
+ },
+ },
};
marked.use(extension1);
marked.use(extension2);
@@ -813,8 +813,8 @@ paragraph
return 'extension1 paragraph\n';
}
return false;
- }
- }
+ },
+ },
};
const extension2 = {
useNewRenderer: true,
@@ -824,8 +824,8 @@ paragraph
return 'extension2 paragraph\n';
}
return false;
- }
- }
+ },
+ },
};
marked.use(extension1);
marked.use(extension2);
@@ -851,8 +851,8 @@ original
},
paragraph() {
return this.options ? 'shorthand options\n' : 'shorthand no options\n';
- }
- }
+ },
+ },
};
marked.use(extension);
const html = marked.parse(`
@@ -964,7 +964,7 @@ br
['paragraph', 'brbr'],
['text', 'br'],
['br', ''],
- ['text', 'br']
+ ['text', 'br'],
]);
});
@@ -975,7 +975,7 @@ br
token.text += ' walked';
token.tokens = this.Lexer.lexInline(token.text);
}
- }
+ },
});
assert.strictEqual(marked.parse('*text*').trim(), 'text walked
');
});
@@ -989,7 +989,7 @@ br
token.text += ' walked';
token.tokens = this.Lexer.lexInline(token.text);
}
- }
+ },
});
const promise = marked.parse('*text*');
assert.ok(promise instanceof Promise);
@@ -999,7 +999,7 @@ br
it('should return promise if async and no walkTokens function', async() => {
marked.use({
- async: true
+ async: true,
});
const promise = marked.parse('*text*');
assert.ok(promise instanceof Promise);
diff --git a/test/update-specs.js b/test/update-specs.js
index b3aad7f0dd..58ccf21c14 100644
--- a/test/update-specs.js
+++ b/test/update-specs.js
@@ -57,7 +57,7 @@ async function updateGfm(dir) {
section: `[extension] ${section}`,
html,
markdown,
- example
+ example,
});
});
});