Skip to content

Commit a950d7c

Browse files
committed
⚒ update devDependencies
1 parent a6180a3 commit a950d7c

File tree

10 files changed

+84
-81
lines changed

10 files changed

+84
-81
lines changed

.eslintrc.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
root: true
12
extends:
2-
- plugin:mysticatea/es2018
3+
- plugin:@mysticatea/es2018
34

4-
overrides:
5-
- files: "*.ts"
6-
rules:
7-
require-jsdoc: off
8-
mysticatea/ts/no-use-before-define: off
5+
rules:
6+
# tsc does.
7+
"no-redeclare": "off"
8+
# https://github.com/typescript-eslint/typescript-eslint/issues/743
9+
"@mysticatea/ts/unbound-method": "off"

.travis.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,17 @@ node_js:
77
- "10"
88
- "12"
99

10+
script:
11+
# eslint and nyc don't support Node 6.
12+
- |
13+
if [ $TRAVIS_NODE_VERSION != "6.5" ]; then
14+
npm test
15+
else
16+
npm run -s test:node6
17+
fi
18+
1019
after_success:
11-
- npm run coveralls
20+
- |
21+
if [ $TRAVIS_NODE_VERSION != "6.5" ]; then
22+
npm run coveralls
23+
fi

package.json

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,22 @@
1111
],
1212
"dependencies": {},
1313
"devDependencies": {
14+
"@mysticatea/eslint-plugin": "^11.0.0",
1415
"@types/eslint": "^4.16.2",
1516
"@types/mocha": "^5.2.2",
16-
"@types/node": "^10.3.3",
17+
"@types/node": "^12.6.8",
1718
"coveralls": "^3.0.1",
1819
"dts-bundle": "^0.7.3",
19-
"eslint": "^4.19.1",
20-
"eslint-plugin-mysticatea": "^5.0.0-beta.15",
21-
"mocha": "^5.2.0",
22-
"npm-run-all": "^4.1.3",
23-
"nyc": "^12.0.2",
20+
"eslint": "^6.1.0",
21+
"mocha": "^6.2.0",
22+
"npm-run-all": "^4.1.5",
23+
"nyc": "^14.1.1",
2424
"rimraf": "^2.6.2",
25-
"rollup": "^0.60.7",
26-
"rollup-plugin-node-resolve": "^3.3.0",
25+
"rollup": "^1.17.0",
26+
"rollup-plugin-node-resolve": "^5.2.0",
2727
"rollup-plugin-sourcemaps": "^0.4.2",
28-
"rollup-watch": "^4.3.1",
29-
"ts-node": "^6.1.1",
30-
"typescript": "^2.9.2",
31-
"typescript-eslint-parser": "^16.0.0"
28+
"ts-node": "^8.3.0",
29+
"typescript": "^3.5.3"
3230
},
3331
"scripts": {
3432
"prebuild": "npm run -s clean",
@@ -41,6 +39,7 @@
4139
"lint": "eslint scripts src test --ext .ts",
4240
"pretest": "run-s build lint",
4341
"test": "nyc _mocha \"test/*.ts\" --reporter dot --timeout 10000",
42+
"test:node6": "_mocha \"test/*.ts\" --require ts-node/register --reporter dot --timeout 10000",
4443
"update:test": "ts-node scripts/update-fixtures.ts",
4544
"update:ids": "ts-node scripts/update-unicode-ids.ts",
4645
"preversion": "npm test",

scripts/clone-without-circular.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const relative = require("path").posix.relative
1+
import { posix } from "path"
22

33
function resolveLocation(
44
obj: any,
@@ -61,10 +61,10 @@ function getRelativePath(
6161
return to.map(el => getRelativePath(from, el, pathMap))
6262
}
6363

64-
const fromPath = pathMap.get(from)
65-
const toPath = pathMap.get(to)
64+
const fromPath = pathMap.get(from)!
65+
const toPath = pathMap.get(to)!
6666
try {
67-
return `♻️${relative(fromPath, toPath).replace(/\/$/u, "")}`
67+
return `♻️${posix.relative(fromPath, toPath).replace(/\/$/u, "")}`
6868
} catch (err) {
6969
console.error(fromPath, toPath, err.stack)
7070
return "💥💥💥💥💥💥💥💥"

scripts/update-unicode-ids.ts

Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { CLIEngine } from "eslint"
44

55
const DB_URL = "http://unicode.org/Public/UNIDATA/DerivedCoreProperties.txt"
66
const FILE_PATH = "src/unicode/ids.ts"
7-
const ID_START = /^([0-9a-z]+)(?:\.\.([0-9a-z]+))?[^;]*; ID_Start /i
8-
const ID_CONTINUE = /^([0-9a-z]+)(?:\.\.([0-9a-z]+))?[^;]*; ID_Continue /i
7+
const ID_START = /^([0-9a-z]+)(?:\.\.([0-9a-z]+))?[^;]*; ID_Start /iu
8+
const ID_CONTINUE = /^([0-9a-z]+)(?:\.\.([0-9a-z]+))?[^;]*; ID_Continue /iu
99
const BORDER = 0x7f
1010
const logger = console
1111

@@ -19,10 +19,10 @@ enum Mode {
1919
;(async () => {
2020
let banner = ""
2121
const idStartSet: Set<string> = new Set()
22-
const idStartSmall: Array<[number, number]> = []
23-
const idStartLarge: Array<[number, number]> = []
24-
const idContinueSmall: Array<[number, number]> = []
25-
const idContinueLarge: Array<[number, number]> = []
22+
const idStartSmall: [number, number][] = []
23+
const idStartLarge: [number, number][] = []
24+
const idContinueSmall: [number, number][] = []
25+
const idContinueLarge: [number, number][] = []
2626

2727
logger.log("Fetching data... (%s)", DB_URL)
2828
await processEachLine(line => {
@@ -86,30 +86,28 @@ ${makeCondition(idContinueLarge, Mode.Former)}
8686

8787
function processEachLine(cb: (line: string) => void): Promise<void> {
8888
return new Promise((resolve, reject) => {
89-
http
90-
.get(DB_URL, res => {
91-
let buffer = ""
92-
res.setEncoding("utf8")
93-
res.on("data", chunk => {
94-
const lines = (buffer + chunk).split("\n")
95-
if (lines.length === 1) {
96-
buffer = lines[0]
97-
} else {
98-
buffer = lines.pop()!
99-
for (const line of lines) {
100-
cb(line)
101-
}
89+
http.get(DB_URL, res => {
90+
let buffer = ""
91+
res.setEncoding("utf8")
92+
res.on("data", chunk => {
93+
const lines = (buffer + String(chunk)).split("\n")
94+
if (lines.length === 1) {
95+
buffer = lines[0]
96+
} else {
97+
buffer = lines.pop()!
98+
for (const line of lines) {
99+
cb(line)
102100
}
103-
})
104-
res.on("end", () => {
105-
if (buffer) {
106-
cb(buffer)
107-
}
108-
resolve()
109-
})
110-
res.on("error", reject)
101+
}
102+
})
103+
res.on("end", () => {
104+
if (buffer) {
105+
cb(buffer)
106+
}
107+
resolve()
111108
})
112-
.on("error", reject)
109+
res.on("error", reject)
110+
}).on("error", reject)
113111
})
114112
}
115113

@@ -148,10 +146,8 @@ function makeSmallCondtion(ranges: [number, number][], mode: Mode): string {
148146

149147
function save(content: string): Promise<void> {
150148
return new Promise((resolve, reject) => {
151-
fs.writeFile(
152-
FILE_PATH,
153-
content,
154-
error => (error ? reject(error) : resolve()),
149+
fs.writeFile(FILE_PATH, content, error =>
150+
error ? reject(error) : resolve(),
155151
)
156152
})
157153
}

src/parser.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ type AppendableNode =
2323
| CharacterClass
2424
| LookaroundAssertion
2525

26-
const DummyPattern = {} as Pattern
27-
const DummyFlags = {} as Flags
28-
const DummyCapturingGroup = {} as CapturingGroup
26+
const DummyPattern: Pattern = {} as any
27+
const DummyFlags: Flags = {} as any
28+
const DummyCapturingGroup: CapturingGroup = {} as any
2929

3030
class RegExpParserState {
3131
public readonly strict: boolean
@@ -251,7 +251,7 @@ class RegExpParserState {
251251
throw new Error("UnknownError")
252252
}
253253

254-
this._node = {
254+
const node: LookaroundAssertion = (this._node = {
255255
type: "Assertion",
256256
parent,
257257
start,
@@ -260,8 +260,8 @@ class RegExpParserState {
260260
kind,
261261
negate,
262262
alternatives: [],
263-
} as LookaroundAssertion
264-
parent.elements.push(this._node)
263+
})
264+
parent.elements.push(node)
265265
}
266266

267267
public onLookaroundAssertionLeave(start: number, end: number): void {

src/regexp-syntax-error.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export class RegExpSyntaxError extends SyntaxError {
88
) {
99
/*eslint-disable no-param-reassign */
1010
if (source) {
11-
if (source[0] !== "/") {
11+
if (!source.startsWith("/")) {
1212
source = `/${source}/${uFlag ? "u" : ""}`
1313
}
1414
source = `: ${source}`

src/validator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ export class RegExpValidator {
449449
this.onLiteralEnter(start)
450450
if (this.eat(Solidus) && this.eatRegExpBody() && this.eat(Solidus)) {
451451
const flagStart = this.index
452-
const uFlag = source.indexOf("u", flagStart) !== -1
452+
const uFlag = source.includes("u", flagStart)
453453
this.validateFlags(source, flagStart, end)
454454
this.validatePattern(source, start + 1, flagStart - 1, uFlag)
455455
} else if (start >= end) {

test/fixtures/visitor/index.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,13 @@ const fixturesRoot = __dirname
1717
export const Fixtures: FixtureData = fs
1818
.readdirSync(fixturesRoot)
1919
.filter(filename => path.extname(filename) === ".json")
20-
.reduce(
21-
(fixtures, filename) => {
22-
fixtures[filename] = JSON.parse(
23-
fs.readFileSync(path.join(fixturesRoot, filename), "utf8"),
24-
(_, v) => (v === "$$Infinity" ? Infinity : v),
25-
)
26-
return fixtures
27-
},
28-
{} as FixtureData,
29-
)
20+
.reduce<FixtureData>((fixtures, filename) => {
21+
fixtures[filename] = JSON.parse(
22+
fs.readFileSync(path.join(fixturesRoot, filename), "utf8"),
23+
(_, v) => (v === "$$Infinity" ? Infinity : v),
24+
)
25+
return fixtures
26+
}, {})
3027
export function save(): void {
3128
for (const filename of Object.keys(Fixtures)) {
3229
fs.writeFileSync(

test/parser.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ describe("parseRegExpLiteral function:", () => {
1313
const options = fixture.options
1414

1515
describe(`${filename} (options=${JSON.stringify(options)})`, () => {
16-
if (filename.indexOf("-valid") !== -1) {
16+
if (filename.includes("-valid")) {
1717
it("should not contain any invalid test case", () => {
1818
for (const source of Object.keys(fixture.patterns)) {
1919
const result = fixture.patterns[source]
2020
assert("ast" in result, `${source} is invalid`)
2121
}
2222
})
23-
} else if (filename.indexOf("-invalid") !== -1) {
23+
} else if (filename.includes("-invalid")) {
2424
it("should not contain any valid test case", () => {
2525
for (const source of Object.keys(fixture.patterns)) {
2626
const result = fixture.patterns[source]
@@ -43,9 +43,7 @@ describe("parseRegExpLiteral function:", () => {
4343
assert.strictEqual(
4444
expected.message.slice(0, 27),
4545
"Invalid regular expression:",
46-
`The error message '${
47-
expected.message
48-
}' was not syntax error.`,
46+
`The error message '${expected.message}' was not syntax error.`,
4947
)
5048
try {
5149
parseRegExpLiteral(source, options)
@@ -62,8 +60,8 @@ describe("parseRegExpLiteral function:", () => {
6260
}
6361

6462
it("should parse RegExp object", () => {
65-
const actual = cloneWithoutCircular(parseRegExpLiteral(/[A-Z]+/))
66-
const expected = cloneWithoutCircular(parseRegExpLiteral("/[A-Z]+/"))
63+
const actual = cloneWithoutCircular(parseRegExpLiteral(/[A-Z]+/u))
64+
const expected = cloneWithoutCircular(parseRegExpLiteral("/[A-Z]+/u"))
6765

6866
assert.deepStrictEqual(actual, expected)
6967
})
@@ -74,7 +72,7 @@ describe("RegExpParser:", () => {
7472
it("should throw syntax error on '\\'.", () => {
7573
assert.throws(
7674
() => new RegExpParser().parsePattern("\\"),
77-
/\\ at end of pattern/,
75+
/\\ at end of pattern/u,
7876
)
7977
})
8078
})

0 commit comments

Comments
 (0)