From c38b8a0ce5a42b833fdd6ec73bb0455907645e93 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Sat, 13 Mar 2021 09:08:14 +0000 Subject: [PATCH 1/2] Update dependency @ota-meshi/eslint-plugin to ^0.3.0 --- package-lock.json | 37 +++++++++++++++++++++++++++++++++---- package.json | 2 +- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 07e2d145..0c12f850 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2594,10 +2594,39 @@ } }, "@ota-meshi/eslint-plugin": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/@ota-meshi/eslint-plugin/-/eslint-plugin-0.2.0.tgz", - "integrity": "sha512-EYXR0l2ZX/E4qdU8iTlA2+TW9t5QoGuSprUibTU2rLeDmyoaCQy0uICBx4WCAABW2dBfqv5tQEDuymNrrw/3uw==", - "dev": true + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/@ota-meshi/eslint-plugin/-/eslint-plugin-0.3.0.tgz", + "integrity": "sha512-Sea1LF9xEPCFPfQRI03uK1Qy1DYPp3TMHJi/+8EpU58Z6up/jEuIQPq53UUgSUpp4+TtNFGySCgB0Xf1yi6USg==", + "dev": true, + "requires": { + "semver": "^7.3.4" + }, + "dependencies": { + "lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "requires": { + "yallist": "^4.0.0" + } + }, + "semver": { + "version": "7.3.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.4.tgz", + "integrity": "sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw==", + "dev": true, + "requires": { + "lru-cache": "^6.0.0" + } + }, + "yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + } + } }, "@sindresorhus/is": { "version": "0.14.0", diff --git a/package.json b/package.json index fe266872..2bf2a8e4 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "dist" ], "devDependencies": { - "@ota-meshi/eslint-plugin": "^0.2.0", + "@ota-meshi/eslint-plugin": "^0.3.0", "@types/eslint": "^7.2.0", "@types/eslint-visitor-keys": "^1.0.0", "@types/estree": "^0.0.46", From 32040ceb51dc4742e90436a06a0eb6e82455e9e9 Mon Sep 17 00:00:00 2001 From: yosuke ota Date: Sat, 13 Mar 2021 18:13:52 +0900 Subject: [PATCH 2/2] fix --- lib/styles/parser/selector/replace-utils.ts | 8 ++++---- lib/styles/parser/selector/scss-selector-parser.ts | 4 ++-- lib/styles/parser/selector/stylus-selector-parser.ts | 12 ++++++------ .../selectors/resolver/stylus-selector-resolver.ts | 2 +- lib/styles/template/scss/util.ts | 4 ++-- lib/styles/template/stylus/util.ts | 2 +- lib/styles/utils/index.ts | 2 +- tools/update-docs.ts | 2 +- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/lib/styles/parser/selector/replace-utils.ts b/lib/styles/parser/selector/replace-utils.ts index 9ba2497f..4dc0ca82 100644 --- a/lib/styles/parser/selector/replace-utils.ts +++ b/lib/styles/parser/selector/replace-utils.ts @@ -14,7 +14,7 @@ class SourceCodeLocationResolver { const lineStartIndices = [0] let match = undefined - const lineEndingPattern = /\r\n|[\r\n\u2028\u2029]/gu + const lineEndingPattern = /\r\n|[\n\r\u2028\u2029]/gu while ((match = lineEndingPattern.exec(code))) { lineStartIndices.push(match.index + match[0].length) } @@ -289,9 +289,9 @@ export function replaceSelector( let start = 0 for (const { name, result: res } of definePatternsSearchGenerator( { - block: /\/\*(?:[\s\S]+?)\*\//gu, // block comment - dstr: /"(?:[^\\"]|\\.)*"/gu, // string - sstr: /'(?:[^\\']|\\.)*'/gu, // string + block: /\/\*[\s\S]+?\*\//gu, // block comment + dstr: /"(?:[^"\\]|\\.)*"/gu, // string + sstr: /'(?:[^'\\]|\\.)*'/gu, // string ...commentRegexps.reduce((o, r, i) => { o[`${i}comment`] = r.regexp return o diff --git a/lib/styles/parser/selector/scss-selector-parser.ts b/lib/styles/parser/selector/scss-selector-parser.ts index a7d8b267..41740a37 100644 --- a/lib/styles/parser/selector/scss-selector-parser.ts +++ b/lib/styles/parser/selector/scss-selector-parser.ts @@ -15,13 +15,13 @@ export class SCSSSelectorParser extends CSSSelectorParser { selector, [ { - regexp: /#\{(?:[\s\S]+?)\}/gu, // interpolation + regexp: /#\{[\s\S]+?\}/gu, // interpolation replace: (_res, random) => `_${random}_`, }, ], [ { - regexp: /\/\/[^\r\n\u2028\u2029]*/gu, // inline comment + regexp: /\/\/[^\n\r\u2028\u2029]*/gu, // inline comment replace: (_res, random) => `/*${random}*/`, }, ], diff --git a/lib/styles/parser/selector/stylus-selector-parser.ts b/lib/styles/parser/selector/stylus-selector-parser.ts index 2cb7486d..c63abe18 100644 --- a/lib/styles/parser/selector/stylus-selector-parser.ts +++ b/lib/styles/parser/selector/stylus-selector-parser.ts @@ -46,11 +46,11 @@ export class StylusSelectorParser extends CSSSelectorParser { selector, [ { - regexp: /\{(?:[\s\S]+?)\}/gu, // interpolation + regexp: /\{[\s\S]+?\}/gu, // interpolation replace: (_res, random) => `_${random}_`, }, { - regexp: /\^\[(?:[\s\S]+?)\]/gu, // partial reference + regexp: /\^\[[\s\S]+?\]/gu, // partial reference replace: replaceStylusNesting, restore: restoreStylusNesting, }, @@ -72,13 +72,13 @@ export class StylusSelectorParser extends CSSSelectorParser { ], [ { - regexp: /\/\/[^\r\n\u2028\u2029]*/gu, // inline comment + regexp: /\/\/[^\n\r\u2028\u2029]*/gu, // inline comment replace: (_res, random) => `/*${random}*/`, }, ], [ { - regexp: /([\r\n\u2028\u2029])(\s*)/gu, // comma + regexp: /([\n\r\u2028\u2029])(\s*)/gu, // comma replace(res, _random, { beforeCss }) { const before = [...beforeCss] let prev = before.pop() @@ -97,10 +97,10 @@ export class StylusSelectorParser extends CSSSelectorParser { while ( (next = after .replace( - /^\s*\/\/[^\r\n\u2028\u2029]*\s*/gu, + /^\s*\/\/[^\n\r\u2028\u2029]*\s*/gu, "", ) - .replace(/^\s*\/\*(?:[\s\S]+?)\*\/\s*/gu, "") + .replace(/^\s*\/\*[\s\S]+?\*\/\s*/gu, "") .trim()) && next !== after ) { diff --git a/lib/styles/selectors/resolver/stylus-selector-resolver.ts b/lib/styles/selectors/resolver/stylus-selector-resolver.ts index d5f727fe..f953131f 100644 --- a/lib/styles/selectors/resolver/stylus-selector-resolver.ts +++ b/lib/styles/selectors/resolver/stylus-selector-resolver.ts @@ -292,7 +292,7 @@ function parsePartialRefValue(partialRefValue: string, length: number) { } } - const rangeValues = /^([-+]?\d+)\.\.([-+]?\d+)$/u.exec(partialRefValue) + const rangeValues = /^([+-]?\d+)\.\.([+-]?\d+)$/u.exec(partialRefValue) if (rangeValues) { // The nestingNode is ranges in partial references. diff --git a/lib/styles/template/scss/util.ts b/lib/styles/template/scss/util.ts index 7cfc0b8d..a6fc9032 100644 --- a/lib/styles/template/scss/util.ts +++ b/lib/styles/template/scss/util.ts @@ -7,7 +7,7 @@ export function processText(text: string): (Interpolation | string)[] { const elements = [] const value = text let start = 0 - const reg = /#\{(?:[\s\S]*?)\}/gu + const reg = /#\{[\s\S]*?\}/gu let re = null while ((re = reg.exec(value))) { elements.push(value.slice(start, re.index)) @@ -26,7 +26,7 @@ export function processValue(text: string): (Interpolation | string)[] { const elements = [] const value = text let start = 0 - const reg = /(#\{(?:[\s\S]*?)\})|(?:\$[\w\d-]+)/gu + const reg = /(#\{[\s\S]*?\})|\$[\w\d-]+/gu let re = null while ((re = reg.exec(value))) { elements.push(value.slice(start, re.index)) diff --git a/lib/styles/template/stylus/util.ts b/lib/styles/template/stylus/util.ts index 88eacd94..9b94383c 100644 --- a/lib/styles/template/stylus/util.ts +++ b/lib/styles/template/stylus/util.ts @@ -7,7 +7,7 @@ export function processText(text: string): (Interpolation | string)[] { const elements = [] const value = text let start = 0 - const reg = /\{(?:[\s\S]*?)\}/gu + const reg = /\{[\s\S]*?\}/gu let re = null while ((re = reg.exec(value))) { elements.push(value.slice(start, re.index)) diff --git a/lib/styles/utils/index.ts b/lib/styles/utils/index.ts index ac7085e0..64480496 100644 --- a/lib/styles/utils/index.ts +++ b/lib/styles/utils/index.ts @@ -14,5 +14,5 @@ export function isSupportedStyleLang( * @returns {string} The escape string */ export function escapeRegExp(value: string): string { - return value.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&") // $& means the whole matched string + return value.replace(/[$(-+.?[-^{-}]/gu, "\\$&") // $& means the whole matched string } diff --git a/tools/update-docs.ts b/tools/update-docs.ts index b3ce24a4..57181ef4 100644 --- a/tools/update-docs.ts +++ b/tools/update-docs.ts @@ -150,7 +150,7 @@ class DocFile { const { meta } = this.rule this.content = this.content.replace( - /