Skip to content

Commit 89194cb

Browse files
committed
⚒ upgrade eslint and configs
1 parent b2041e4 commit 89194cb

7 files changed

+24
-25
lines changed

.eslintrc.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ extends:
66
- plugin:@mysticatea/+node
77

88
rules:
9-
"@mysticatea/node/no-unsupported-features":
9+
"@mysticatea/node/no-unsupported-features/es-syntax":
1010
- error
1111
- ignores:
1212
- modules

package.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,22 @@
55
"engines": {
66
"node": ">=6"
77
},
8+
"sideEffects": false,
89
"main": "index",
10+
"module": "index.mjs",
911
"files": [
1012
"index.*"
1113
],
1214
"dependencies": {
1315
"eslint-visitor-keys": "^1.0.0"
1416
},
1517
"devDependencies": {
16-
"@mysticatea/eslint-plugin": "^5.0.1",
18+
"@mysticatea/eslint-plugin": "^10.0.3",
1719
"codecov": "^3.0.2",
1820
"dot-prop": "^4.2.0",
19-
"eslint": "^5.0.1",
21+
"eslint": "^5.16.0",
2022
"esm": "^3.0.55",
21-
"espree": "^4.0.0",
23+
"espree": "^5.0.1",
2224
"mocha": "^5.2.0",
2325
"nyc": "^13.0.1",
2426
"opener": "^1.4.3",

src/pattern-matcher.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* See LICENSE file in root directory for full license.
44
*/
55

6-
const placeholder = /\$(?:[$&`']|[1-9][0-9]?)/g
6+
const placeholder = /\$(?:[$&`']|[1-9][0-9]?)/gu
77

88
/** @type {WeakMap<PatternMatcher, {pattern:RegExp,escaped:boolean}>} */
99
const internal = new WeakMap()
@@ -70,7 +70,6 @@ function replaceS(matcher, str, replacement) {
7070
return chunks.join("")
7171
}
7272

73-
//eslint-disable-next-line valid-jsdoc
7473
/**
7574
* Replace a given string by a given matcher.
7675
* @param {PatternMatcher} matcher The pattern matcher.
@@ -146,7 +145,6 @@ export class PatternMatcher {
146145
return !ret.done
147146
}
148147

149-
//eslint-disable-next-line valid-jsdoc
150148
/**
151149
* Replace a given string.
152150
* @param {string} str The string to be replaced.

src/reference-tracker.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { findVariable } from "./find-variable"
22
import { getPropertyName } from "./get-property-name"
33
import { getStringIfConstant } from "./get-string-if-constant"
44

5-
const SENTINEL_TYPE = /^(?:.+?Statement|.+?Declaration|(?:Array|ArrowFunction|Assignment|Call|Class|Function|Member|New|Object)Expression|AssignmentPattern|Program|VariableDeclarator)$/
6-
const IMPORT_TYPE = /^(?:Import|Export(?:All|Default|Named))Declaration$/
5+
const SENTINEL_TYPE = /^(?:.+?Statement|.+?Declaration|(?:Array|ArrowFunction|Assignment|Call|Class|Function|Member|New|Object)Expression|AssignmentPattern|Program|VariableDeclarator)$/u
6+
const IMPORT_TYPE = /^(?:Import|Export(?:All|Default|Named))Declaration$/u
77
const has = Function.call.bind(Object.hasOwnProperty)
88

99
export const READ = Symbol("read")
@@ -224,7 +224,7 @@ export class ReferenceTracker {
224224
* @param {object} traceMap The trace map.
225225
* @returns {IterableIterator<{node:Node,path:string[],type:symbol,info:any}>} The iterator to iterate references.
226226
*/
227-
//eslint-disable-next-line complexity, require-jsdoc
227+
//eslint-disable-next-line complexity
228228
*_iteratePropertyReferences(rootNode, path, traceMap) {
229229
let node = rootNode
230230
while (!SENTINEL_TYPE.test(node.parent.type)) {

test/find-variable.js

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import eslint from "eslint"
33
import { findVariable } from "../src/"
44

55
describe("The 'findVariable' function", () => {
6-
//eslint-disable-next-line require-jsdoc
76
function getVariable(code, selector, withString = null) {
87
const linter = new eslint.Linter()
98
let variable = null

test/get-static-value.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ describe("The 'getStaticValue' function", () => {
5959
{ code: "false", expected: { value: false } },
6060
{ code: "1", expected: { value: 1 } },
6161
{ code: "'hello'", expected: { value: "hello" } },
62-
{ code: "/foo/g", expected: { value: /foo/g } },
62+
{ code: "/foo/gu", expected: { value: /foo/gu } },
6363
{ code: "true && 1", expected: { value: 1 } },
6464
{ code: "false && a", expected: { value: false } },
6565
{ code: "true || a", expected: { value: true } },

test/pattern-matcher.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { PatternMatcher } from "../src/"
33

44
const NAMED_CAPTURE_GROUP_SUPPORTED = (() => {
55
try {
6-
new RegExp("(?<a>)", "u") //eslint-disable-line no-new, @mysticatea/node/no-unsupported-features
6+
new RegExp("(?<a>)", "u") //eslint-disable-line no-new, @mysticatea/node/no-unsupported-features/es-syntax
77
return true
88
} catch (_error) {
99
return false
@@ -44,16 +44,16 @@ describe("The 'PatternMatcher' class:", () => {
4444
]) {
4545
assert.throws(
4646
() => new PatternMatcher(value),
47-
/^TypeError: 'pattern' should be a RegExp instance\.$/
47+
/^TypeError: 'pattern' should be a RegExp instance\.$/u
4848
)
4949
}
5050
})
5151

5252
it("should throw Error if the RegExp value does not have 'g' flag.", () => {
53-
for (const value of [/foo/, /bar/im]) {
53+
for (const value of [/foo/u, /bar/imu]) {
5454
assert.throws(
5555
() => new PatternMatcher(value),
56-
/^Error: 'pattern' should contains 'g' flag\.$/
56+
/^Error: 'pattern' should contains 'g' flag\.$/u
5757
)
5858
}
5959
})
@@ -116,7 +116,7 @@ describe("The 'PatternMatcher' class:", () => {
116116
it(`should return ${JSON.stringify(
117117
expected
118118
)} in ${JSON.stringify(str)}.`, () => {
119-
const matcher = new PatternMatcher(/foo/g)
119+
const matcher = new PatternMatcher(/foo/gu)
120120
const actual = Array.from(matcher.execAll(str))
121121
assert.deepStrictEqual(actual, expected)
122122
})
@@ -139,14 +139,14 @@ describe("The 'PatternMatcher' class:", () => {
139139
it(`should return ${JSON.stringify(
140140
expected
141141
)} in ${JSON.stringify(str)}.`, () => {
142-
const matcher = new PatternMatcher(/(\w)(\d)/g)
142+
const matcher = new PatternMatcher(/(\w)(\d)/gu)
143143
const actual = Array.from(matcher.execAll(str))
144144
assert.deepStrictEqual(actual, expected)
145145
})
146146
}
147147

148148
it("should iterate for two strings in parallel.", () => {
149-
const matcher = new PatternMatcher(/\w/g)
149+
const matcher = new PatternMatcher(/\w/gu)
150150
const expected1 = [
151151
newRegExpExecArray(["a"], 0, "a--b-c"),
152152
newRegExpExecArray(["b"], 3, "a--b-c"),
@@ -213,7 +213,7 @@ describe("The 'PatternMatcher' class:", () => {
213213
it(`should return ${JSON.stringify(
214214
expected
215215
)} in ${JSON.stringify(str)}.`, () => {
216-
const matcher = new PatternMatcher(/foo/g, {
216+
const matcher = new PatternMatcher(/foo/gu, {
217217
escaped: true,
218218
})
219219
const actual = Array.from(matcher.execAll(str))
@@ -238,7 +238,7 @@ describe("The 'PatternMatcher' class:", () => {
238238
{ str: String.raw`-foo\foofooabcfoo-`, expected: true },
239239
]) {
240240
it(`should return ${expected} in ${JSON.stringify(str)}.`, () => {
241-
const matcher = new PatternMatcher(/foo/g)
241+
const matcher = new PatternMatcher(/foo/gu)
242242
const actual = matcher.test(str)
243243
assert.deepStrictEqual(actual, expected)
244244
})
@@ -278,7 +278,7 @@ describe("The 'PatternMatcher' class:", () => {
278278
{ str: "abc", replacer: "$0", expected: "$0$0$0" },
279279
{ str: "abc", replacer: "$1", expected: "$1$1$1" },
280280
{
281-
pattern: /a(b)/g,
281+
pattern: /a(b)/gu,
282282
str: "abc",
283283
replacer: "$1",
284284
expected: "bc",
@@ -287,14 +287,14 @@ describe("The 'PatternMatcher' class:", () => {
287287
it(`should return ${expected} in ${JSON.stringify(
288288
str
289289
)} and ${JSON.stringify(replacer)}.`, () => {
290-
const matcher = new PatternMatcher(pattern || /[a-c]/g)
290+
const matcher = new PatternMatcher(pattern || /[a-c]/gu)
291291
const actual = str.replace(matcher, replacer)
292292
assert.deepStrictEqual(actual, expected)
293293
})
294294
}
295295

296-
it(`should pass the correct arguments to replacers.`, () => {
297-
const matcher = new PatternMatcher(/(\w)(\d)/g)
296+
it("should pass the correct arguments to replacers.", () => {
297+
const matcher = new PatternMatcher(/(\w)(\d)/gu)
298298
const actualArgs = []
299299
const actual = "abc1d2efg".replace(matcher, (...args) => {
300300
actualArgs.push(args)

0 commit comments

Comments
 (0)