-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update dependency @ota-meshi/eslint-plugin to ^0.12.0 (#140)
* Update dependency @ota-meshi/eslint-plugin to ^0.12.0 * format Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Yosuke Ota <[email protected]>
- Loading branch information
1 parent
7b630e9
commit 64354d5
Showing
30 changed files
with
3,177 additions
and
3,218 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,75 @@ | ||
// eslint-disable-next-line eslint-comments/disable-enable-pair -- ignore | ||
/* eslint-disable require-jsdoc, no-console -- ignore */ | ||
import * as Benchmark from "benchmark" | ||
import fs from "fs" | ||
import { parseForESLint } from ".." | ||
import { parseForESLint as parseOld } from "../node_modules/jsonc-eslint-parser" | ||
import * as Benchmark from "benchmark"; | ||
import fs from "fs"; | ||
import { parseForESLint } from ".."; | ||
import { parseForESLint as parseOld } from "../node_modules/jsonc-eslint-parser"; | ||
|
||
const contents = `${fs.readFileSync( | ||
require.resolve("../package.json"), | ||
"utf-8", | ||
)}// comments` | ||
require.resolve("../package.json"), | ||
"utf-8" | ||
)}// comments`; | ||
|
||
type Result = { name: string; hz: number } | ||
const results: Result[] = [] | ||
type Result = { name: string; hz: number }; | ||
const results: Result[] = []; | ||
|
||
function format(hz: number): string { | ||
return (~~(hz * 100) / 100).toString().padEnd(4, " ").padStart(6, " ") | ||
return (~~(hz * 100) / 100).toString().padEnd(4, " ").padStart(6, " "); | ||
} | ||
|
||
function onCycle(event: { target: Result }): void { | ||
const { name, hz } = event.target | ||
results.push({ name, hz }) | ||
const { name, hz } = event.target; | ||
results.push({ name, hz }); | ||
|
||
console.log(event.target.toString()) | ||
console.log(event.target.toString()); | ||
} | ||
|
||
function onComplete(): void { | ||
console.log("-".repeat(72)) | ||
const map: Record<string, number[]> = {} | ||
for (const result of results) { | ||
const r = (map[result.name.slice(2)] ??= []) | ||
r.push(result.hz) | ||
} | ||
for (const name of Object.keys(map)) { | ||
console.log( | ||
`${name.padEnd(15)} ${format( | ||
map[name].reduce((p, a) => p + a, 0) / map[name].length, | ||
)} ops/sec`, | ||
) | ||
} | ||
for (let i = 0; i < results.length; ++i) { | ||
const result = results[i] | ||
console.log("-".repeat(72)); | ||
const map: Record<string, number[]> = {}; | ||
for (const result of results) { | ||
const r = (map[result.name.slice(2)] ??= []); | ||
r.push(result.hz); | ||
} | ||
for (const name of Object.keys(map)) { | ||
console.log( | ||
`${name.padEnd(15)} ${format( | ||
map[name].reduce((p, a) => p + a, 0) / map[name].length | ||
)} ops/sec` | ||
); | ||
} | ||
for (let i = 0; i < results.length; ++i) { | ||
const result = results[i]; | ||
|
||
console.log(`${result.name.padEnd(15)} ${format(result.hz)} ops/sec`) | ||
} | ||
console.log(`${result.name.padEnd(15)} ${format(result.hz)} ops/sec`); | ||
} | ||
} | ||
|
||
const suite = new Benchmark.Suite("benchmark", { onCycle, onComplete }) | ||
const suite = new Benchmark.Suite("benchmark", { onCycle, onComplete }); | ||
|
||
for (const no of [1, 2, 3]) { | ||
suite.add(`${no} new jsonc-eslint-parser`, function () { | ||
parseForESLint(contents, { | ||
loc: true, | ||
range: true, | ||
raw: true, | ||
tokens: true, | ||
comment: true, | ||
eslintVisitorKeys: true, | ||
eslintScopeManager: true, | ||
}) | ||
}) | ||
suite.add(`${no} old jsonc-eslint-parser`, function () { | ||
parseOld(contents, { | ||
loc: true, | ||
range: true, | ||
raw: true, | ||
tokens: true, | ||
comment: true, | ||
eslintVisitorKeys: true, | ||
eslintScopeManager: true, | ||
}) | ||
}) | ||
suite.add(`${no} new jsonc-eslint-parser`, function () { | ||
parseForESLint(contents, { | ||
loc: true, | ||
range: true, | ||
raw: true, | ||
tokens: true, | ||
comment: true, | ||
eslintVisitorKeys: true, | ||
eslintScopeManager: true, | ||
}); | ||
}); | ||
suite.add(`${no} old jsonc-eslint-parser`, function () { | ||
parseOld(contents, { | ||
loc: true, | ||
range: true, | ||
raw: true, | ||
tokens: true, | ||
comment: true, | ||
eslintVisitorKeys: true, | ||
eslintScopeManager: true, | ||
}); | ||
}); | ||
} | ||
|
||
suite.run() | ||
suite.run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,40 @@ | ||
import { parseForESLint } from "./parser/parser" | ||
import { traverseNodes } from "./parser/traverse" | ||
import { parseForESLint } from "./parser/parser"; | ||
import { traverseNodes } from "./parser/traverse"; | ||
import { | ||
getStaticJSONValue, | ||
isExpression, | ||
isNumberIdentifier, | ||
isUndefinedIdentifier, | ||
} from "./utils/ast" | ||
getStaticJSONValue, | ||
isExpression, | ||
isNumberIdentifier, | ||
isUndefinedIdentifier, | ||
} from "./utils/ast"; | ||
|
||
import type * as AST from "./parser/ast" | ||
import { getVisitorKeys } from "./parser/visitor-keys" | ||
import type * as AST from "./parser/ast"; | ||
import { getVisitorKeys } from "./parser/visitor-keys"; | ||
|
||
// parser | ||
export { parseForESLint } | ||
export { parseForESLint }; | ||
// Keys | ||
// eslint-disable-next-line @typescript-eslint/naming-convention -- parser module | ||
export const VisitorKeys = getVisitorKeys() | ||
export const VisitorKeys = getVisitorKeys(); | ||
|
||
// tools | ||
export { | ||
traverseNodes, | ||
getStaticJSONValue, | ||
isExpression, | ||
isNumberIdentifier, | ||
isUndefinedIdentifier, | ||
} | ||
traverseNodes, | ||
getStaticJSONValue, | ||
isExpression, | ||
isNumberIdentifier, | ||
isUndefinedIdentifier, | ||
}; | ||
|
||
/** | ||
* Parse JSON source code | ||
*/ | ||
export function parseJSON( | ||
code: string, | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- any | ||
options?: any, | ||
code: string, | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- any | ||
options?: any | ||
): AST.JSONProgram { | ||
return parseForESLint(code, options).ast as never | ||
return parseForESLint(code, options).ast as never; | ||
} | ||
|
||
// types | ||
export { AST } | ||
export { AST }; |
Oops, something went wrong.