jsonc-eslint-parser
Advanced tools
Comparing version 0.6.0 to 0.6.1
@@ -16,13 +16,4 @@ "use strict"; | ||
function parseJSON(code, options) { | ||
const parserOptions = Object.assign({ filePath: "<input>", ecmaVersion: 2019 }, options || {}, { | ||
loc: true, | ||
range: true, | ||
raw: true, | ||
tokens: true, | ||
comment: true, | ||
eslintVisitorKeys: true, | ||
eslintScopeManager: true, | ||
}); | ||
return parser_1.parseForESLint(code, parserOptions).ast; | ||
return parser_1.parseForESLint(code, options).ast; | ||
} | ||
exports.parseJSON = parseJSON; |
@@ -10,4 +10,13 @@ "use strict"; | ||
function parseForESLint(code, options) { | ||
const parserOptions = Object.assign({ filePath: "<input>", ecmaVersion: 2019 }, options || {}, { | ||
loc: true, | ||
range: true, | ||
raw: true, | ||
tokens: true, | ||
comment: true, | ||
eslintVisitorKeys: true, | ||
eslintScopeManager: true, | ||
}); | ||
try { | ||
const ast = parseJS(`0(${code}\n)`, options); | ||
const ast = parseJS(`0(${code}\n)`, parserOptions); | ||
const tokens = ast.tokens || []; | ||
@@ -41,3 +50,3 @@ const tokenStore = new token_store_1.TokenStore(tokens); | ||
return { | ||
ast: postprocess(ast, tokenStore, options), | ||
ast: postprocess(ast, tokenStore, parserOptions), | ||
visitorKeys: visitor_keys_1.KEYS, | ||
@@ -44,0 +53,0 @@ services: { |
@@ -8,3 +8,3 @@ import type { AST } from "eslint"; | ||
export declare class TokenStore { | ||
private tokens; | ||
private readonly tokens; | ||
constructor(tokens: AST.Token[]); | ||
@@ -11,0 +11,0 @@ findIndexByOffset(offset: number): number; |
@@ -11,6 +11,3 @@ import type { JSONNode, JSONExpression, JSONNumberIdentifier, JSONIdentifier, JSONObjectExpression, JSONArrayExpression, JSONUnaryExpression, JSONNumberLiteral, JSONExpressionStatement, JSONProgram, JSONUndefinedIdentifier, JSONTemplateLiteral, JSONTemplateElement, JSONStringLiteral, JSONKeywordLiteral, JSONRegExpLiteral, JSONBigIntLiteral, JSONLiteral } from "../parser/ast"; | ||
export declare function getStaticJSONValue(node: JSONUndefinedIdentifier): undefined; | ||
export declare function getStaticJSONValue(node: JSONTemplateLiteral): string; | ||
export declare function getStaticJSONValue(node: JSONTemplateElement): string; | ||
export declare function getStaticJSONValue(node: JSONStringLiteral): string; | ||
export declare function getStaticJSONValue(node: JSONNumberLiteral): number; | ||
export declare function getStaticJSONValue(node: JSONTemplateLiteral | JSONTemplateElement | JSONStringLiteral): string; | ||
export declare function getStaticJSONValue(node: JSONKeywordLiteral): boolean | null; | ||
@@ -22,4 +19,2 @@ export declare function getStaticJSONValue(node: JSONRegExpLiteral): RegExp; | ||
export declare function getStaticJSONValue(node: JSONArrayExpression): JSONValue[]; | ||
export declare function getStaticJSONValue(node: JSONExpression | JSONExpressionStatement): JSONValue; | ||
export declare function getStaticJSONValue(node: JSONProgram): JSONValue; | ||
export declare function getStaticJSONValue(node: JSONNode): JSONValue; | ||
export declare function getStaticJSONValue(node: JSONExpression | JSONExpressionStatement | JSONProgram | JSONNode): JSONValue; |
@@ -29,6 +29,2 @@ "use strict"; | ||
exports.isUndefinedIdentifier = isUndefinedIdentifier; | ||
function getStaticJSONValue(node) { | ||
return resolver[node.type](node); | ||
} | ||
exports.getStaticJSONValue = getStaticJSONValue; | ||
const resolver = { | ||
@@ -112,1 +108,5 @@ Program(node) { | ||
}; | ||
function getStaticJSONValue(node) { | ||
return resolver[node.type](node); | ||
} | ||
exports.getStaticJSONValue = getStaticJSONValue; |
{ | ||
"name": "jsonc-eslint-parser", | ||
"version": "0.6.0", | ||
"version": "0.6.1", | ||
"description": "JSON, JSONC and JSON5 parser for use with ESLint plugins", | ||
@@ -42,6 +42,6 @@ "main": "lib/index.js", | ||
"devDependencies": { | ||
"@ota-meshi/eslint-plugin": "0.0.0", | ||
"@ota-meshi/eslint-plugin": ">=0.0.0", | ||
"@types/eslint": "^7.2.0", | ||
"@types/eslint-visitor-keys": "^1.0.0", | ||
"@types/estree": "0.0.44", | ||
"@types/estree": "^0.0.45", | ||
"@types/mocha": "^7.0.2", | ||
@@ -51,4 +51,4 @@ "@types/natural-compare": "^1.4.0", | ||
"@types/semver": "^7.3.1", | ||
"@typescript-eslint/eslint-plugin": "4.0.0-alpha.9", | ||
"@typescript-eslint/parser": "4.0.0-alpha.9", | ||
"@typescript-eslint/eslint-plugin": "^4.0.0-0", | ||
"@typescript-eslint/parser": "^4.0.0-0", | ||
"eslint": "^7.3.0", | ||
@@ -65,3 +65,4 @@ "eslint-config-prettier": "^6.11.0", | ||
"ts-node": "^8.10.2", | ||
"typescript": "^3.9.7" | ||
"typescript": "^3.9.7", | ||
"vue-eslint-parser": "^7.2.0" | ||
}, | ||
@@ -68,0 +69,0 @@ "dependencies": { |
@@ -62,2 +62,8 @@ # jsonc-eslint-parser | ||
## Usage for Custom Rules / Plugins | ||
- [AST.md](./docs/AST.md) is AST specification. | ||
- [no-template-literals.ts](https://github.com/ota-meshi/eslint-plugin-jsonc/blob/master/lib/rules/no-template-literals.ts) is an example. | ||
- You can see the AST on the [DEMO](https://ota-meshi.github.io/jsonc-eslint-parser/). | ||
## :lock: License | ||
@@ -64,0 +70,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
54553
77
23
1239