Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jsonc-eslint-parser

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsonc-eslint-parser - npm Package Compare versions

Comparing version 0.6.0 to 0.6.1

11

lib/index.js

@@ -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;

13

lib/parser/parser.js

@@ -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 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc