Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update FieldDefinition -> PropertyDefinition and related dependencies for ESTree changes #11

Merged
merged 1 commit into from
Jun 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
230 changes: 200 additions & 30 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@
"@types/estree": "*"
},
"devDependencies": {
"acorn": "^7.2.0",
"acorn-class-fields": "^0.3.2",
"acorn-static-class-features": "^0.2.1",
"acorn": "^8.0.5",
"acorn-class-fields": "^1.0.0",
"acorn-static-class-features": "^1.0.0",
"estree-walker": "^3.0.0",
"typescript": "^3.9.2",
"typescript": "^4.1.5",
"uvu": "^0.5.1"
}
}
10 changes: 5 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
//@ts-check
/** @typedef { import('estree').Node} Node */
/** @typedef {Node | {
* type: 'FieldDefinition';
* type: 'PropertyDefinition';
* computed: boolean;
* value: Node
* }} NodeWithFieldDefinition */
* }} NodeWithPropertyDefinition */

/**
*
* @param {NodeWithFieldDefinition} node
* @param {NodeWithFieldDefinition} parent
* @param {NodeWithPropertyDefinition} node
* @param {NodeWithPropertyDefinition} parent
* @returns boolean
*/
export default function is_reference (node, parent) {
Expand All @@ -28,7 +28,7 @@ export default function is_reference (node, parent) {
case 'MethodDefinition': return parent.computed;

// disregard the `foo` in `class {foo=bar}` but keep it in `class {[foo]=bar}` and `class {bar=foo}`
case 'FieldDefinition': return parent.computed || node === parent.value;
case 'PropertyDefinition': return parent.computed || node === parent.value;

// disregard the `bar` in `{ bar: foo }`, but keep it in `{ [bar]: foo }`
case 'Property': return parent.computed || node === parent.value;
Expand Down
2 changes: 1 addition & 1 deletion test/test.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import acorn from 'acorn';
import * as acorn from 'acorn';
import injectClassFields from 'acorn-class-fields';
import injectStaticClassFeatures from 'acorn-static-class-features';
import { walk } from 'estree-walker';
Expand Down