Skip to content

Commit a9f5bb6

Browse files
chore(deps): update dependency prettier to v3 (#168)
* chore(deps): update dependency prettier to v3 * fix * Update NodeCI.yml * Update NodeCI.yml --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Yosuke Ota <[email protected]>
1 parent 4b91978 commit a9f5bb6

27 files changed

+100
-102
lines changed

.github/workflows/NodeCI.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ jobs:
3333
node-version: ${{ matrix.node-version }}
3434
- name: Install Target Packages
3535
run: |+
36-
npm i -D eslint@7
37-
npx rimraf node_modules
38-
npm install
36+
npm install --legacy-peer-deps
3937
- name: Test
4038
run: npm test
4139
test-and-coverage:

benchmark/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { parseForESLint as parseOld } from "../node_modules/jsonc-eslint-parser"
77

88
const contents = `${fs.readFileSync(
99
require.resolve("../package.json"),
10-
"utf-8"
10+
"utf-8",
1111
)}// comments`;
1212

1313
type Result = { name: string; hz: number };
@@ -34,8 +34,8 @@ function onComplete(): void {
3434
for (const name of Object.keys(map)) {
3535
console.log(
3636
`${name.padEnd(15)} ${format(
37-
map[name].reduce((p, a) => p + a, 0) / map[name].length
38-
)} ops/sec`
37+
map[name].reduce((p, a) => p + a, 0) / map[name].length,
38+
)} ops/sec`,
3939
);
4040
}
4141
for (let i = 0; i < results.length; ++i) {

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,12 @@
7070
"eslint-plugin-jsonc": "^2.0.0",
7171
"eslint-plugin-node": "^11.1.0",
7272
"eslint-plugin-node-dependencies": "^0.11.0",
73-
"eslint-plugin-prettier": "^4.0.0",
73+
"eslint-plugin-prettier": "^5.0.0",
7474
"eslint-plugin-regexp": "^1.0.0",
7575
"eslint-plugin-vue": "^9.0.0",
7676
"mocha": "^10.0.0",
7777
"nyc": "^15.1.0",
78-
"prettier": "^2.0.5",
78+
"prettier": "^3.0.0",
7979
"ts-node": "^10.0.0",
8080
"typescript": "~5.0.0",
8181
"vue-eslint-parser": "^9.0.0"

src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export {
3333
export function parseJSON(
3434
code: string,
3535
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- any
36-
options?: any
36+
options?: any,
3737
): AST.JSONProgram {
3838
return parseForESLint(code, options).ast as never;
3939
}

src/parser/convert.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export class TokenConvertor {
8383
if (this.templateBuffer.length === 0) {
8484
return throwUnexpectedTokenError(
8585
this.code.slice(...token.range!),
86-
token
86+
token,
8787
);
8888
}
8989
this.templateBuffer.push(token);
@@ -146,7 +146,7 @@ export function convertProgramNode(
146146
node: Node | JSONNode,
147147
tokens: TokenStore,
148148
ctx: JSONSyntaxContext,
149-
code: string
149+
code: string,
150150
): JSONProgram {
151151
/* istanbul ignore next */
152152
if (

src/parser/errors.ts

+17-17
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export class ParseError extends SyntaxError {
2626
message: string,
2727
offset: number,
2828
line: number,
29-
column: number
29+
column: number,
3030
) {
3131
super(message);
3232
this.index = offset;
@@ -42,14 +42,14 @@ export class ParseError extends SyntaxError {
4242
*/
4343
export function throwExpectedTokenError(
4444
name: string,
45-
beforeToken: MaybeNodeOrToken
45+
beforeToken: MaybeNodeOrToken,
4646
): never {
4747
const locs = getLocation(beforeToken);
4848
const err = new ParseError(
4949
`Expected token '${name}'.`,
5050
locs.end,
5151
locs.loc.end.line,
52-
locs.loc.end.column + 1
52+
locs.loc.end.column + 1,
5353
);
5454

5555
throw err;
@@ -62,14 +62,14 @@ export function throwExpectedTokenError(
6262
*/
6363
export function throwUnexpectedError(
6464
name: string,
65-
token: MaybeNodeOrToken
65+
token: MaybeNodeOrToken,
6666
): never {
6767
const locs = getLocation(token);
6868
const err = new ParseError(
6969
`Unexpected ${name}.`,
7070
locs.start,
7171
locs.loc.start.line,
72-
locs.loc.start.column + 1
72+
locs.loc.start.column + 1,
7373
);
7474

7575
throw err;
@@ -82,7 +82,7 @@ export function throwUnexpectedError(
8282
*/
8383
export function throwUnexpectedTokenError(
8484
name: string,
85-
token: MaybeNodeOrToken
85+
token: MaybeNodeOrToken,
8686
): never {
8787
return throwUnexpectedError(`token '${name}'`, token);
8888
}
@@ -100,14 +100,14 @@ export function throwUnexpectedCommentError(token: Comment): never {
100100
* Throw syntax error for unexpected whitespace.
101101
*/
102102
export function throwUnexpectedSpaceError(
103-
beforeToken: MaybeNodeOrToken
103+
beforeToken: MaybeNodeOrToken,
104104
): never {
105105
const locs = getLocation(beforeToken);
106106
const err = new ParseError(
107107
"Unexpected whitespace.",
108108
locs.end,
109109
locs.loc.end.line,
110-
locs.loc.end.column + 1
110+
locs.loc.end.column + 1,
111111
);
112112

113113
throw err;
@@ -118,14 +118,14 @@ export function throwUnexpectedSpaceError(
118118
*/
119119
export function throwInvalidNumberError(
120120
text: string,
121-
token: MaybeNodeOrToken
121+
token: MaybeNodeOrToken,
122122
): never {
123123
const locs = getLocation(token);
124124
const err = new ParseError(
125125
`Invalid number ${text}.`,
126126
locs.start,
127127
locs.loc.start.line,
128-
locs.loc.start.column + 1
128+
locs.loc.start.column + 1,
129129
);
130130

131131
throw err;
@@ -138,15 +138,15 @@ export function throwInvalidNumberError(
138138
export function throwUnexpectedNodeError(
139139
node: Node | JSONNode,
140140
tokens: TokenStore,
141-
offset?: number
141+
offset?: number,
142142
): never {
143143
if (node.type === "Identifier" || node.type === "JSONIdentifier") {
144144
const locs = getLocation(node);
145145
const err = new ParseError(
146146
`Unexpected identifier '${node.name}'.`,
147147
locs.start,
148148
locs.loc.start.line,
149-
locs.loc.start.column + 1
149+
locs.loc.start.column + 1,
150150
);
151151
throw err;
152152
}
@@ -164,7 +164,7 @@ export function throwUnexpectedNodeError(
164164
`Unexpected ${type} literal.`,
165165
locs.start,
166166
locs.loc.start.line,
167-
locs.loc.start.column + 1
167+
locs.loc.start.column + 1,
168168
);
169169
throw err;
170170
}
@@ -174,7 +174,7 @@ export function throwUnexpectedNodeError(
174174
"Unexpected template literal.",
175175
locs.start,
176176
locs.loc.start.line,
177-
locs.loc.start.column + 1
177+
locs.loc.start.column + 1,
178178
);
179179
throw err;
180180
}
@@ -188,7 +188,7 @@ export function throwUnexpectedNodeError(
188188
`Unexpected ${name}.`,
189189
locs.start,
190190
locs.loc.start.line,
191-
locs.loc.start.column + 1
191+
locs.loc.start.column + 1,
192192
);
193193
throw err;
194194
}
@@ -200,15 +200,15 @@ export function throwUnexpectedNodeError(
200200
`Unexpected token '${name}'.`,
201201
locs.start,
202202
locs.loc.start.line,
203-
locs.loc.start.column + 1
203+
locs.loc.start.column + 1,
204204
);
205205

206206
throw err;
207207
}
208208

209209
/** get locations */
210210
function getLocation(
211-
token: MaybeNodeOrToken & { start?: number; end?: number }
211+
token: MaybeNodeOrToken & { start?: number; end?: number },
212212
) {
213213
const start = token.range?.[0] ?? token.start!;
214214
const end = token.range?.[1] ?? token.end!;

src/parser/extend-parser.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export function getParser(): typeof Parser {
4040
nodes: Node[];
4141
},
4242
code: string,
43-
pos: number
43+
pos: number,
4444
) {
4545
super(
4646
((): Options => {
@@ -84,7 +84,7 @@ export function getParser(): typeof Parser {
8484
};
8585
})(),
8686
code,
87-
pos
87+
pos,
8888
);
8989
this[PRIVATE] = {
9090
code,
@@ -118,7 +118,7 @@ export function getParser(): typeof Parser {
118118
message,
119119
pos,
120120
loc.line,
121-
loc.column + 1 // acorn uses 0-based columns
121+
loc.column + 1, // acorn uses 0-based columns
122122
);
123123
throw err;
124124
}
@@ -171,12 +171,12 @@ export function getAnyTokenErrorParser(): typeof Parser {
171171
onToken: (token) => {
172172
return throwUnexpectedTokenError(
173173
code.slice(...token.range!),
174-
token
174+
token,
175175
);
176176
},
177177
},
178178
code,
179-
pos
179+
pos,
180180
);
181181
}
182182
};

src/parser/modules/espree.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ export function getNewestEspreeKind(): NewestKind {
6161
return kindCache;
6262
}
6363
const cwdPkg: { version: string } | null = requireFromCwd(
64-
"espree/package.json"
64+
"espree/package.json",
6565
);
6666
const linterPkg: { version: string } | null = requireFromLinter(
67-
"espree/package.json"
67+
"espree/package.json",
6868
);
6969
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports -- ignore
7070
const self: { version: string } = require("espree/package.json");

src/parser/modules/require-utils.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import type ModuleClass from "module";
66
* createRequire
77
*/
88
export function createRequire(
9-
filename: string
9+
filename: string,
1010
): ReturnType<typeof ModuleClass.createRequire> {
1111
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports, @typescript-eslint/naming-convention -- special require
1212
const Module = require("module");
1313
const fn: (
14-
fileName: string
14+
fileName: string,
1515
) => // eslint-disable-next-line @typescript-eslint/no-explicit-any -- any
1616
any =
1717
// Added in v12.2.0
@@ -99,7 +99,7 @@ export function requireFromCwd<T>(module: string): T | null {
9999
* Get the newest `espree` kind from the loaded ESLint or dependency.
100100
*/
101101
export function loadNewest<T>(
102-
items: { getPkg: () => { version: string } | null; get: () => T | null }[]
102+
items: { getPkg: () => { version: string } | null; get: () => T | null }[],
103103
): T {
104104
let target: { version: string; get: () => T | null } | null = null;
105105
for (const item of items) {

src/parser/parser.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const DEFAULT_ECMA_VERSION = "latest";
1818
export function parseForESLint(
1919
code: string,
2020
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- any
21-
options?: any
21+
options?: any,
2222
): {
2323
ast: JSONProgram;
2424
visitorKeys: SourceCode.VisitorKeys;
@@ -37,7 +37,7 @@ export function parseForESLint(
3737
comment: true,
3838
eslintVisitorKeys: true,
3939
eslintScopeManager: true,
40-
}
40+
},
4141
);
4242
parserOptions.ecmaVersion = normalizeEcmaVersion(parserOptions.ecmaVersion);
4343
const ctx: JSONSyntaxContext = getJSONSyntaxContext(parserOptions.jsonSyntax);
@@ -59,7 +59,7 @@ export function parseForESLint(
5959
let lastIndex = Math.max(
6060
baseAst.range![1],
6161
tokens[tokens.length - 1]?.range[1] ?? 0,
62-
comments[comments.length - 1]?.range![1] ?? 0
62+
comments[comments.length - 1]?.range![1] ?? 0,
6363
);
6464
let lastChar = code[lastIndex];
6565
while (

src/parser/token-store.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export class TokenStore {
2121

2222
private findIndexByOffset(offset: number): number {
2323
return this.tokens.findIndex(
24-
(token) => token.range[0] <= offset && offset < token.range[1]
24+
(token) => token.range[0] <= offset && offset < token.range[1],
2525
);
2626
}
2727

@@ -50,7 +50,7 @@ export class TokenStore {
5050
*/
5151
public getTokenBefore(
5252
nodeOrToken: MaybeNodeOrToken,
53-
filter?: (token: AST.Token) => boolean
53+
filter?: (token: AST.Token) => boolean,
5454
): AST.Token | null {
5555
const tokenIndex = this.findIndexByOffset(nodeOrToken.range![0]);
5656

@@ -68,7 +68,7 @@ export class TokenStore {
6868
*/
6969
public getTokenAfter(
7070
nodeOrToken: MaybeNodeOrToken,
71-
filter?: (token: AST.Token) => boolean
71+
filter?: (token: AST.Token) => boolean,
7272
): AST.Token | null {
7373
const tokenIndex = this.findIndexByOffset(nodeOrToken.range![0]);
7474

@@ -86,7 +86,7 @@ export class TokenStore {
8686
* Checks if given token is comma
8787
*/
8888
export function isComma(
89-
token: AST.Token
89+
token: AST.Token,
9090
): token is AST.Token & { type: "Punctuator"; value: "," } {
9191
return token.type === "Punctuator" && token.value === ",";
9292
}

0 commit comments

Comments
 (0)