Skip to content

Commit fb4b00c

Browse files
Merge pull request #101 from mysticatea/fix-meta-property
Fix meta property
2 parents 87ec828 + bb64582 commit fb4b00c

File tree

4 files changed

+60
-70
lines changed

4 files changed

+60
-70
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"babel-register": "^6.3.13",
3131
"browserify": "^13.0.0",
3232
"chai": "^3.4.1",
33-
"espree": "^2.2.5",
33+
"espree": "^3.1.1",
3434
"esprima": "^2.7.1",
3535
"gulp": "^3.9.0",
3636
"gulp-babel": "^6.1.1",

src/referencer.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,10 @@ export default class Referencer extends esrecurse.Visitor {
575575
let local = (node.id || node.local);
576576
this.visit(local);
577577
}
578+
579+
MetaProperty() {
580+
// do nothing.
581+
}
578582
}
579583

580584
/* vim: set sw=4 ts=4 et tw=80 : */

test/es6-new-target.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// -*- coding: utf-8 -*-
2+
// Copyright (C) 2014 Yusuke Suzuki <[email protected]>
3+
//
4+
// Redistribution and use in source and binary forms, with or without
5+
// modification, are permitted provided that the following conditions are met:
6+
//
7+
// * Redistributions of source code must retain the above copyright
8+
// notice, this list of conditions and the following disclaimer.
9+
// * Redistributions in binary form must reproduce the above copyright
10+
// notice, this list of conditions and the following disclaimer in the
11+
// documentation and/or other materials provided with the distribution.
12+
//
13+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14+
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15+
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16+
// ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
17+
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18+
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19+
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20+
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22+
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23+
24+
import { expect } from 'chai';
25+
import { analyze } from '..';
26+
27+
const parse = require('../third_party/espree');
28+
29+
describe('ES6 new.target', function() {
30+
it('should not make references of new.target', function() {
31+
const ast = parse(`
32+
class A {
33+
constructor() {
34+
new.target;
35+
}
36+
}
37+
`);
38+
39+
const scopeManager = analyze(ast, {ecmaVersion: 6});
40+
expect(scopeManager.scopes).to.have.length(3);
41+
42+
const scope = scopeManager.scopes[2];
43+
expect(scope.type).to.be.equal('function');
44+
expect(scope.block.type).to.be.equal('FunctionExpression');
45+
expect(scope.isStrict).to.be.true;
46+
expect(scope.variables).to.have.length(1);
47+
expect(scope.variables[0].name).to.be.equal('arguments');
48+
expect(scope.references).to.have.length(0);
49+
});
50+
});
51+
52+
// vim: set sw=4 ts=4 et tw=80 :

third_party/espree.js

Lines changed: 3 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -47,75 +47,9 @@ module.exports = function (code) {
4747
// top-level errors array
4848
tolerant: true,
4949

50-
// specify parsing features (default only has blockBindings: true)
51-
ecmaFeatures: {
52-
53-
// enable parsing of arrow functions
54-
arrowFunctions: true,
55-
56-
// enable parsing of let/const
57-
blockBindings: true,
58-
59-
// enable parsing of destructured arrays and objects
60-
destructuring: true,
61-
62-
// enable parsing of regular expression y flag
63-
regexYFlag: true,
64-
65-
// enable parsing of regular expression u flag
66-
regexUFlag: true,
67-
68-
// enable parsing of template strings
69-
templateStrings: true,
70-
71-
// enable parsing of binary literals
72-
binaryLiterals: true,
73-
74-
// enable parsing of ES6 octal literals
75-
octalLiterals: true,
76-
77-
// enable parsing unicode code point escape sequences
78-
unicodeCodePointEscapes: true,
79-
80-
// enable parsing of default parameters
81-
defaultParams: true,
82-
83-
// enable parsing of rest parameters
84-
restParams: true,
85-
86-
// enable parsing of for-of statement
87-
forOf: true,
88-
89-
// enable parsing computed object literal properties
90-
objectLiteralComputedProperties: true,
91-
92-
// enable parsing of shorthand object literal methods
93-
objectLiteralShorthandMethods: true,
94-
95-
// enable parsing of shorthand object literal properties
96-
objectLiteralShorthandProperties: true,
97-
98-
// Allow duplicate object literal properties (except '__proto__')
99-
objectLiteralDuplicateProperties: true,
100-
101-
// enable parsing of generators/yield
102-
generators: true,
103-
104-
// enable parsing spread operator
105-
spread: true,
106-
107-
// enable parsing classes
108-
classes: true,
109-
110-
// enable parsing of modules
111-
modules: true,
112-
113-
// enable React JSX parsing
114-
jsx: true,
115-
116-
// enable return in global scope
117-
globalReturn: true
118-
}
50+
// enable es6 features.
51+
ecmaVersion: 6,
52+
sourceType: "module"
11953
});
12054
};
12155

0 commit comments

Comments
 (0)