From 224e248526b8b8df9ccb4524df121e6d21b7d0d1 Mon Sep 17 00:00:00 2001 From: guanghechen Date: Fri, 20 Sep 2024 16:24:01 +0800 Subject: [PATCH] :wrench: chore: fix lint --- .yarnrc.yml | 4 +- eslint.config.js | 14 ++ jest.config.mjs | 1 - package.json | 4 +- .../__test__/footnote-definition.spec.ts | 1 + .../character/src/util/entity-reference.ts | 2 +- packages/character/src/util/searcher.ts | 2 +- .../src/processor/inline/single-priority.ts | 1 + packages/core-tokenizer/README.md | 3 +- packages/core-tokenizer/src/types/token.ts | 1 - packages/core-tokenizer/src/util/uri.ts | 2 +- packages/markup-weaver/src/MarkupWeaver.ts | 2 +- packages/parser-gfm/CHANGELOG.md | 3 +- .../__test__/answer.spec.ts | 1 - .../jest-for-tokenizer/src/TokenizerTester.ts | 1 - scripts/gfm/{classify.js => classify.mjs} | 26 +-- scripts/gfm/{fetch.js => fetch.mjs} | 16 +- scripts/handlebar/tokenizer.ts | 4 +- scripts/handlebar/util.ts | 6 +- scripts/nx/project.mjs | 4 +- scripts/unicode/{fetch.js => fetch.mjs} | 8 +- tokenizers/definition/src/util/link-label.ts | 2 +- .../ecma-import/__test__/ecma-import.spec.ts | 38 ++--- tokenizers/ecma-import/src/util.ts | 4 +- .../__test__/tokenizer.spec.ts | 1 - .../__test__/tokenizer.spec.ts | 1 - tokenizers/footnote/__test__/footnote.spec.ts | 1 - yarn.lock | 156 +++++++++--------- 28 files changed, 154 insertions(+), 155 deletions(-) rename scripts/gfm/{classify.js => classify.mjs} (74%) rename scripts/gfm/{fetch.js => fetch.mjs} (87%) rename scripts/unicode/{fetch.js => fetch.mjs} (77%) diff --git a/.yarnrc.yml b/.yarnrc.yml index f1ce0e7ac..9ef03c50a 100644 --- a/.yarnrc.yml +++ b/.yarnrc.yml @@ -1,10 +1,10 @@ nodeLinker: node-modules -npmRegistryServer: "https://registry.npmjs.org/" +npmRegistryServer: 'https://registry.npmjs.org/' plugins: - path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs - spec: "@yarnpkg/plugin-interactive-tools" + spec: '@yarnpkg/plugin-interactive-tools' preferInteractive: true diff --git a/eslint.config.js b/eslint.config.js index 2346e7d9e..50c16be2f 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -22,8 +22,22 @@ export default [ { files: ['**/src/**/*.ts'], rules: { + '@typescript-eslint/no-invalid-void-type': 'off', '@typescript-eslint/no-unnecessary-type-arguments': 'off', + '@typescript-eslint/no-unused-vars': [ + 'error', + { + args: 'all', + argsIgnorePattern: '^_', + caughtErrors: 'all', + caughtErrorsIgnorePattern: '^_', + destructuredArrayIgnorePattern: '^_', + varsIgnorePattern: '^_', + ignoreRestSiblings: true, + }, + ], 'import/no-named-as-default': 'off', + 'space-in-parens': 'off', }, }, ] diff --git a/jest.config.mjs b/jest.config.mjs index 795cd6a6f..076e55aed 100644 --- a/jest.config.mjs +++ b/jest.config.mjs @@ -1,4 +1,3 @@ -/* eslint-disable import/no-extraneous-dependencies */ import { tsMonorepoConfig } from '@guanghechen/jest-config' import path from 'node:path' import url from 'node:url' diff --git a/package.json b/package.json index eb1b2c6a1..f68587768 100644 --- a/package.json +++ b/package.json @@ -54,11 +54,11 @@ "@guanghechen/conventional-changelog": "^6.0.0-alpha.2", "@guanghechen/eslint-config": "^7.0.4", "@guanghechen/helper-jest": "^6.0.0-alpha.5", - "@guanghechen/helper-string": "^6.0.0-alpha.2", "@guanghechen/jest-config": "^6.0.0-alpha.2", "@guanghechen/reporter": "^1.0.0", "@guanghechen/rollup-config": "^6.0.0-alpha.6", "@guanghechen/script-doc-link": "^6.0.0-alpha.17", + "@guanghechen/string": "^1.0.1", "@types/jest": "29.5.13", "@types/node": "^20.16.5", "cross-env": "^7.0.3", @@ -74,7 +74,7 @@ "pinst": "3.0.0", "prettier": "3.3.3", "rimraf": "^6.0.1", - "rollup": "^4.22.0", + "rollup": "^4.22.1", "ts-jest": "29.2.5", "ts-node": "10.9.2", "tsconfig-paths": "4.2.0", diff --git a/packages/ast-util/__test__/footnote-definition.spec.ts b/packages/ast-util/__test__/footnote-definition.spec.ts index f3d75fdee..68c86ee51 100644 --- a/packages/ast-util/__test__/footnote-definition.spec.ts +++ b/packages/ast-util/__test__/footnote-definition.spec.ts @@ -32,6 +32,7 @@ describe('calcFootnoteDefinitionMap', function () { identifier: 'bravo', label: 'Bravo', children: [ + // eslint-disable-next-line @typescript-eslint/consistent-type-assertions { type: 'text', value: 'bravo and charlie.', diff --git a/packages/character/src/util/entity-reference.ts b/packages/character/src/util/entity-reference.ts index 8228e06f2..0cb252b89 100644 --- a/packages/character/src/util/entity-reference.ts +++ b/packages/character/src/util/entity-reference.ts @@ -216,7 +216,7 @@ export function eatEntityReference( try { if (val === 0) val = UnicodeCodePoint.REPLACEMENT_CHARACTER value = String.fromCodePoint(val) - } catch (error) { + } catch (_) { value = String.fromCodePoint(UnicodeCodePoint.REPLACEMENT_CHARACTER) } return { nextIndex: i + 1, value } diff --git a/packages/character/src/util/searcher.ts b/packages/character/src/util/searcher.ts index 886d54138..29d2dcf61 100644 --- a/packages/character/src/util/searcher.ts +++ b/packages/character/src/util/searcher.ts @@ -50,7 +50,7 @@ export function createCodePointSearcher( * But only when orderedRangeCodePoints.length * 1.5 < orderedCodePoints.length, * the range binary search could work better (1.5 is just a hypothesis). * - * The code point ranges are something like [left_1, right_1, left_2, right_2, ...left_n, right_n], + * The code point ranges are something like [left_1, right_1, left_2, ...left_n, right_n], * - The good ranges: [left_1, right_0), ..., [left_i, right_i), ..., [left_n, right_n] * - The bad ranges: [-Infinity, left_1), ..., [right_i, left_{i+1}), ..., [right_n, Infinity] */ diff --git a/packages/core-parser/src/processor/inline/single-priority.ts b/packages/core-parser/src/processor/inline/single-priority.ts index df9157dd3..9dbb1b27a 100644 --- a/packages/core-parser/src/processor/inline/single-priority.ts +++ b/packages/core-parser/src/processor/inline/single-priority.ts @@ -142,6 +142,7 @@ export const createSinglePriorityDelimiterProcessor = (): IDelimiterProcessor => ) // Set internalTokens returned by processDelimiterPair. + // eslint-disable-next-line no-lone-blocks { for (const token of result.tokens) { if (token._tokenizer == null) token._tokenizer = hook.name diff --git a/packages/core-tokenizer/README.md b/packages/core-tokenizer/README.md index 3cb33399f..6599f138a 100644 --- a/packages/core-tokenizer/README.md +++ b/packages/core-tokenizer/README.md @@ -93,8 +93,7 @@ along the existing nesting structure (such as the above [Blockquote][@yozora/tok to complete the matching, and then gets a matching opportunity. In order to make the tokenizers work with each other transparently, when designing the life cycle methods of the block-level tokenizer in the `match-block` stage, the parsing logic of the nested structure lifted into [@yozora/core-parser -][], and use a special data structure called `PhrasingContentLine` as the actual parsing unit of a -line: +][], and use a special data structure called `PhrasingContentLine` as the actual parsing unit of a line: ```typescript export interface PhrasingContentLine { diff --git a/packages/core-tokenizer/src/types/token.ts b/packages/core-tokenizer/src/types/token.ts index 4e337b09d..3ff90e15c 100644 --- a/packages/core-tokenizer/src/types/token.ts +++ b/packages/core-tokenizer/src/types/token.ts @@ -4,7 +4,6 @@ import type { INodeInterval } from '@yozora/character' /** * Make a set of properties by key `K` become optional from `T`. */ -// eslint-disable-next-line @typescript-eslint/ban-types declare type IPickPartial = Omit & Partial> /** diff --git a/packages/core-tokenizer/src/util/uri.ts b/packages/core-tokenizer/src/util/uri.ts index 87a073982..41f8b2c57 100644 --- a/packages/core-tokenizer/src/util/uri.ts +++ b/packages/core-tokenizer/src/util/uri.ts @@ -14,7 +14,7 @@ export function encodeLinkDestination(destination: string): string { const result2 = decodeURIComponent(result) if (result2 === result) break result = result2 - } catch (error) { + } catch (_) { break } } diff --git a/packages/markup-weaver/src/MarkupWeaver.ts b/packages/markup-weaver/src/MarkupWeaver.ts index cfaee95aa..39be9b102 100644 --- a/packages/markup-weaver/src/MarkupWeaver.ts +++ b/packages/markup-weaver/src/MarkupWeaver.ts @@ -199,7 +199,7 @@ export class MarkupWeaver implements IMarkupWeaver { const isBlockLevel: boolean = weaver.isBlockLevel(node, ctx, childIndex) if (isBlockLevel) { dequeue(node) - throw new TypeError(`[MarkupWeaver.weave] Cannot processInline for block-level node.`) + throw new TypeError('[MarkupWeaver.weave] Cannot processInline for block-level node.') } let result = '' diff --git a/packages/parser-gfm/CHANGELOG.md b/packages/parser-gfm/CHANGELOG.md index 2c73c64f1..999d0cd97 100644 --- a/packages/parser-gfm/CHANGELOG.md +++ b/packages/parser-gfm/CHANGELOG.md @@ -740,8 +740,7 @@ All notable changes to this project will be documented in this file. See ([ab1caca](https://github.com/yozorajs/yozora/commit/ab1caca36d2009b6487151eabf7e59361a837b05)) - :bug: [tokenizercore] fix: mistaken '>' for ']' in eatAndCollectLinkLabel ([4277f82](https://github.com/yozorajs/yozora/commit/4277f820f875eada92a4aaba06299ef7c54b38f3)) -- :bug: [tokenizer-line-break, tokenizer-text] fix: remove spaces at the end of the line and - beginning +- :bug: [tokenizer-line-break, tokenizer-text] fix: remove spaces at the end of the line and beginning ([5641968](https://github.com/yozorajs/yozora/commit/5641968da7c1355141f466dd347879dccd42bbca)) - :bug: [tokenizer-list-*-item] fix: fix gfm#242, gfm#298: ListItem could contains blank lines ([edf1b58](https://github.com/yozorajs/yozora/commit/edf1b58898c3c887e5d0af717af174a9cd40ea85)), diff --git a/scaffolds/jest-for-tokenizer/__test__/answer.spec.ts b/scaffolds/jest-for-tokenizer/__test__/answer.spec.ts index 782c4badc..f511ae833 100644 --- a/scaffolds/jest-for-tokenizer/__test__/answer.spec.ts +++ b/scaffolds/jest-for-tokenizer/__test__/answer.spec.ts @@ -1,4 +1,3 @@ -/* eslint-disable import/no-extraneous-dependencies */ import { InlineCodeTokenizerName } from '@yozora/tokenizer-inline-code' import InlineMathTokenizer from '@yozora/tokenizer-inline-math' import { parsers, weavers } from 'jest.setup' diff --git a/scaffolds/jest-for-tokenizer/src/TokenizerTester.ts b/scaffolds/jest-for-tokenizer/src/TokenizerTester.ts index 1191d2ff8..623690dcf 100644 --- a/scaffolds/jest-for-tokenizer/src/TokenizerTester.ts +++ b/scaffolds/jest-for-tokenizer/src/TokenizerTester.ts @@ -1,4 +1,3 @@ -/* eslint-disable jest/no-export, jest/valid-title */ import type { IParser } from '@yozora/core-parser' import { BaseTester } from './BaseTester' import type { IYozoraUseCase } from './types' diff --git a/scripts/gfm/classify.js b/scripts/gfm/classify.mjs similarity index 74% rename from scripts/gfm/classify.js rename to scripts/gfm/classify.mjs index 81b12ddad..f122c1171 100644 --- a/scripts/gfm/classify.js +++ b/scripts/gfm/classify.mjs @@ -1,8 +1,13 @@ /* eslint-disable import/no-extraneous-dependencies */ -const chalk = require('chalk') -const fs = require('node:fs') -const path = require('node:path') -const gfmClassifyData = require('./data.json') +import chalk from 'chalk' +import fs from 'node:fs' +import path from 'node:path' +import url from 'node:url' +import parserGfmData from './data-classify/parser-gfm.json' +import gfmClassifyData from './data.json' + +const __dirname = path.dirname(url.fileURLToPath(import.meta.url)) +const rootDir = path.resolve(__dirname, '../../') class GFMExampleClassifier { constructor(gfmExamples) { @@ -11,23 +16,22 @@ class GFMExampleClassifier { } classifyToPath(caseRootDir, groups) { - const self = this for (const group of groups) { const excluded = group.excluded || [] const groupDir = path.resolve(caseRootDir, group.name) if (!fs.existsSync(groupDir)) fs.mkdirSync(groupDir, { recursive: true }) for (let i = group.start; i <= group.end; ++i) { if (excluded.includes(i)) continue - const fileName = '#' + ('' + i).padStart(self.numberLength, '0') + '.json' + const fileName = '#' + ('' + i).padStart(this.numberLength, '0') + '.json' const caseFilePath = path.join(groupDir, fileName) - const gfmExample = self.gfmExamples[i] - const data = self.mapGFMExampleDataToCase(gfmExample) + const gfmExample = this.gfmExamples[i] + const data = this.mapGFMExampleDataToCase(gfmExample) const content = JSON.stringify(data, null, 2) fs.writeFileSync(caseFilePath, content, 'utf-8') console.log(chalk.green(`Add case ${caseFilePath}`)) } } - return self + return this } mapGFMExampleDataToCase(gfmExample) { @@ -47,10 +51,8 @@ class GFMExampleClassifier { const classifier = new GFMExampleClassifier(gfmClassifyData) -const rootDir = path.resolve(__dirname, '../../') - // parser-gfm test cases classifier.classifyToPath( path.resolve(rootDir, 'scaffolds/jest-for-tokenizer/fixtures/gfm'), - require('./data-classify/parser-gfm.json'), + parserGfmData, ) diff --git a/scripts/gfm/fetch.js b/scripts/gfm/fetch.mjs similarity index 87% rename from scripts/gfm/fetch.js rename to scripts/gfm/fetch.mjs index 348b43236..5df3f6a98 100644 --- a/scripts/gfm/fetch.js +++ b/scripts/gfm/fetch.mjs @@ -1,8 +1,9 @@ +/* eslint-disable no-undef */ /** * 将 GFM 中的 example 元素解析成 JSON 数据 * @param exampleEl example 元素 */ -function parseGFMExample(exampleEl) { +export function parseGFMExample(exampleEl) { if (exampleEl == null) return null const exampleId = exampleEl.id || '' @@ -40,7 +41,7 @@ function parseGFMExample(exampleEl) { return result } -function fetchGFMExamples(...exampleNos) { +export function fetchGFMExamples(...exampleNos) { const exampleEls = exampleNos.map(exampleNo => { const id = 'example-' + exampleNo const elementEl = document.getElementById(id) @@ -51,21 +52,14 @@ function fetchGFMExamples(...exampleNos) { return JSON.stringify(result, null, 2) } -function fetchGFMExamplesInRange(left, right = left) { +export function fetchGFMExamplesInRange(left, right = left) { const exampleNos = [] for (let i = left; i <= right; ++i) exampleNos.push(i) return fetchGFMExamples(...exampleNos) } -function fetchExamplesAll() { +export function fetchExamplesAll() { const exampleEls = document.querySelectorAll('[id^=example]') const result = Array.from(exampleEls).map(exampleEl => parseGFMExample(exampleEl)) return JSON.stringify(result, null, 2) } - -module.exports = { - fetchExamplesAll, - fetchGFMExamples, - fetchGFMExamplesInRange, - parseGFMExample, -} diff --git a/scripts/handlebar/tokenizer.ts b/scripts/handlebar/tokenizer.ts index bc833fa9e..f0a04fd65 100644 --- a/scripts/handlebar/tokenizer.ts +++ b/scripts/handlebar/tokenizer.ts @@ -172,7 +172,7 @@ __**__foo__**__ inGfmEx: true, isInlineTokenizer: false, isBlockTokenizer: true, - usageDemoSourceContent: `"source contents"`, + usageDemoSourceContent: '"source contents"', }, // fenced-code { @@ -528,7 +528,7 @@ Foo *bar* inGfmEx: true, isInlineTokenizer: true, isBlockTokenizer: false, - usageDemoSourceContent: `"hello $.;'there"`, + usageDemoSourceContent: '"hello $.;\'there"', }, // thematic-break { diff --git a/scripts/handlebar/util.ts b/scripts/handlebar/util.ts index 55782d062..0aba84096 100644 --- a/scripts/handlebar/util.ts +++ b/scripts/handlebar/util.ts @@ -13,7 +13,7 @@ import { toTitleCase, toTrim, toUpperCase, -} from '@guanghechen/helper-string' +} from '@guanghechen/string' import Handlebars from 'handlebars' import fs from 'node:fs' import path from 'node:path' @@ -51,7 +51,7 @@ Handlebars.registerHelper('transform', (...args: any[]): string => { const value = args[args.length - 1] const transformFns = args .slice(0, args.length - 2) - .map(name => transformers[name]) + .map((name: string) => transformers[name as keyof typeof transformers]) .filter(fn => fn != null) const transform = composeTextTransformers(...transformFns) return transform(value) @@ -97,7 +97,7 @@ export function renderMarkdown( const resolvedContent = content - .replace(regex, (m, templateName): string => { + .replace(regex, (_, templateName): string => { const result = renderTemplate(templateName, data) return `\n\n\n\n${result}\n\n\n\n` }) diff --git a/scripts/nx/project.mjs b/scripts/nx/project.mjs index 2ee5475bf..04a401036 100644 --- a/scripts/nx/project.mjs +++ b/scripts/nx/project.mjs @@ -36,11 +36,11 @@ export async function genAndWriteNxProjectJson(params, reporter) { const { workspaceRoot, projectDir } = params const absolutePackageDir = path.resolve(workspaceRoot, projectDir) if (!fs.existsSync(absolutePackageDir)) { - reporter?.warn(`skipped. packageDirFromRoot is not found.`, projectDir) + reporter?.warn('skipped. packageDirFromRoot is not found.', projectDir) return } if (!fs.statSync(absolutePackageDir).isDirectory()) { - reporter?.warn(`skipped. packageDirFromRoot is not a folder.`, projectDir) + reporter?.warn('skipped. packageDirFromRoot is not a folder.', projectDir) return } const projectJsonPath = path.join(absolutePackageDir, 'project.json') diff --git a/scripts/unicode/fetch.js b/scripts/unicode/fetch.mjs similarity index 77% rename from scripts/unicode/fetch.js rename to scripts/unicode/fetch.mjs index 4c980a5e7..f94638ccc 100644 --- a/scripts/unicode/fetch.js +++ b/scripts/unicode/fetch.mjs @@ -1,7 +1,7 @@ /** * @see https://www.fileformat.info/info/unicode/category/Pd/list.htm */ -function fetchUnicodeCharacter(tbody) { +export function fetchUnicodeCharacter(tbody) { const trList = tbody.querySelectorAll('tr') const items = [] for (let i = 0; i < trList.length; ++i) { @@ -14,12 +14,8 @@ function fetchUnicodeCharacter(tbody) { const name = nameText.trim().split(/[\s-]/g).join('_') const value = valueText.trim().toLowerCase().replace(/^u\+/i, '0x0') - const item = ' /**\n ' + '* @see ' + url + '\n */\n ' + `${name} = ${value},` + const item = ' /**\n * @see ' + url + '\n */\n ' + name + ` = ${value},` items.push(item) } return items.join('\n') } - -module.exports = { - fetchUnicodeCharacter, -} diff --git a/tokenizers/definition/src/util/link-label.ts b/tokenizers/definition/src/util/link-label.ts index dc73bd8ec..94cc31479 100644 --- a/tokenizers/definition/src/util/link-label.ts +++ b/tokenizers/definition/src/util/link-label.ts @@ -77,7 +77,7 @@ export function eatAndCollectLinkLabel( } i += 1 - // eslint-disable-next-line no-param-reassign + state.nodePoints.push(p) } diff --git a/tokenizers/ecma-import/__test__/ecma-import.spec.ts b/tokenizers/ecma-import/__test__/ecma-import.spec.ts index 554b4dfa5..62d28533f 100644 --- a/tokenizers/ecma-import/__test__/ecma-import.spec.ts +++ b/tokenizers/ecma-import/__test__/ecma-import.spec.ts @@ -11,30 +11,30 @@ createTokenizerTesters( describe('util', function () { test('regex1', function () { - expect(regex1.test(`import '@yozora/parser'`)).toBe(true) - expect(regex1.test(`import "@yozora/parser"`)).toBe(true) - expect(regex1.test(`import '@yozora/parser"`)).toBe(false) - expect(regex1.test(`import "@yozora/parser'`)).toBe(false) - expect(regex1.test(`import Parser from '@yozora/parser'`)).toBe(false) + expect(regex1.test("import '@yozora/parser'")).toBe(true) + expect(regex1.test('import "@yozora/parser"')).toBe(true) + expect(regex1.test('import \'@yozora/parser"')).toBe(false) + expect(regex1.test('import "@yozora/parser\'')).toBe(false) + expect(regex1.test("import Parser from '@yozora/parser'")).toBe(false) }) test('regex2', function () { - expect(regex2.test(`import Parser from '@yozora/parser'`)).toBe(true) - expect(regex2.test(`import Parser from "@yozora/parser"`)).toBe(true) - expect(regex2.test(`import Parser from '@yozora/parser"`)).toBe(false) - expect(regex2.test(`import Parser from "@yozora/parser'`)).toBe(false) - expect(regex2.test(`import { Parser } from "@yozora/parser'`)).toBe(false) + expect(regex2.test("import Parser from '@yozora/parser'")).toBe(true) + expect(regex2.test('import Parser from "@yozora/parser"')).toBe(true) + expect(regex2.test('import Parser from \'@yozora/parser"')).toBe(false) + expect(regex2.test('import Parser from "@yozora/parser\'')).toBe(false) + expect(regex2.test('import { Parser } from "@yozora/parser\'')).toBe(false) }) test('regex3', function () { - expect(regex3.test(`import Parser, { a, b as c } from '@yozora/parser'`)).toBe(true) - expect(regex3.test(`import Parser, { a as c, b as d, e } from "@yozora/parser"`)).toBe(true) - expect(regex3.test(`import Parser, { a, b, c } from "@yozora/parser"`)).toBe(true) - expect(regex3.test(`import { a, b as c } from '@yozora/parser'`)).toBe(true) - expect(regex3.test(`import { a as c, b as d, e } from "@yozora/parser"`)).toBe(true) - expect(regex3.test(`import { a, b, c } from "@yozora/parser"`)).toBe(true) - expect(regex3.test(`import { a, b, c }, Parser from "@yozora/parser"`)).toBe(false) - expect(regex3.test(`import Parser from '@yozora/parser"`)).toBe(false) - expect(regex3.test(`import Parser from "@yozora/parser'`)).toBe(false) + expect(regex3.test("import Parser, { a, b as c } from '@yozora/parser'")).toBe(true) + expect(regex3.test('import Parser, { a as c, b as d, e } from "@yozora/parser"')).toBe(true) + expect(regex3.test('import Parser, { a, b, c } from "@yozora/parser"')).toBe(true) + expect(regex3.test("import { a, b as c } from '@yozora/parser'")).toBe(true) + expect(regex3.test('import { a as c, b as d, e } from "@yozora/parser"')).toBe(true) + expect(regex3.test('import { a, b, c } from "@yozora/parser"')).toBe(true) + expect(regex3.test('import { a, b, c }, Parser from "@yozora/parser"')).toBe(false) + expect(regex3.test('import Parser from \'@yozora/parser"')).toBe(false) + expect(regex3.test('import Parser from "@yozora/parser\'')).toBe(false) }) }) diff --git a/tokenizers/ecma-import/src/util.ts b/tokenizers/ecma-import/src/util.ts index be5ffcb22..e7e893d4b 100644 --- a/tokenizers/ecma-import/src/util.ts +++ b/tokenizers/ecma-import/src/util.ts @@ -25,9 +25,9 @@ export const regex2 = new RegExp( * import { YozoraParser, YozoraParser as Parser } from '@yozora/parser' */ export const regex3 = new RegExp( - '^import\\s+(?:([\\w]+)\\s*,\\s*)?'+ + '^import\\s+(?:([\\w]+)\\s*,\\s*)?' + namedImportRegex.source + - `from\\s+(['"])([^'"]+)\\3` + + 'from\\s+([\'"])([^\'"]+)\\3' + endRegex.source, ) diff --git a/tokenizers/footnote-definition/__test__/tokenizer.spec.ts b/tokenizers/footnote-definition/__test__/tokenizer.spec.ts index 0e725dc11..47a259cbf 100644 --- a/tokenizers/footnote-definition/__test__/tokenizer.spec.ts +++ b/tokenizers/footnote-definition/__test__/tokenizer.spec.ts @@ -1,4 +1,3 @@ -/* eslint-disable import/no-extraneous-dependencies */ import { createTokenizerTesters } from '@yozora/jest-for-tokenizer' import { DefinitionTokenizerName } from '@yozora/tokenizer-definition' import FootnoteTokenizer from '@yozora/tokenizer-footnote' diff --git a/tokenizers/footnote-reference/__test__/tokenizer.spec.ts b/tokenizers/footnote-reference/__test__/tokenizer.spec.ts index 13b0f3d15..3b2ef3386 100644 --- a/tokenizers/footnote-reference/__test__/tokenizer.spec.ts +++ b/tokenizers/footnote-reference/__test__/tokenizer.spec.ts @@ -1,4 +1,3 @@ -/* eslint-disable import/no-extraneous-dependencies */ import { createTokenizerTesters } from '@yozora/jest-for-tokenizer' import { DefinitionTokenizerName } from '@yozora/tokenizer-definition' import FootnoteTokenizer from '@yozora/tokenizer-footnote' diff --git a/tokenizers/footnote/__test__/footnote.spec.ts b/tokenizers/footnote/__test__/footnote.spec.ts index 8ef35d9b1..e6064ad4c 100644 --- a/tokenizers/footnote/__test__/footnote.spec.ts +++ b/tokenizers/footnote/__test__/footnote.spec.ts @@ -1,4 +1,3 @@ -/* eslint-disable import/no-extraneous-dependencies */ import { createTokenizerTesters } from '@yozora/jest-for-tokenizer' import { DefinitionTokenizerName } from '@yozora/tokenizer-definition' import FootnoteDefinitionTokenizer from '@yozora/tokenizer-footnote-definition' diff --git a/yarn.lock b/yarn.lock index 0e4245e7d..17047c37e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -608,13 +608,6 @@ __metadata: languageName: node linkType: hard -"@guanghechen/helper-string@npm:^6.0.0-alpha.2": - version: 6.0.0-alpha.2 - resolution: "@guanghechen/helper-string@npm:6.0.0-alpha.2" - checksum: e19d156e6c8b09bcecd526cebd90521055ef9edc9c34c7e384a82aad6205fe105a0c8657c9467bb50616b622b3d015b224129b9f3d3faf75b2e7a5373e325aa8 - languageName: node - linkType: hard - "@guanghechen/invariant@npm:^6.0.1": version: 6.0.1 resolution: "@guanghechen/invariant@npm:6.0.1" @@ -694,6 +687,13 @@ __metadata: languageName: node linkType: hard +"@guanghechen/string@npm:^1.0.1": + version: 1.0.1 + resolution: "@guanghechen/string@npm:1.0.1" + checksum: 41548288d8fc3e07431af02b5a685ed6cda0e8341973c04cc48a8710d46b8a438910f6ad08fc0c30d95172e47fb0462b2772e6c9286cba35532ab24ad6afe4c3 + languageName: node + linkType: hard + "@guanghechen/types@npm:^1.0.0": version: 1.0.0 resolution: "@guanghechen/types@npm:1.0.0" @@ -1738,114 +1738,114 @@ __metadata: languageName: node linkType: hard -"@rollup/rollup-android-arm-eabi@npm:4.22.0": - version: 4.22.0 - resolution: "@rollup/rollup-android-arm-eabi@npm:4.22.0" +"@rollup/rollup-android-arm-eabi@npm:4.22.1": + version: 4.22.1 + resolution: "@rollup/rollup-android-arm-eabi@npm:4.22.1" conditions: os=android & cpu=arm languageName: node linkType: hard -"@rollup/rollup-android-arm64@npm:4.22.0": - version: 4.22.0 - resolution: "@rollup/rollup-android-arm64@npm:4.22.0" +"@rollup/rollup-android-arm64@npm:4.22.1": + version: 4.22.1 + resolution: "@rollup/rollup-android-arm64@npm:4.22.1" conditions: os=android & cpu=arm64 languageName: node linkType: hard -"@rollup/rollup-darwin-arm64@npm:4.22.0": - version: 4.22.0 - resolution: "@rollup/rollup-darwin-arm64@npm:4.22.0" +"@rollup/rollup-darwin-arm64@npm:4.22.1": + version: 4.22.1 + resolution: "@rollup/rollup-darwin-arm64@npm:4.22.1" conditions: os=darwin & cpu=arm64 languageName: node linkType: hard -"@rollup/rollup-darwin-x64@npm:4.22.0": - version: 4.22.0 - resolution: "@rollup/rollup-darwin-x64@npm:4.22.0" +"@rollup/rollup-darwin-x64@npm:4.22.1": + version: 4.22.1 + resolution: "@rollup/rollup-darwin-x64@npm:4.22.1" conditions: os=darwin & cpu=x64 languageName: node linkType: hard -"@rollup/rollup-linux-arm-gnueabihf@npm:4.22.0": - version: 4.22.0 - resolution: "@rollup/rollup-linux-arm-gnueabihf@npm:4.22.0" +"@rollup/rollup-linux-arm-gnueabihf@npm:4.22.1": + version: 4.22.1 + resolution: "@rollup/rollup-linux-arm-gnueabihf@npm:4.22.1" conditions: os=linux & cpu=arm & libc=glibc languageName: node linkType: hard -"@rollup/rollup-linux-arm-musleabihf@npm:4.22.0": - version: 4.22.0 - resolution: "@rollup/rollup-linux-arm-musleabihf@npm:4.22.0" +"@rollup/rollup-linux-arm-musleabihf@npm:4.22.1": + version: 4.22.1 + resolution: "@rollup/rollup-linux-arm-musleabihf@npm:4.22.1" conditions: os=linux & cpu=arm & libc=musl languageName: node linkType: hard -"@rollup/rollup-linux-arm64-gnu@npm:4.22.0": - version: 4.22.0 - resolution: "@rollup/rollup-linux-arm64-gnu@npm:4.22.0" +"@rollup/rollup-linux-arm64-gnu@npm:4.22.1": + version: 4.22.1 + resolution: "@rollup/rollup-linux-arm64-gnu@npm:4.22.1" conditions: os=linux & cpu=arm64 & libc=glibc languageName: node linkType: hard -"@rollup/rollup-linux-arm64-musl@npm:4.22.0": - version: 4.22.0 - resolution: "@rollup/rollup-linux-arm64-musl@npm:4.22.0" +"@rollup/rollup-linux-arm64-musl@npm:4.22.1": + version: 4.22.1 + resolution: "@rollup/rollup-linux-arm64-musl@npm:4.22.1" conditions: os=linux & cpu=arm64 & libc=musl languageName: node linkType: hard -"@rollup/rollup-linux-powerpc64le-gnu@npm:4.22.0": - version: 4.22.0 - resolution: "@rollup/rollup-linux-powerpc64le-gnu@npm:4.22.0" +"@rollup/rollup-linux-powerpc64le-gnu@npm:4.22.1": + version: 4.22.1 + resolution: "@rollup/rollup-linux-powerpc64le-gnu@npm:4.22.1" conditions: os=linux & cpu=ppc64 & libc=glibc languageName: node linkType: hard -"@rollup/rollup-linux-riscv64-gnu@npm:4.22.0": - version: 4.22.0 - resolution: "@rollup/rollup-linux-riscv64-gnu@npm:4.22.0" +"@rollup/rollup-linux-riscv64-gnu@npm:4.22.1": + version: 4.22.1 + resolution: "@rollup/rollup-linux-riscv64-gnu@npm:4.22.1" conditions: os=linux & cpu=riscv64 & libc=glibc languageName: node linkType: hard -"@rollup/rollup-linux-s390x-gnu@npm:4.22.0": - version: 4.22.0 - resolution: "@rollup/rollup-linux-s390x-gnu@npm:4.22.0" +"@rollup/rollup-linux-s390x-gnu@npm:4.22.1": + version: 4.22.1 + resolution: "@rollup/rollup-linux-s390x-gnu@npm:4.22.1" conditions: os=linux & cpu=s390x & libc=glibc languageName: node linkType: hard -"@rollup/rollup-linux-x64-gnu@npm:4.22.0": - version: 4.22.0 - resolution: "@rollup/rollup-linux-x64-gnu@npm:4.22.0" +"@rollup/rollup-linux-x64-gnu@npm:4.22.1": + version: 4.22.1 + resolution: "@rollup/rollup-linux-x64-gnu@npm:4.22.1" conditions: os=linux & cpu=x64 & libc=glibc languageName: node linkType: hard -"@rollup/rollup-linux-x64-musl@npm:4.22.0": - version: 4.22.0 - resolution: "@rollup/rollup-linux-x64-musl@npm:4.22.0" +"@rollup/rollup-linux-x64-musl@npm:4.22.1": + version: 4.22.1 + resolution: "@rollup/rollup-linux-x64-musl@npm:4.22.1" conditions: os=linux & cpu=x64 & libc=musl languageName: node linkType: hard -"@rollup/rollup-win32-arm64-msvc@npm:4.22.0": - version: 4.22.0 - resolution: "@rollup/rollup-win32-arm64-msvc@npm:4.22.0" +"@rollup/rollup-win32-arm64-msvc@npm:4.22.1": + version: 4.22.1 + resolution: "@rollup/rollup-win32-arm64-msvc@npm:4.22.1" conditions: os=win32 & cpu=arm64 languageName: node linkType: hard -"@rollup/rollup-win32-ia32-msvc@npm:4.22.0": - version: 4.22.0 - resolution: "@rollup/rollup-win32-ia32-msvc@npm:4.22.0" +"@rollup/rollup-win32-ia32-msvc@npm:4.22.1": + version: 4.22.1 + resolution: "@rollup/rollup-win32-ia32-msvc@npm:4.22.1" conditions: os=win32 & cpu=ia32 languageName: node linkType: hard -"@rollup/rollup-win32-x64-msvc@npm:4.22.0": - version: 4.22.0 - resolution: "@rollup/rollup-win32-x64-msvc@npm:4.22.0" +"@rollup/rollup-win32-x64-msvc@npm:4.22.1": + version: 4.22.1 + resolution: "@rollup/rollup-win32-x64-msvc@npm:4.22.1" conditions: os=win32 & cpu=x64 languageName: node linkType: hard @@ -2825,11 +2825,11 @@ __metadata: "@guanghechen/conventional-changelog": ^6.0.0-alpha.2 "@guanghechen/eslint-config": ^7.0.4 "@guanghechen/helper-jest": ^6.0.0-alpha.5 - "@guanghechen/helper-string": ^6.0.0-alpha.2 "@guanghechen/jest-config": ^6.0.0-alpha.2 "@guanghechen/reporter": ^1.0.0 "@guanghechen/rollup-config": ^6.0.0-alpha.6 "@guanghechen/script-doc-link": ^6.0.0-alpha.17 + "@guanghechen/string": ^1.0.1 "@types/jest": 29.5.13 "@types/node": ^20.16.5 cross-env: ^7.0.3 @@ -2845,7 +2845,7 @@ __metadata: pinst: 3.0.0 prettier: 3.3.3 rimraf: ^6.0.1 - rollup: ^4.22.0 + rollup: ^4.22.1 ts-jest: 29.2.5 ts-node: 10.9.2 tsconfig-paths: 4.2.0 @@ -9421,26 +9421,26 @@ __metadata: languageName: node linkType: hard -"rollup@npm:^4.22.0": - version: 4.22.0 - resolution: "rollup@npm:4.22.0" - dependencies: - "@rollup/rollup-android-arm-eabi": 4.22.0 - "@rollup/rollup-android-arm64": 4.22.0 - "@rollup/rollup-darwin-arm64": 4.22.0 - "@rollup/rollup-darwin-x64": 4.22.0 - "@rollup/rollup-linux-arm-gnueabihf": 4.22.0 - "@rollup/rollup-linux-arm-musleabihf": 4.22.0 - "@rollup/rollup-linux-arm64-gnu": 4.22.0 - "@rollup/rollup-linux-arm64-musl": 4.22.0 - "@rollup/rollup-linux-powerpc64le-gnu": 4.22.0 - "@rollup/rollup-linux-riscv64-gnu": 4.22.0 - "@rollup/rollup-linux-s390x-gnu": 4.22.0 - "@rollup/rollup-linux-x64-gnu": 4.22.0 - "@rollup/rollup-linux-x64-musl": 4.22.0 - "@rollup/rollup-win32-arm64-msvc": 4.22.0 - "@rollup/rollup-win32-ia32-msvc": 4.22.0 - "@rollup/rollup-win32-x64-msvc": 4.22.0 +"rollup@npm:^4.22.1": + version: 4.22.1 + resolution: "rollup@npm:4.22.1" + dependencies: + "@rollup/rollup-android-arm-eabi": 4.22.1 + "@rollup/rollup-android-arm64": 4.22.1 + "@rollup/rollup-darwin-arm64": 4.22.1 + "@rollup/rollup-darwin-x64": 4.22.1 + "@rollup/rollup-linux-arm-gnueabihf": 4.22.1 + "@rollup/rollup-linux-arm-musleabihf": 4.22.1 + "@rollup/rollup-linux-arm64-gnu": 4.22.1 + "@rollup/rollup-linux-arm64-musl": 4.22.1 + "@rollup/rollup-linux-powerpc64le-gnu": 4.22.1 + "@rollup/rollup-linux-riscv64-gnu": 4.22.1 + "@rollup/rollup-linux-s390x-gnu": 4.22.1 + "@rollup/rollup-linux-x64-gnu": 4.22.1 + "@rollup/rollup-linux-x64-musl": 4.22.1 + "@rollup/rollup-win32-arm64-msvc": 4.22.1 + "@rollup/rollup-win32-ia32-msvc": 4.22.1 + "@rollup/rollup-win32-x64-msvc": 4.22.1 "@types/estree": 1.0.5 fsevents: ~2.3.2 dependenciesMeta: @@ -9480,7 +9480,7 @@ __metadata: optional: true bin: rollup: dist/bin/rollup - checksum: 268b29e9476165273256ccd56049d6307bc0869d2a832be7751ac347ddaa5a65269cba11eb528b03a88386b7793a23d28d989ffe6abc29a5626e5cbfe8f0e858 + checksum: 691e5a31f1380fd470833002c57fa245eb606abaf9afceb817eb994ba48ecd57a99096b01abb337540ba8dea9edab69e6b94a40bde506a98290fb9b0e918798d languageName: node linkType: hard