315 Commits

Author SHA1 Message Date
Raphael Mu
f25a2fbc78 add startLine option (#346) 2017-02-10 15:06:28 +01:00
Daniel Tschinder
407c97c9c2 Fix #321 by allowing question marks in type params (#338)
* Fix #321 by allowing question marks in type params

* Require commas between params
2017-02-10 15:03:15 +01:00
Daniel Tschinder
bc771bd0f9 Fix #336 by correctly setting arrow-param (#337) 2017-02-10 15:01:39 +01:00
Daniel Tschinder
4bd682e90b keywords are not allowed as local specifier (#307)
Also fix some error messages to be more specific
2017-02-10 14:58:44 +01:00
Panagiotis Vekris
e049ec3456 [Flow] Function predicate declaration (#103)
* [Flow] Function predicate declaration

The accepted syntax for function declarations is extended to allow
the following predicate declaration:

  FunctionReturnType :=
    Type
    Predicate
    Type Predicate

  Predicate :=
    %checks
    %checks ( ConditionalExpression )

* [Flow] Minor tweaks and more examples to function predicates

* [Flow] Clean-up and better message for function predicates

* [Flow] Adding abstract function predicate example

* [Flow] Rearranging the `predicate` field to ease babel generator.
2017-02-10 14:55:13 +01:00
jeromew
898c4a7623 Add a parseExpression public method (#213) 2017-01-27 20:13:02 +01:00
Daniel Tschinder
d2faddf0d9 Fix export default async function to be FunctionDeclaration (#324) 2017-01-27 19:43:06 +01:00
Andrew Levine
9929baaca8 Don't parse class properties without initializers when classProperties is disabled and Flow is enabled (#300) 2017-01-23 23:56:39 +01:00
Daniel Tschinder
b6c3b5aa83 Cleanup and splitup parser functions (#295)
This makes it easier to integrate the estree plugin.
2017-01-20 23:52:16 +01:00
Daniel Tschinder
0a00aff2fe Do not allow overwritting of primitive types (#314)
* Do not allow overwritting of primitive types

* Better name for method
2017-01-20 22:22:25 +01:00
Brian Ng
461ed45942 Fix parse error when destructuring set with default value (#317) 2017-01-20 22:21:40 +01:00
Daniel Tschinder
55df6631fa Address comments on flow type imports (#312) 2017-01-20 22:20:13 +01:00
Daniel Tschinder
d5cd2c3231 Allow imports in declare module (#315)
* Allow imports in declare module {}

* Rename bodyElement to bodyNode
2017-01-20 22:19:50 +01:00
Daniel Tschinder
999b655ca6 Disallow import type { type a } from … (#305) 2017-01-17 20:34:20 +01:00
Dan Harper
28c467e8fe Fix ObjectTypeCallProperty static (#298)
* add failing test for ObjectTypeCallProperty static (#297)

* fix ObjectTypeCallProperty static
2017-01-16 10:42:13 +01:00
Daniel Tschinder
5977479f57 Call inner function instead of 1:1 copy to plugin (#294) 2017-01-16 10:21:44 +01:00
greenkeeper[bot]
68a173c97c Update eslint-config-babel to the latest version 🚀 (#299)
* chore(package): update eslint-config-babel to version 6.0.0

https://greenkeeper.io/

* Fix linting
2017-01-15 11:12:49 +01:00
Brian Ng
9d78213ab6 Improve error message on attempt to destructure named import (#288) 2017-01-14 15:38:30 +01:00
Daniel Tschinder
b918554d73 Correct indent eslint rule config (#276)
* Change indent rule to correctly lint

* Remove rule again
2017-01-14 15:11:50 +01:00
greenkeeper[bot]
62d1970f77 Update eslint-config-babel to the latest version 🚀 (#293)
* chore(package): update eslint-config-babel to version 5.0.0

https://greenkeeper.io/

* fix lint warnings
2017-01-14 15:04:10 +01:00
Sven SAULEAU
ed13a4ab05 Refactor tokenizer types file (#263)
* refactor(tokenizer): use class for keywork tokens

* refactor(tokenizer): re-use constacts in types

* refactor(tokenizer): binop token type

* feat(tokenizer): use beforeAndStartExpr for shortcut

* fix(tokenizer): typo in keywordTokenType

* refactor(tokenizer): don't use spread operator

* refactor(tokenizer): constant for isLoop, isAssign, prefix, postfix

* fix(tokenizer): remove constant beforeAndStartExpr

* style(tokenizer): space after comma
2017-01-10 20:22:56 +01:00
greenkeeper[bot]
6773279039 Update eslint-config-babel to the latest version 🚀 (#273)
* chore(package): update eslint-config-babel to version 4.0.0

https://greenkeeper.io/

* Fix prefer-const

* Update package.json
2017-01-10 19:42:43 +01:00
Vladimir Kurchatkin
3267e5f365 Don't set inType flag when parsing property names (#266)
* Don't set inType flag when parsing property names

* Add inPropertyName type definition

* Move inPropertyName check before this.curContext()
2017-01-05 12:25:57 +01:00
Jeff Morrison
9ea4e9dead Add support for Flow shorthand import type (#267) 2017-01-03 10:52:18 +01:00
Alex Rattray
68bb1c6598 Allow this.state.clone() when parsing decorators (#262)
Adding the line `this.state = this.state.clone();` in a parser plugin 
(specifically, in my case `parseExprAtom`)
would break decorators. 

This change fixes that.
2017-01-02 10:37:05 +01:00
Ryan Duffy
1c13800efd Use fromCodePoint to convert high value unicode entities (#243)
* Use fromCodePoint to convert high value unicode entities

* Include polyfill for String.fromCodePoint

* copy and adapt fromCodePoint into String.fromcodepoint

In order to avoid modifying String as the polyfill does, I've copied
the source from the polyfill and adapted it return the polyfill
function if the native version does not exist. Once support for node
versions that lack fromCodePoint is dropped, this polyfill can be
removed.

* move license notice to top of file
2017-01-02 10:15:56 +01:00
Vladimir Kurchatkin
3dc403974c flow: allow leading pipes in all positions (#256) 2017-01-02 10:13:53 +01:00
James Long
ba96b91f40 Fix source location for JSXEmptyExpression nodes (fixes #248) (#249) 2016-12-14 16:32:36 -05:00
Andrew Levine
30545e883f Freeze current plugins list for "*" option, and remove from README.md (#245) 2016-12-06 14:09:36 -05:00
Kai Cataldo
5fb4353778 Throw error when exporting non-declaration (#241)
* Throw error when exporting non-declaration

fixes #238

* Do check ahead of parsing export statement
2016-12-01 21:03:13 +01:00
Daniel Tschinder
6d3b63454c Allow plugins:["*"] (#229) 2016-11-17 19:04:58 -05:00
Daniel Tschinder
ad88d461d3
Correctly eat a semicolon at the end of DelcareModuleExports 2016-11-13 14:29:46 +01:00
Bernhard Häussner
01ed943deb Parse flow nested array type annotations like number[][] (#219)
* Parse flow nested array type annotations like number[][]

Fixes #217.

* Do not parse a newline separated array statement into a flow type annotation

* Get rid of lineBreak dependency in flow.js in favor of higher level method
2016-11-13 10:22:16 +01:00
Kai Cataldo
e260381e06 Throw error for reserved words enum and await (#195)
* Throw error for reserved words enum and await when source type is module

* Extract reserved word check into method

* Fix tests
2016-11-09 16:29:02 +01:00
Gabe Levi
643124744f Optional names for function types and object type indexers (#197)
* Use .gitattributes to ignore files with weird newlines

* [Flow] Make parameter names in function types optional

* [Flow] Anonymous function types with single params can omit parens

* [Flow] Optional names for object indexer keys

* Add noAnonFunctionType explicitly to state

* Adjust gitattributes as files have been fixed
2016-11-09 16:22:53 +01:00
Andrew Levine
beb8db6264 Use rollup for bundling to speed up startup time (#190) 2016-10-26 10:44:21 -04:00
Moti Zilberman
e047a1b89a Flow: Allow class properties to be named static (#184)
Related: #158
2016-10-17 15:55:50 -04:00
Daniel Tschinder
0d72a89df6 Fix flowtype and add inType to state (#189)
this improves the performance slightly
2016-10-17 10:45:46 -04:00
Andrew Levine
01e984fd0f Allow "async" as identifier for object literal property shorthand (#187) 2016-10-17 10:33:18 -04:00
Moti Zilberman
9b6e243736 Raise error on duplicate definition of __proto__ (#183)
Spec: http://www.ecma-international.org/ecma-262/6.0/#sec-__proto__-property-names-in-object-initializers

This brings back to life a bit of dead code in Parser.prototype.checkPropClash, and enables several tests that were previously disabled.
2016-10-16 15:16:38 +02:00
Moti Zilberman
7c18bf83cc Increase test coverage (#175)
* Increase test coverage

* Test for error when binding `this` in destructuring pattern

* Ignore coverage of inAsync check in parseAwait - already checked externally

* Ignore coverage of default case in checkPropClash

* Remove unused parameter isAsync from parseParenAndDistinguishExpression

* Ignore coverage of an `else` branch in flowParseTypeParameterDeclaration

* Flow: remove unused parameters to flowParseTypeAnnotatableIdentifier

* Flow: ignore coverage of pass-through throw statement in parseConditional

* Flow: Add test for error on property with type param

* Flow: ignore coverage of pass-through throw statements in parseMaybeAssign, parseArrow

* Add test for error on XML-style comment in module code

* Update test for error on method in object pattern

* Test for error: "Only '=' operator can be used for specifying default value"
2016-10-16 15:04:13 +02:00
Sam Goldman
26809e8ce7 Property variance type annotations for Flow plugin (#161)
* Property variance type annotations for Flow plugin

Non-method properties and indexers of object types, declare class, and
interfaces can be "positive" or "negative." Class fields, but again not
methods, can also have variance.

This PR generalizes the variance annotations for type parameters into a
new node type, and reuses that node for those properties.

The code for object types is reused for interfaces and declare classes.
The changes there are straightfoward.

The code for class fields is reused for object literals, which do not
support variance annotations (currently). This code is a bit sketchy,
because we always parse variance annotations in the `parsePropertyName`
extension, then error in a the subsequent parse phase for object
literals (`parseObjPropValue`) or class methods (`parseClassMethod`).

* Remove bogus unreachable code, clarify variance parsing conditional

* Don't use a new node type for variance annotations

Adding a new node type, specifically changing the TypeParameter node's
variance property to be node-valued, is a breaking change. We might
choose to make this breaking change in a later version.

* s/start/variancePos
2016-10-14 23:13:27 +02:00
Moti Zilberman
b5877f04b1 Fix up #172 (#177)
* Update two esprima tests to the new "expected TOKEN" messages

* Update dynamic-import to use "expected (" error message
2016-10-14 16:50:07 -04:00
Henry Zhu
9ecf763218 lint [skip ci] 2016-10-14 16:12:05 -04:00
Moti Zilberman
d3af158ba5 Annotate more errors with expected token (#172)
Expanding on #150, this allows `unexpected()` to accept the expected token type instead of a message string.
This overload is then used in a couple more places (that independently implement a logic similar to `expect()`'s) to construct an `Unexpected token, expected FOO` message.
2016-10-14 16:10:09 -04:00
Dan Harper
99fbcefa65 allow keyword in Flow object declaration property names with type parameters (#146) 2016-10-14 21:15:00 +02:00
Dan Harper
f7c1af1c1f allow keyword in object/class property names with Flow type parameters (#145) 2016-10-14 21:13:00 +02:00
Jordan Gensler
c63c1bc728 [dynamic-import] Implementing import() syntax (#163) 2016-10-14 14:54:21 -04:00
Daniel Tschinder
4c445fd5f8 Remove kcheck (#173) 2016-10-14 12:12:55 -04:00
Daniel Tschinder
b31834ad29 Allow typeAnnotations for yield epressions (#174) 2016-10-14 12:07:46 -04:00