This commit updates `npm run format:all` to not only format .js files in
src/ and bin/, but also tests_config/ and scripts/, as well as all
jsfmt.spec.js files.
It also includes the result of running `npm run format:all`, except
changes to src/ and bin/.
* Run AST comparison tests on Travis
It looks like some of these currently fail, so we should probably also
sort that out.
Inspired by https://github.com/prettier/prettier/issues/1552
* tests: Use specified parser when AST_COMPARE=1
This fixes some of the tests with AST_COMPARE=1
* Move cleanAST() into prettier.__debug
This makes it available for tests to use.
* AST_COMPARE=1 uses cleanAst() instead of removeEmptyStatements()
Ths fixes some of the tests with AST_COMPARE=1
* Export parse() from src/parser.js
This makes it available for tests to use.
* tests: Use specified parser more when AST_COMPARE=1
This is a continuation of commit 86437a66d326919897fe89891a25824870f5bb79
This fixes some of the tests with AST_COMPARE=1
* massageAST: remove leadingComments/trailingComments
This fixes some of the tests with AST_COMPARE=1
* massageAST: remove `extra`
This fixes some of the tests with AST_COMPARE=1
* tests_config/run_spec.js: Rename variables for clarity
* AST_COMPARE=1 tests compare unstringified objects
This makes the test error output shorter.
* fixup! Export parse() from src/parser.js
* Revert "Run AST comparison tests on Travis"
See https://github.com/prettier/prettier/pull/1553#issuecomment-300027747
This reverts commit 49873a956c532f23fd216551a35ae35c1a18407e.
* fixup! fixup! Export parse() from src/parser.js
* parser: Require babel-code-frame only when needed
This addresses:
* https://github.com/prettier/prettier/pull/1553#discussion_r115386253
* https://github.com/prettier/prettier/pull/1553#discussion_r115386250
* parser: Don't export now-unused parseWith* functions
Addresses https://github.com/prettier/prettier/pull/1553#discussion_r115386964
* Move cleanAST/massageAST into own file, don't export
This addresses:
* https://github.com/prettier/prettier/pull/1553#discussion_r115386993
* https://github.com/prettier/prettier/pull/1553#discussion_r115386611
* Don't destructure require() result (Node v4 compat.)
* Fix copy/paste error
* Add eslint as dev dep, reorder scripts.
* Add tests & docs to eslintignore.
* Add eslintcache to gitignore.
* Update yarn lock file 😽.
* Add linting step in the test pipeline.
* Add a set of really basic rules for linting.
* Fix linting 🚀.
* No need for .jsx files to be linted...
* Reorder rules alphabetically.
* Refine rules: drop styling ones, only keep what provides dead code elimination.
* Add no-console rule to be consistent along with the no-debugger one.
* Remove empty line.
* Add eslint-disable-next-line no-console where console log/warn/error are allowed.
* Drop no-console rule.
* Remove eslint-disable-next-line no-console comments.
* Remove linting step in Travis CI.
* Fix linting after merging current master.
* Run `npm test -- -u` after noticing one test was out of sync.
* Drop eslint references from previous implementation.
* Revert yarn lock file.
* Revert scripts ordering.
* Fix incorrect yarn lock file.
* Verify parsers against same snapshot
- Reworked run_spec, now accepts 3th optional array argument for
additional parsers to verify against
- Merged duplicate run_spec configs
- Removed duplicate snapshot data
* Formatted run_spec.js with prettier
* Fixed node4 incompatibility
* Revert "Remove mutation in `printBinaryishExpressions` (#1067)"
This reverts commit e7312ad7b2.
* Revert "Make it clear what parser was used in each snapshot (#1068)"
This reverts commit 4f7ae4815b.
* Add some typescript tests
* fix: Remove extraneous colon in type parameter constraint
* style: Add missing newline at EOF in TS tests
* feat: Pretty print typescript object type annotations
* feat: Pretty print TSFunctionType
* fix: Type annotations was missing on class properties
* Add a new batch of tests
* Bump typescript-eslint-parser
* Add a new batch of tests and fix a syntax error in previous
* Bump typescript-eslint-parser
The previous API was inconsistent. The new one is
```js
--parser flow
--parser babylon
{parser: 'flow'}
{parser: 'babylon'}
```
if we ever want to add new parsers in the future it'll allow that more easily.
I put a console.log in parser.js in both functions and tested that the test suite worked both with and without the change in run_spec. I also tested that both the previous and new command line options are working.
At some point in the future we'll likely want to get rid of the old api but might as well keep supporting it so we don't break anyone for now.
The Nuclide codebase uses features that are still proposals which require a flag to be enabled. Babylon parses them fine without any flags.
Let's enable them by default as it doesn't cost much, you either are using those features and you don't want the parser to break, or you are not and you don't care.
After this and #218, none of the nuclide files are throwing exceptions! (yay!)
- This brings in the flow test suite that contains a ton of JavaScript parsing edge cases
- This creates snapshot tests using the pretty printer for all of them
- If uncomment `RUN_AST_TESTS` line in `tests/run_specs.js`, it checks ast(pretty_print(x)) == ast(x). Right now, "178 failed, 197 passed, 375 of 377 total". So half of the tests are not passing, most of them are crashes and many of the rest are subtle issues.