Skip to content

Commit 2908014

Browse files
committed
Fix compliance issue.
Numeric literal may not be used as identifier.
1 parent 6a93df5 commit 2908014

File tree

3 files changed

+53
-4
lines changed

3 files changed

+53
-4
lines changed

package.json

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"publishConfig": {
66
"access": "public"
77
},
8+
"homepage": "https://letsflow.io/jmespath",
89
"contributors": [
910
{
1011
"name": "Arnold Daniels",
@@ -43,5 +44,47 @@
4344
"license": "MPL-2.0",
4445
"engines": {
4546
"node": ">=14.0.0"
46-
}
47+
},
48+
"scripts": {
49+
"lint": "npx eslint --ignore-path .eslintignore './{src,test}/**/*.{js,ts}'",
50+
"lint:fix": "npm run lint -- --fix",
51+
"prebuild": "npx rimraf dist",
52+
"build": "npx tsc --outDir dist/lib -d --module commonjs && npx rollup -c rollup.config.ts",
53+
"perf": "node --expose-gc scripts/perf.js",
54+
"start": "npx rollup -c rollup.config.ts -w",
55+
"test": "vitest --run",
56+
"test:watch": "vitest",
57+
"test:prod": "npm run lint && npm run test",
58+
"coverage": "vitest run --coverage",
59+
"deploy-docs": "ts-node scripts/gh-pages-publish",
60+
"report-coverage": "cat ./coverage/lcov.info | coveralls",
61+
"precommit": "lint-staged",
62+
"prepack": "npx clear-package-json package.json --output ./package.json"
63+
},
64+
"devDependencies": {
65+
"@rollup/plugin-json": "^4.1.0",
66+
"@rollup/plugin-node-resolve": "^13.0.0",
67+
"@rollup/plugin-terser": "^0.4.0",
68+
"@rollup/plugin-typescript": "^8.2.1",
69+
"@typescript-eslint/eslint-plugin": "^4.26.0",
70+
"@typescript-eslint/parser": "^4.26.0",
71+
"@vitest/coverage-v8": "^2.1.8",
72+
"clean-publish": "^3.4.5",
73+
"coveralls-next": "^4.2.0",
74+
"eslint": "^7.27.0",
75+
"eslint-config-prettier": "^8.6.0",
76+
"eslint-plugin-prettier": "^3.4.1",
77+
"husky": "^6.0.0",
78+
"lint-staged": "^11.0.0",
79+
"prettier": "^2.3.0",
80+
"prettier-eslint": "^12.0.0",
81+
"rimraf": "^3.0.2",
82+
"rollup": "^2.50.5",
83+
"rollup-plugin-typescript2": "^0.34.1",
84+
"shelljs": "^0.8.4",
85+
"tinybench": "^2.5.1",
86+
"ts-node": "^10.9.1",
87+
"typescript": "^4.3.2",
88+
"vitest": "^2.1.8"
89+
}
4790
}

src/Lexer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ class StreamLexer {
312312
}
313313
if (numberLooking.includes(literalString[0])) {
314314
// eslint-disable-next-line @typescript-eslint/naming-convention
315-
const [_, ok] = this.parseJSON(literalString);
315+
const [, ok] = this.parseJSON(literalString);
316316
return ok;
317317
}
318318
return false;

src/Parser.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,13 @@ class TokenParser {
110110
switch (token.type) {
111111
case Token.TOK_VARIABLE:
112112
return { type: 'Variable', name: token.value as string };
113-
case Token.TOK_NUMBER:
113+
case Token.TOK_NUMBER: {
114+
if (this.lookahead(0) === Token.TOK_RBRACKET || this.lookahead(0) === Token.TOK_COMMA) {
115+
throw new Error('Syntax error: numeric literal is not allowed as identifier.');
116+
} else {
117+
return { type: 'Literal', value: token.value };
118+
}
119+
}
114120
case Token.TOK_LITERAL:
115121
return { type: 'Literal', value: token.value };
116122
case Token.TOK_UNQUOTEDIDENTIFIER: {
@@ -191,7 +197,7 @@ class TokenParser {
191197
}
192198
case Token.TOK_LPAREN: {
193199
const args: ExpressionNode[] = [];
194-
let expression = this.expression(0);
200+
const expression = this.expression(0);
195201
args.push(expression);
196202
this.match(Token.TOK_RPAREN);
197203
return args[0];

0 commit comments

Comments
 (0)