Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/styles/parser/selector/replace-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/styles/parser/selector/scss-selector-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}*/`,
},
],
Expand Down
12 changes: 6 additions & 6 deletions lib/styles/parser/selector/stylus-selector-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand All @@ -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()
Expand All @@ -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
) {
Expand Down
2 changes: 1 addition & 1 deletion lib/styles/selectors/resolver/stylus-selector-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions lib/styles/template/scss/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion lib/styles/template/stylus/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion lib/styles/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
37 changes: 33 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion tools/update-docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ class DocFile {
const { meta } = this.rule

this.content = this.content.replace(
/<eslint-code-block\s(:?fix[^\s]*)?\s*/gu,
/<eslint-code-block\s(:?fix\S*)?\s*/gu,
`<eslint-code-block ${meta.fixable ? "fix " : ""}`,
)
return this
Expand Down