-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
switch from jstestr to mocha; track coverage; drop node <8 (#84)
- Breaking change: To ensure passing `nyc`, bump `engines` to Node 8 - Fix: Multiple leading decimals were not being handled correctly (produced inner array followed by "." such that `21.` (e.g., at beginning of "21.35") would be processed instead as `2,1.`) - Enhancement: Throw for unknown operator - Refactoring: Avoid unnecessary code to unescape `\\a` (`\a` has no special meaning) - Maintenance: Add pegjs as 2 sp. in `.editorconfig` - Testing: Expand to effective 100% coverage - Testing: Switch from jstestr to mocha - Testing: Get coverage for bad operator, class name, and selector type - Simplify `leadingDecimals` setting in grammar - Add coverage thresholds (tentatively at 100%) - Update .eslintrc.js - Remove deprecated `preferGlobal`: https://docs.npmjs.com/files/package.json#preferglobal - Fix test name to reflect contents - cover more lines - fix linting - gitignore nyc_output Co-authored-by: Michael Ficarra <[email protected]>
- Loading branch information
1 parent
8a5b594
commit 176a6b1
Showing
37 changed files
with
1,485 additions
and
1,261 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 |
---|---|---|
|
@@ -13,3 +13,6 @@ indent_size = 4 | |
|
||
[*.json] | ||
indent_size = 2 | ||
|
||
[*.pegjs] | ||
indent_size = 2 |
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,3 +1,4 @@ | ||
node_modules | ||
coverage | ||
dist | ||
/.nyc_output | ||
/node_modules | ||
/coverage | ||
/dist |
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
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,6 +1,5 @@ | ||
{ | ||
"name": "esquery", | ||
"preferGlobal": false, | ||
"version": "1.1.0", | ||
"author": "Joel Feenstra <[email protected]>", | ||
"contributors": [], | ||
|
@@ -13,11 +12,27 @@ | |
"license.txt", | ||
"README.md" | ||
], | ||
"nyc": { | ||
"branches": 100, | ||
"lines": 100, | ||
"functions": 100, | ||
"statements": 100, | ||
"reporter": [ | ||
"html", | ||
"text" | ||
], | ||
"exclude": [ | ||
"parser.js", | ||
"dist", | ||
"tests" | ||
] | ||
}, | ||
"scripts": { | ||
"build-parser": "rm parser.js && pegjs --cache --format umd -o \"parser.js\" \"grammar.pegjs\"", | ||
"build-browser-only": "rollup -c", | ||
"build-browser": "npm run build-parser && npm run build-browser-only", | ||
"test": "jstestr path=tests", | ||
"mocha": "mocha --require chai/register-assert --require esm tests", | ||
"test": "nyc npm run mocha", | ||
"lint": "eslint ." | ||
}, | ||
"repository": { | ||
|
@@ -36,16 +51,19 @@ | |
"@rollup/plugin-commonjs": "^11.0.2", | ||
"@rollup/plugin-json": "^4.0.2", | ||
"@rollup/plugin-node-resolve": "^7.1.1", | ||
"chai": "^4.2.0", | ||
"eslint": "^6.8.0", | ||
"esm": "^3.2.25", | ||
"esprima": "~4.0.1", | ||
"jstestr": ">=0.4", | ||
"mocha": "^7.1.0", | ||
"nyc": "^15.0.0", | ||
"pegjs": "~0.10.0", | ||
"rollup": "^1.32.0", | ||
"rollup-plugin-terser": "^5.2.0" | ||
}, | ||
"license": "BSD-3-Clause", | ||
"engines": { | ||
"node": ">=4.0" | ||
"node": ">=8.0" | ||
}, | ||
"dependencies": { | ||
"estraverse": "^4.3.0" | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,119 +1,112 @@ | ||
// eslint-disable-next-line no-unused-vars | ||
define(["esprima"], function (esprima) { | ||
|
||
// return esprima.parse("function a(){ [a] = () => 0; new.target; `test`; `hello,${name}`; }"); | ||
|
||
return { | ||
"type": "Program", | ||
"body": [ | ||
{ | ||
"type": "FunctionDeclaration", | ||
"id": { | ||
"type": "Identifier", | ||
"name": "a" | ||
}, | ||
"params": [], | ||
"defaults": [], | ||
"body": { | ||
"type": "BlockStatement", | ||
"body": [ | ||
{ | ||
"type": "ExpressionStatement", | ||
"expression": { | ||
"type": "AssignmentExpression", | ||
"operator": "=", | ||
"left": { | ||
"type": "ArrayPattern", | ||
"elements": [ | ||
{ | ||
"type": "Identifier", | ||
"name": "a" | ||
} | ||
] | ||
export default { | ||
"type": "Program", | ||
"body": [ | ||
{ | ||
"type": "FunctionDeclaration", | ||
"id": { | ||
"type": "Identifier", | ||
"name": "a" | ||
}, | ||
"params": [], | ||
"defaults": [], | ||
"body": { | ||
"type": "BlockStatement", | ||
"body": [ | ||
{ | ||
"type": "ExpressionStatement", | ||
"expression": { | ||
"type": "AssignmentExpression", | ||
"operator": "=", | ||
"left": { | ||
"type": "ArrayPattern", | ||
"elements": [ | ||
{ | ||
"type": "Identifier", | ||
"name": "a" | ||
} | ||
] | ||
}, | ||
"right": { | ||
"type": "ArrowFunctionExpression", | ||
"params": [], | ||
"defaults": [], | ||
"rest": null, | ||
"body": { | ||
"type": "Literal", | ||
"value": 0, | ||
"raw": "0" | ||
}, | ||
"right": { | ||
"type": "ArrowFunctionExpression", | ||
"params": [], | ||
"defaults": [], | ||
"rest": null, | ||
"body": { | ||
"type": "Literal", | ||
"value": 0, | ||
"raw": "0" | ||
}, | ||
"generator": false, | ||
"expression": false | ||
} | ||
"generator": false, | ||
"expression": false | ||
} | ||
} | ||
}, | ||
{ | ||
"type": "ExpressionStatement", | ||
"expression": { | ||
"type": "MetaProperty", | ||
"meta": { | ||
"type": "Identifier", | ||
"name": "new", | ||
}, | ||
{ | ||
"type": "ExpressionStatement", | ||
"expression": { | ||
"type": "MetaProperty", | ||
"meta": { | ||
"type": "Identifier", | ||
"name": "new", | ||
}, | ||
"property": { | ||
"type": "Identifier", | ||
"name": "target", | ||
}, | ||
}, | ||
"property": { | ||
"type": "Identifier", | ||
"name": "target", | ||
}, | ||
{ | ||
"type": "ExpressionStatement", | ||
"expression": { | ||
}, | ||
}, | ||
{ | ||
"type": "ExpressionStatement", | ||
"expression": { | ||
"type": "TemplateLiteral", | ||
"quasis": [ | ||
{ | ||
"type": "TemplateElement", | ||
"value": { | ||
"raw": "test", | ||
"cooked": "test" | ||
}, | ||
"tail": true, | ||
} | ||
], | ||
"expressions": [], | ||
}, | ||
}, | ||
{ | ||
"type": "ExpressionStatement", | ||
"expression": { | ||
"type": "TemplateLiteral", | ||
"quasis": [ | ||
{ | ||
"type": "TemplateElement", | ||
"value": { | ||
"raw": "test", | ||
"cooked": "test" | ||
{ | ||
"type": "TemplateElement", | ||
"value": { | ||
"raw": "hello,", | ||
"cooked": "hello," | ||
}, | ||
"tail": false, | ||
}, | ||
"tail": true, | ||
} | ||
{ | ||
"type": "TemplateElement", | ||
"value": { | ||
"raw": "", | ||
"cooked": "" | ||
}, | ||
"tail": true, | ||
} | ||
], | ||
"expressions": [ | ||
{ | ||
"type": "Identifier", | ||
"name": "name", | ||
} | ||
], | ||
"expressions": [], | ||
}, | ||
}, | ||
{ | ||
"type": "ExpressionStatement", | ||
"expression": { | ||
"type": "TemplateLiteral", | ||
"quasis": [ | ||
{ | ||
"type": "TemplateElement", | ||
"value": { | ||
"raw": "hello,", | ||
"cooked": "hello," | ||
}, | ||
"tail": false, | ||
}, | ||
{ | ||
"type": "TemplateElement", | ||
"value": { | ||
"raw": "", | ||
"cooked": "" | ||
}, | ||
"tail": true, | ||
} | ||
], | ||
"expressions": [ | ||
{ | ||
"type": "Identifier", | ||
"name": "name", | ||
} | ||
], | ||
}, | ||
} | ||
] | ||
}, | ||
"rest": null, | ||
"generator": false, | ||
"expression": false | ||
} | ||
] | ||
}; | ||
|
||
}); | ||
} | ||
] | ||
}, | ||
"rest": null, | ||
"generator": false, | ||
"expression": false | ||
} | ||
] | ||
}; |
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,7 +1,7 @@ | ||
define(["esprima"], function (esprima) { | ||
import * as esprima from "esprima"; | ||
|
||
return esprima.parse( | ||
'[1, 2, 3, foo, bar, 4, 5, baz, qux, 6]' | ||
); | ||
var parsed = esprima.parse( | ||
'[1, 2, 3, foo, bar, 4, 5, baz, qux, 6]' | ||
); | ||
|
||
}); | ||
export default parsed; |
Oops, something went wrong.