Compare commits

..

769 Commits

Author SHA1 Message Date
41fd81a8f5 Managed to publish a new version of csx-babel. Woo! 2020-01-22 17:18:23 +01:00
bfa97fe782 Hard linking to own csx.2 package version 2020-01-22 14:25:01 +01:00
1518210ee6 more uncommitted changes... 2020-01-22 12:00:47 +01:00
b1facb18de Commit before publish 2020-01-22 12:00:26 +01:00
2c38b52ffb Commit before publish 2020-01-22 11:59:38 +01:00
44e7cf615c (Test output was missing) 2020-01-22 10:49:32 +01:00
983ab3bbc0 Trying to fix tests (it still crashes on windows separators vs unix separators...) 2020-01-22 10:48:39 +01:00
05dfb60683 Improved InitializeDefinerProperty (babel-helper) to correctly handle properties with get/setters. (This is revision 2 of a fix...) 2020-01-21 16:57:39 +01:00
Huáng Jùnliàng
a8e859bb05 fix: supply ‘.’ subpath for node.js < 13.2 (#11006)
(cherry picked from commit e7961a08a839b0bfe2c5a08f2e1c7e3d436af144)
2020-01-21 11:16:40 +01:00
f3c530b2c9 Set csx.2 version 2020-01-21 01:45:51 +01:00
a12f1771c8 Replace peerDependency on @babel/core to allow csx version 2020-01-21 01:45:48 +01:00
fad999bf52 Fixed version coercion (which would cause issues later on when babel internally checkes if this csx-version qualifies for the desired version) 2020-01-21 01:45:46 +01:00
2707780f7e Makefile additions 2020-01-21 01:45:39 +01:00
Babel Bot
b138b5a62e Add v7.8.3 to CHANGELOG.md [skip ci] 2020-01-13 21:44:41 +00:00
Nicolò Ribaudo
a7620bd266 v7.8.3 2020-01-13 22:36:19 +01:00
Huáng Jùnliàng
6874c244ab fix: generated builder parameter should respect builder keys (#11002) 2020-01-13 22:30:24 +01:00
Nicolò Ribaudo
8fce431d88
Revert "chore: specify package type (#10849)" (#11003)
This reverts commit e8dac621de9dba27b47646169562c0a0c2e02c96.

Fixes installs when using npm <= 3.9.5 (Node.js <= 6.2.2)
2020-01-13 21:18:42 +01:00
Nicolò Ribaudo
d0a8982c12 Ignore .map files in standalone packages (#10994) 2020-01-12 19:43:10 -05:00
Nicolò Ribaudo
a677d59a63
Archive syntax plugins enabled by default (#10820)
* Remove syntax plugins enabled by default

Moved to babel-archive: babel/babel-archive@8f23ddce03

- `@babel/plugin-syntax-async-generators`
- `@babel/plugin-syntax-bigint`
- `@babel/plugin-syntax-dynamic-import`
- `@babel/plugin-syntax-json-strings`
- `@babel/plugin-syntax-nullish-coalescing-operator`
- `@babel/plugin-syntax-object-rest-spread`
- `@babel/plugin-syntax-optional-catch-binding`
- `@babel/plugin-syntax-optional-chaining`

* Fix build script

* Fix jest config

* Remove archived plugins from tests
2020-01-13 00:31:48 +01:00
Babel Bot
c7f7f9b8b5 Add v7.8.2 to CHANGELOG.md [skip ci] 2020-01-12 22:50:23 +00:00
Nicolò Ribaudo
61d01f1114 v7.8.2 2020-01-12 23:44:39 +01:00
Haoqun Jiang
f995f8e02c fix: isPluginRequired returns the opposite result in v7.8.0 (#10992) 2020-01-12 23:43:03 +01:00
Babel Bot
2ccc451e96 Add v7.8.1 to CHANGELOG.md [skip ci] 2020-01-12 13:04:04 +00:00
Nicolò Ribaudo
575eeb370e v7.8.1 2020-01-12 13:58:53 +01:00
Nicolò Ribaudo
27668377b5
Downgrade semver for compatibility with Node 6 (#10991) 2020-01-12 13:56:09 +01:00
Nicolò Ribaudo
d1c93e7e3e
Remove ESLint packages from the changelog
They are not published
2020-01-12 01:54:11 +01:00
Babel Bot
9647560dd6 Add v7.8.0 to CHANGELOG.md [skip ci] 2020-01-12 00:27:36 +00:00
Nicolò Ribaudo
2486615a74 v7.8.0 2020-01-12 01:09:29 +01:00
Kai Cataldo
d8e6219ad9 @babel/eslint-plugin: Update rules/tests to use @babel/eslint-parser (#10977)
* Use @babel/eslint-parser for tests

* Update rules/tests

* Update docs

* add @babel/eslint-shared-fixtures to package.json

* remove bug fix

* convert RuleTester to ESM

* Update devDep versions
2020-01-11 20:42:21 +01:00
Huáng Jùnliàng
81c5f1f22d
Disallow private name in object elements and TS type elements (#10980)
* fix: disallow private name in object member and TS type elements

* chore: update test262 whitelist

* chore: make flow happy

* Update packages/babel-parser/src/parser/expression.js

Co-Authored-By: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>

* chore: update test fixtures

* Update packages/babel-parser/src/parser/expression.js

Co-Authored-By: Brian Ng <bng412@gmail.com>

* chore: update test fixtures

Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
Co-authored-by: Brian Ng <bng412@gmail.com>
2020-01-11 11:26:10 -05:00
Nicolò Ribaudo
e7b80a2cb9
Improve @babel/types with env.BABEL_TYPES_8_BREAKING (#10917)
Co-authored-by: Justin Ridgewell <justin@ridgewell.name>
2020-01-11 10:34:30 +01:00
Huáng Jùnliàng
405c1aaad8 Merge env-standalone to babel-standalone (#10821)
* feat: add babel-preset-env to babel-standalone

* chore: copy preset-env-standalone test

* polish: tune warning message when babel-preset-env-standalone is loaded
2020-01-11 10:31:29 +01:00
Huáng Jùnliàng
a1310333f7 chore: update corejs fixtures (#10983) 2020-01-11 09:23:58 +01:00
Huáng Jùnliàng
903ad6160d
Filename detection should respect short flags (#10763)
* chore: add test files

# Conflicts:
#	packages/babel-node/package.json

* fix: respect short flags when finding filename index

* fix: use attributeName for kebab-case
2020-01-10 20:46:19 -05:00
Anders Kaseorg
5a3e97073e CONTRIBUTING: Update link to plugin-features.js [skip ci] (#10982)
It was moved in #10899.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2020-01-10 20:43:10 -05:00
Yordis Prieto
4c28f54152 Add babelrc.json support (#10783)
* Add babelrc.json support

* Add tests

Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
2020-01-10 23:41:42 +01:00
Nicolò Ribaudo
ae06baf22f
Add support for babel.config.mjs and .babelrc.mjs (#10903)
* Add support for babel.config.mjs and .babelrc.mjs

* Use path.extname
2020-01-10 23:14:29 +01:00
Nicolò Ribaudo
282f81bd67
Prepare @babel/core for asynchronicity (#10507)
* Prepare @babel/core for asynchronicity

* Include regenerator-runtime in standalone build

* Fix rollup build
2020-01-10 22:44:13 +01:00
Huáng Jùnliàng
9fec528016 Reduce false negative cases of typescript parser tests (#10979)
* tests: read baesline errors for typescript parsing error

* chore: add error codes

* chore: tune the regex
2020-01-10 22:11:10 +01:00
James Beavers
80aa7dc3c6 Add optional-chaining and nullish-coalescing to preset-env (#10811)
* Add support for optional-chaining (stage 4) in present-env

* revert babel-preset-env built-in-modules.json

* add shipped proposal syntax map entry, optional chaining

* update remaining syntax plugin references, proposal description

* Add support for nullish coalescing operator in preset-env

* selectively enable sort-keys rule

* enforce sort-keys on shipped-proposals

* don't use Object.entries()

* Update fixtures
2020-01-10 22:07:43 +01:00
Kai Cataldo
4cb2148273 @babel/eslint-plugin: remove deprecated rules (#10975) 2020-01-10 20:22:39 +01:00
Siddhant N Trivedi
3dcb8ca99e Added instructions to fork the repo in order to setup. (#10973)
* Added instructions to fork the repo to setup

* Capitalized Github and Indented the guidelines

[skip ci]
2020-01-10 20:05:58 +01:00
Nicolò Ribaudo
bfc56ebbab Update Test262, Flow and TS parser tests (#10976)
* Update Test262, Flow and TS parser tests

* Updates
2020-01-10 09:50:11 -05:00
Huáng Jùnliàng
e8dac621de
chore: specify package type (#10849) 2020-01-09 21:40:15 -05:00
Huáng Jùnliàng
44f9d85904 add allowTopLevelThis option to transform-modules-systemjs (#10780)
* feat: expose rewriteThis method

* feat: add allowTopLevelThis option to transform-modules-systemjs
2020-01-10 03:16:26 +01:00
Nicolò Ribaudo
04354d1556
Extract targets parser and compat data from preset-env (#10899)
* Extract targets parser and compat data from preset-env

* Review by Jùnliàng

* isItemRequired -> targetsSupported

* Export isRequired
2020-01-10 03:15:20 +01:00
jack
5f807ae45b Enable optional chaining by default in @babel/parser (#10817) 2020-01-10 03:09:39 +01:00
ZYSzys
646409b23e Use babel > as prompt in babel-node (#9695) 2020-01-10 03:04:02 +01:00
Raja Sekar
8415065d99 --copy-ignored flag added to CLI (#10887)
* prevent ignored files in out dir

* added includeIgnore cli option

* Help text change

* Update packages/babel-cli/src/babel/options.js

Copy review.

Co-Authored-By: Brian Ng <bng412@gmail.com>

* review comments

* throw error if copyIgnored is used without ignore flag

* check for ignored files

* duplicate pathToPattern fn in babel/cli

* change implementation

* removed ignore option from cliOption

* added test case with ignore in config

* added test case with ignore in config

* review

Co-authored-by: Brian Ng <bng412@gmail.com>
2020-01-10 03:03:37 +01:00
Sebastian Silbermann
3af02f63de Add --out-file-extension option to babel-cli (#9144)
* Add --use-file-extension option to babel-cli

* refactor file extension logic

use existing methods from path module

* Rename use-file-extension -> out-file-extension

* add error message if bot keep- and out-file-extension is used

* add test for error when mixing --keep- and --out-file-extension

* poke travis
2020-01-10 03:02:52 +01:00
Oleksandr Fediashov
c3388ea42f Enable nullish coalescing by default in @babel/parser (#10819)
* move files, remove hasPlugin() & expectPlugin()

* restore permissions
2020-01-10 02:52:53 +01:00
Abdul Ali
5b907e9bb7 [parser] enable dynamic import by default (#10843)
* [parser] enable dynamic import by default

* chore: add back babel-core api test
2020-01-10 02:28:52 +01:00
Huáng Jùnliàng
7bc22e42f5 StringNumericLiteral does not include NumericLiteralSeparator (#10938) 2020-01-10 02:28:16 +01:00
Nicolò Ribaudo
771c730fda
[parser] Disallow duplicate and undeclared private names (#10456)
* [parser] Add private names tracking to Scope

- Disallow duplicate private names
- Disallow undeclared private names

* Update tests

* Test all possible duplications

* Test undeclared private names

* Better error message for top-level private names

* Fix flow

* Update test262 whitelist

* Update fixtures

* Update flow whitelist

* Remove old output.json

* Move ClassScopeHandler to a separate class

* Make the code readable
2020-01-10 02:22:05 +01:00
Huáng Jùnliàng
9f148a1603 chore: update caniuse-usage fixtures (#10974) 2020-01-10 00:38:21 +01:00
Huáng Jùnliàng
09cb4273bc update corejs-compat fixtures (#10967)
* update corejs-compat fixtures

* chore: bump core-js-compat to 3.6.2
2020-01-07 18:43:14 +01:00
Huáng Jùnliàng
8fd532db39
LiteralPropertyName should allow BigIntLiteral (#10955)
* fix: property name should allow BigIntLiteral

* test: add non decimal test case

* add bigintIndex to whitelist
2020-01-07 10:23:50 -05:00
Nicolò Ribaudo
3fa37d2da3 Bump coverage target from 80% to 90% (#10964) 2020-01-05 18:08:50 -05:00
Nicolò Ribaudo
4636321f06
Make @babel/transform-runtime's absoluteRuntime/relative test meaningful (#10963) 2020-01-05 17:28:44 +01:00
Huáng Jùnliàng
a7dac49518 chore: workaround yarn issue (#10958) 2020-01-04 11:35:24 +01:00
Huáng Jùnliàng
03d163a0d9
Use chrome data when android is absent (#10790)
* chore: rename test folder

* chore: add test case

* fix: use chrome support data when android is absent

* chore: add type annotation

* chore: add testcases last 2 versions not ie

* chore: bump browerslist to v4.8.2

* chore: update test fixtures

* chore: update test fixtures
2020-01-03 18:26:27 -05:00
Huáng Jùnliàng
455d782ef0 test: add invalid-lone-import test (#10950)
* test: add lone import test

* polish: raise recoverable error
2020-01-03 23:08:59 +01:00
Huáng Jùnliàng
a28353703f fix: check await when parsing AsyncArrowBindingIdentifier (#10953) 2020-01-03 23:08:28 +01:00
Huáng Jùnliàng
467667af88 When reading a new string, U+2028/2029 should correctly set th… (#10944)
* test: add test on template

* fix: update lineStart when string contains U+2028/U+2029
2020-01-03 23:07:54 +01:00
Huáng Jùnliàng
6ee8c97e6a Fix: TopLevelAwait should respect await identifiers defined in… (#10947) 2020-01-03 23:07:11 +01:00
Huáng Jùnliàng
e5048053aa Add integration test: e2e-vue-cli (#10919)
* chore: add e2e-vue-cli test

* chore: add node-browsers-executor

* chore: state why node-browsers-executor is required
2020-01-03 23:06:13 +01:00
Kai Cataldo
9f832c2716
@babel/eslint-parser: Fix ClassPrivateMethods (#10913) 2020-01-02 18:36:58 -05:00
Jayen Ashar
daaa2063bb Override toString in case this function is printed (#10949)
* Override toString in case this function is printed

Related to https://stackoverflow.com/questions/59543968/unexpected-return-value-from-visitor-method

* Don't override `toString` if `wrapper` is true

Override `toString` immediately before returning a newFn, otherwise it will be overridden if wrapper is true

https://github.com/babel/babel/pull/10949#discussion_r362302625

* prettier
2020-01-01 15:36:20 +01:00
Huáng Jùnliàng
26eb891870
fix: Class Field Initializer should not allow await expression as immediate child (#10946)
* fix: scope.inAsync should exclude reference in class property initializers

* chore: add test on await in computed class property

* fix flow error :(
2019-12-31 09:36:03 -05:00
Huáng Jùnliàng
0238244268
refactor: remove unecessary checkYieldAwaitInDefaultParams (#10936) 2019-12-30 16:12:09 -05:00
Huáng Jùnliàng
2f3f77926d
refactor: remove unused invalidTemplateEscapePosition tokenizer state (#10935)
* refactor: remove unused invalidTemplateEscapePosition tokenizer state

* fix flow error
2019-12-30 16:11:56 -05:00
Huáng Jùnliàng
30449fe05d
Refactor parseSubscript (#10937)
* refactor: unify optionalMemberExpression generation

* test: add optional calls invalid typecasts

* fix: do not parse async arrow when call is optional

* test: update test fixtures
2019-12-30 16:11:39 -05:00
Huáng Jùnliàng
86245a83a2
TSTypeCastExpression should not be inside call parameters (#10939) 2019-12-30 16:10:19 -05:00
Huáng Jùnliàng
197a8da04d
Remove unused parser methods (#10942)
* chore: remove unused isStrictBody

* chore: remove unused eatRelational
2019-12-30 16:09:50 -05:00
Huáng Jùnliàng
314513374d
chore: update test262 (#10943)
* chore: update test262

* chore: ignore untoggleable features
2019-12-29 21:35:19 -05:00
Klaus Meinhardt
b91720c1cc helper-module-transforms: dereference imported template tag (#10934)
* Dereference imported template tag

* apply fix for OptionalCallExpression as well
2019-12-28 16:46:20 -05:00
Huáng Jùnliàng
e9dc74e787
fix: Promise.any requires global.AggregateError (#10930)
* fix: promise.any requires global.AggregateError

* address review comments
2019-12-26 20:29:47 -05:00
Nicolò Ribaudo
30f3b07ebf Replace custom "findSuggestion" function with "levenary" (#10924)
* Replace custom "findSuggestion" function with "levenary"

* Update
2019-12-26 00:45:26 +01:00
Huáng Jùnliàng
db3c31a8af fix: minified should not accept optional argument (#10923) 2019-12-25 19:13:23 +01:00
Nicolò Ribaudo
00758308ae Always use forked @lerna/collect-updates 2019-12-25 01:22:43 +01:00
Huáng Jùnliàng
fc5365fe4a
Fix parameter expression get binding (#10912)
* fix: parameter expression closure should not have access to the declaration inside function body

* fix: renameVisitor should skip when a pattern is a scope

* address review comments
2019-12-24 15:18:46 -05:00
Kai Cataldo
ee5b79d75d @babel-core: parse should parse only (#10914)
* @babel/core: parse methods should parse only

* Update Flow types
2019-12-24 18:28:57 +01:00
Huáng Jùnliàng
875e9619b7
chore: refine e2e test scripts (#10918) 2019-12-24 12:25:23 -05:00
Huáng Jùnliàng
a18166d2a9 refactor: remove inClassProperty parser state (#10906) 2019-12-24 11:43:39 +01:00
Kai Cataldo
c09664f35d @babel/eslint-parser: Refactor (#10916) 2019-12-23 23:12:07 +01:00
Huáng Jùnliàng
83993b08d5 chore: separate build-standalone with coverage (#10905)
* chore: separate build-standalone with coverage

* style polish
2019-12-23 19:03:45 +01:00
Barthélémy Ledoux
f651f22f96 fix: lost leading comment after named import (#10901)
* create test for 10892

* update expected output

* fixed #10892

* add colon to restart build

* remove colon as it makes tests fail
2019-12-22 10:22:28 +01:00
Tsubasa Nakayama
416ce35638 fix: Object.getOwnPropertySymbols called on non-object (#10902)
* fix: Object.getOwnPropertySymbols called on non-object

* convert Object
2019-12-22 00:16:51 +01:00
Huáng Jùnliàng
c5cfc83182 Move coverage to GitHub actions (#10898)
* chore: remove Circle CI test config

* chore: add GitHub Actions: Report Coverage

* chore: polish the step names

* chore: remove Circle CI test job definition

* chore: remove cache actions as it seems that they are hanging forever
2019-12-20 21:32:22 +01:00
Nicolò Ribaudo
d389b702e6 Remove reverted PR from changelog [skip ci] 2019-12-19 02:02:16 +01:00
Babel Bot
aaa1b1f4b0 Add v7.7.7 to CHANGELOG.md [skip ci] 2019-12-19 00:53:52 +00:00
Nicolò Ribaudo
12da0941c8 v7.7.7 2019-12-19 01:33:19 +01:00
Huáng Jùnliàng
9be27bcfea fix: add computed property support for object Ref (#10863)
* fix: add computed property support for object Ref

* Apply suggestions from code review

Co-Authored-By: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>

* Update output.js
2019-12-19 01:29:46 +01:00
Nicolò Ribaudo
c0d0bf2e5e Update core-js fixtures 2019-12-19 01:28:41 +01:00
Huáng Jùnliàng
e85c9b9ec8 fix: skip merging large input sourcemaps (#10890) 2019-12-19 01:16:20 +01:00
Nicolò Ribaudo
80e95d0c83 Fix flow 2019-12-18 14:34:06 +01:00
Raja Sekar
dbf3f91f1e Revert "Prevent ignored files in out dir (#10831)" (#10886)
This reverts commit 2b3590929b4eb955b0e8b287f9749b5af66cc1a0.
2019-12-18 11:17:35 +01:00
Huáng Jùnliàng
aa814073b7 Ignore some files in npm package (#10882) 2019-12-17 23:53:53 -06:00
Huáng Jùnliàng
8afeef2d96 chore: cache chocolatey install temp (#10874) 2019-12-17 23:32:05 -06:00
Nicolò Ribaudo
3d7bc435d5 Allow -r from node_modules with @babel/node (#10871) 2019-12-17 23:31:26 -06:00
Raja Sekar
2b3590929b Prevent ignored files in out dir (#10831)
Co-Authored-By: Brian Ng <bng412@gmail.com>
2019-12-17 21:39:36 -06:00
Huáng Jùnliàng
b3c7df9314 fix: avoid string copy when processing input source-map (#10885)
Co-Authored-By: Justin Ridgewell <justin@ridgewell.name>
2019-12-17 21:12:55 -06:00
Huáng Jùnliàng
ff8a295ea7 chore: download compat-table when build-data is run (#10873) 2019-12-17 21:12:10 -06:00
Huáng Jùnliàng
c35ba3d3ab
chore: add PR Intent checkbox [ci-skip] (#10880)
* chore: add PR Intent checkbox

* chore: rephrase [ci-skip]
2019-12-17 14:36:09 -05:00
Nicolò Ribaudo
4f77a5aaad
e2e test: create-react-app (#10704)
* e2e test: create-react-app

* Fix

* Fix

* Fix

* Fix
2019-12-16 22:13:23 +01:00
Huáng Jùnliàng
0e9c49606a chore: update babel-eslint to 11.0.0-beta.2 (#10870) 2019-12-16 22:10:29 +01:00
Aziz Khambati
a0d76a8c0e Fix pragmaFrag spelling in error message (#10868) 2019-12-16 09:55:08 -05:00
Huáng Jùnliàng
bffa415b83 Check shadow variable to identifier in default parameters (#10053)
When there is a variable declaration inside the function body, which shares its name to a referenced identifier in default parameter expression, the function body should be wrapped into iife, otherwise the binding in default parameter scope will be shadowed by function body.
2019-12-13 14:39:37 +01:00
Nicolò Ribaudo
0b3f883ed1 Properly serialize non-json values in parser tests (#10858) 2019-12-12 10:22:17 +01:00
Kai Cataldo
25f7e6808e
@babel/eslint-parser: refactor configuration logic (#10860) 2019-12-11 18:06:37 -05:00
Kai Cataldo
7b54a94389 @babel/eslint-parser: fix ImportExpression node to match ESTree spec (#10828)
* @babel/eslint-parser: fix ImportExpression node to match ESTree spec

* Update caller name for @babel/core.parseSync

* Move logic into estree plugin

* Add estree plugin tests

* Fix Flow error

* Fix flow

* Remove extra properties on ImportExpression node

* Incorporate review feedback
2019-12-11 11:13:57 +01:00
Nicolò Ribaudo
5156d3ea06
Restore @babel/parser tests (#10854)
* Make parser tests work again

* Update failing fixtures

* Fix serialization of BigInt

* Fix
2019-12-11 11:09:13 +01:00
Bowei Han
20e43ad103 validate parentheses in the left-hand side of assignment expressions (#10576)
* invalid left-hand assignments based on parenthesis

* validate against nested ParenthesizedExpressions
2019-12-09 20:29:02 -05:00
Huáng Jùnliàng
de1fa902f0 Tune eslint packages test configuration (#10848)
* Do not load root babel.config.js in esilnt tests

* add testcase: sourceType: script + globalReturn: true

* chore: remove globalReturn on default test config
2019-12-10 01:14:29 +01:00
Huáng Jùnliàng
f02e5e6d0a Add missing dev dependencies (#10847)
* chore: declare eslint-import-resolver-node dependency

# Conflicts:
#	yarn.lock

* chore: add devDependencies

* Add browserify devDep to babel-register

# Conflicts:
#	packages/babel-register/package.json
#	yarn.lock

* chore: resolve eslint-scope to 5.0.0
2019-12-09 23:56:22 +01:00
Nicolò Ribaudo
2884bac44b Use async-to-generator even when regenerator is enabled (#10839)
While it isn't technically needed because regenerator already handles
async functions, it doesn't play well with the Promise detection logic
used by @babel/preset-env's useBuiltIns and @babel/transform-runtime.

The plugin exclusion logic isn't removed, because
1) it will be useful when merging @babel/preset-modules
    into @babel/preset-env
2) if/when regenerator will support injecting a custom promise,
    we can enable this optimization again
2019-12-09 16:54:25 -05:00
Huáng Jùnliàng
b7989419c7 Update corejs fixtures (#10846)
* chore: add update-env-corejs-fixture recipe

* chore: update corejs fixtures
2019-12-09 19:50:34 +01:00
Huáng Jùnliàng
0164662944 refactor: rewrite available-plugins to esm (#10837) 2019-12-08 14:53:28 +01:00
Kai Cataldo
fb100eee41 @babel/eslint-parser: fix BigIntLiteral node to match ESTree spec (#10827)
* @babel/eslint-parser: fix BigIntLiteral node to match ESTree spec

* Move token conversion to @babel/eslint-parser

* Add estree plugin tests

* Update test helpers to handle BigInt serializing

* Update Literal union type to include BigIntLiteral

* Add FlowIgnore comment for BigInt
2019-12-08 02:59:18 +01:00
Babel Bot
b2429fe203 Add v7.7.6 to CHANGELOG.md [skip ci] 2019-12-07 23:29:56 +00:00
Nicolò Ribaudo
f753c48f74 v7.7.6 2019-12-08 00:25:57 +01:00
Huáng Jùnliàng
4436ffd604 Revert "Add ".js" extension to injected polyfill imports (#10549)" (#10835)
This reverts commit d3a37b5d08074c007268eb15a11ae432165bad5d.
2019-12-07 23:05:35 +01:00
Huáng Jùnliàng
655a972737 chore: add PR Revert labels to changelog (#10836) 2019-12-07 21:21:52 +01:00
Babel Bot
8a8474c321 Add v7.7.5 to CHANGELOG.md [skip ci] 2019-12-06 13:15:23 +00:00
Nicolò Ribaudo
d04508e510 v7.7.5 2019-12-06 14:12:41 +01:00
shimataro
d3a37b5d08 Add ".js" extension to injected polyfill imports (#10549)
* Node modules compatibility: add ".js" extension to imported polyfills

* Update fixtures

* add extensions on calling `addDefaultImport()`, not in the function.
2019-12-06 13:30:23 +01:00
Huáng Jùnliàng
c9a68984d6 babel --watch should have equivalent file selection logic with babel (#10283)
* fix(watcher): skip non-compilable file only when it is not included in filenames argument

* perf: disable globbing for watch
2019-12-05 08:28:52 +01:00
Huáng Jùnliàng
c6e966cac9 [parser] Use scope flags to check arguments (#10801)
* chore: add test case

Co-authored-by: Jens Maier<jens@elberet.de>

* use scope flags to check arguments
2019-12-05 08:23:53 +01:00
Huáng Jùnliàng
a0bed42aec
Bundle standalone using rollup (#10779)
* chore: bundle babel-standalone via rollup

Co-authored-by: Daniel Tschinder <daniel.tschinder@researchgate.net>

* chore: build babel-preset-env-standalone via Rollup

# Conflicts:
#	yarn.lock

* chore: add babelEnvName

* chore: farewell webpack

* chore: add terser minification

* chore: dedupe some popular dependencies

* chore: remove unused devDependencies

* chore: move plugin-babel-source to scripts/

* make prettier happy

* fix: rewrite available-plugins into esm

* chore: add extra unambiguous sources when env is rollup/standalone
2019-12-04 23:09:52 -05:00
Huáng Jùnliàng
2b472912e4
Tune makefile scripts (#10781)
* chore: replace node by `yarn node`

* chore: fix tsc command

* chore: use `yarn` to wrap node

* chore: supress yarn run output

* chore: disable silent mode for builtin yarn command
2019-12-04 22:28:25 -05:00
Huáng Jùnliàng
e94da0dce5 Incorrect trace position in fixture runner (#10566)
* test: add test case

* fix: incorrect fixture callsite position
2019-12-05 00:35:37 +01:00
Alex Lewis
bb6cc61979 fix(optional chaining): Optional delete returns true with nullish base (#10806)
Per issue 10805, the return value when using delete on a nullish base is
currently undefined. The correct return type should be true.
2019-12-04 12:56:25 +01:00
Nicolò Ribaudo
3d0c5d2afc
Do not transpile typeof helper with itself in babel/runtime (#10788)
* Do not transpile typeof helper with itself in babel/runtime

* Nits

* Remove console.log
2019-12-04 01:09:14 +01:00
YeonJuan
d18afbd7c3 Allow tuple rest trailing comma (#10800) 2019-12-03 18:32:36 +01:00
Nicolò Ribaudo
e74efd2c0a Run parser tests from the official TypeScript parser (#10444) 2019-12-03 01:09:54 +01:00
Nicolò Ribaudo
7195f0d8cf Unify logic for running parser tests from external suites (#10444) 2019-12-03 01:09:54 +01:00
Nicolò Ribaudo
5440ae1cae
Correctly disambiguate / after async fuctions (#10475)
* Correctly disambiguate / after async fuctions
2019-12-02 22:41:39 +01:00
Nicolò Ribaudo
8f89167486
Update core-js-compat (#10795)
* Update core-js-compat

* Update lockfile
2019-12-02 22:30:21 +01:00
Jaroslav Kubíček
26c0a32c7c refactor: Improve error message in @babel/core when root config is not found (#10778) 2019-12-01 00:07:05 +01:00
Jaroslav Kubicek
a6e8b3843b chore: update snapshot for corejs3 targets unit test 2019-11-29 14:49:08 -05:00
Huáng Jùnliàng
4e774b7264 fix: rewriteBindingInitVisitor should skip on scopable node (#10764) 2019-11-26 08:51:11 +01:00
Kai Cataldo
7f732ad019 Clean up @babel/eslint-plugin (#10756)
* Clean up @babel/eslint-plugin

* Add directory field to package.json

* Update eslint/babel-eslint-plugin/README.md

Co-Authored-By: Huáng Jùnliàng <jlhwung@gmail.com>

* Incorporate feedback :)
2019-11-25 17:15:34 -05:00
Kai Cataldo
e81bbd69b3 Clean up @babel/eslint-parser (#10753)
* Ensure compilation works for @babel/eslint-parser

* Update with review suggestions

* Incorporate feedback :)
2019-11-25 22:17:45 +01:00
Kai Cataldo
52f964126d Update babel-eslint-plugin-dev engines (#10761) [ci-skip] 2019-11-25 16:14:00 -05:00
Nicolò Ribaudo
01c33a5719
Fix dependencies on @babel/* packages (#10762)
* Remove dep on Babel 7 beta

* Add missing dependencies used in babel.config.js

* Update lockfile
2019-11-25 21:48:12 +01:00
Ives van Hoorne
66a70267b6 Add CodeSandbox CI Config (#10639)
* Add CodeSandbox CI Config

* Force build

* New build
2019-11-25 13:02:02 -05:00
Kai Cataldo
0b06b23b00 Clean up @babel/eslint-plugin-development (#10757)
* Clean up @babel/eslint-plugin-development

* Add directory field to package.json
2019-11-25 18:44:46 +01:00
Nicolò Ribaudo
e239eb4c55 Update babel-eslint used in top-level package.json (#10754) 2019-11-23 21:59:26 -05:00
Nicolò Ribaudo
d38c4dd57b babel-eslint-v11.0.0-beta.1 2019-11-23 12:17:11 +01:00
Nicolò Ribaudo
5dbb90ede3 Add v7.7.4 to CHANGELOG.md [skip ci] 2019-11-23 00:38:07 +01:00
Nicolò Ribaudo
75767d87cb v7.7.4 2019-11-23 00:05:58 +01:00
Nicolò Ribaudo
1b4cfc21d9
Add support for native esm to @babel/runtime (#10748)
* Add support for native esm to @babel/runtime

* Test

* Do not remove new package.json files

* Remove git diff
2019-11-22 23:59:30 +01:00
Kai Cataldo
2dfc06e83b
Merge pull request #10744 from kaicataldo/@babel/eslint-config-internal
Rename babel-eslint-config-internal -> @babel/eslint-config-internal
2019-11-22 17:11:53 -05:00
Kai Cataldo
2c40b8c706 Fix failing tests 2019-11-22 16:25:38 -05:00
Kai Cataldo
ca88cf1060 Incorporate feedback 2019-11-22 16:05:44 -05:00
Kai Cataldo
74e2c2cd78 Update eslint/babel-eslint-config-internal/package.json
Co-Authored-By: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
2019-11-22 16:05:43 -05:00
Kai Cataldo
25169901de Rename babel-eslint-config-internal -> @babel/eslint-config-internal 2019-11-22 16:05:43 -05:00
Jaideep Bhoosreddy
74fb914fe3 Use the local version of babel in test262 job (#10749)
* Use the local version of babel

* retrigger

* correctly remove other changes

* d'oh last one

* remove link part
2019-11-22 11:21:19 -05:00
Huáng Jùnliàng
683adcbb70 Reduce standalone build size (#10668)
* infra: build standalone against src

* infra: add absoluteRuntime

# Conflicts:
#	babel.config.js

* chore: remove `process.env` replace

* add $ to signify exact match

credits to Nicolò
2019-11-21 14:31:38 +01:00
Nicolò Ribaudo
cc51f2a1f2
Update lerna (#10733)
* Update lerna

* yarn-deduplicate

* Update lockfile
2019-11-21 01:05:47 +01:00
Brian Ng
83fc3f2623 Update preset-env mappings (#10742) 2019-11-20 18:48:38 -05:00
Huáng Jùnliàng
fee4d936a3 chore: introduce envinfo into environment section [ci-skip] (#10565)
This reverts commit d234ff6572e7593f36620780319b4e183aec7561.
2019-11-20 21:49:34 +01:00
George Zahariev
01d6d6dd3b Flow enums: fix enum body location (#10737) 2019-11-19 22:46:08 -06:00
Huáng Jùnliàng
6ba113197f
fix: add missing available plugins to babel-preset-env-standalone (#10732)
* fix: add missing available plugins to babel-preset-env-standalone

* skip available-plugins test in CI coverage test
2019-11-18 14:29:18 -05:00
Brian Ng
a502d88043 Fix some incorrect typeof parsing in flow (#10657) 2019-11-18 19:22:27 +01:00
gr
10213655bc [parser] Allow optional async methods (#10582)
* Add parsePostMemberNameModifiers to aync method

* Add test
2019-11-18 19:18:36 +01:00
Huáng Jùnliàng
cfd26fdbf2
register ImportEqualsSpecifier to scope (#10710)
Co-authored-by: <jaejoon.choi>
2019-11-18 13:04:34 -05:00
Raja Sekar
faf149226b minor config change (#10731) 2019-11-18 09:27:53 +01:00
Kai Cataldo
dba5bd3012
Merge pull request #10730 from kaicataldo/node-6-tests
Do not run eslint/* tests in Node v6
2019-11-18 00:26:23 -05:00
Kai Cataldo
d18d0b6478 Run Prettier 2019-11-17 23:31:38 -05:00
Kai Cataldo
db2b601886 Add TODO comment 2019-11-17 23:28:51 -05:00
Kai Cataldo
e9e6918df6 Do not run eslint/* tests in Node v6 2019-11-17 23:28:51 -05:00
Kai Cataldo
53a3dac011 Clean up eslint/* directories (#10729) 2019-11-17 11:01:10 +01:00
Kai Cataldo
401c9bbe83 Update ESLint/Prettier config for eslint/* packages (#10724) 2019-11-16 23:28:02 +01:00
Brian Ng
c37361ba2e Bump prettier@1.19.1 (#10728) 2019-11-16 16:05:40 +01:00
Raja Sekar
f087cf842f Mocha to jest migration for eslint packages (#10716)
* migrated mocha to jest

* migrated mocha to jest - 2

* migrated mocha to jest - removed preversion hook from script

* migrated mocha to jest - 3

* migrated mocha to jest - 4

* cleanup

* review

* review
2019-11-16 12:32:19 +01:00
Kai Cataldo
bcd181f051 ESLint: disable max-len (#10727)
* ESLint: disable max-len

* Rename .eslintrc.json -> .eslintrc.js

* Fix up .eslintrc.js
2019-11-16 11:10:33 +01:00
Nicolò Ribaudo
5ca8acdb38
Do not automatically publish eslint packages (#10722)
* Do not automatically publish eslint packages

* Fix

* Fix

* Fix

* Fix

* Fix
2019-11-16 11:09:18 +01:00
Kai Cataldo
a6d134804a Unify build step for ESLint packages (#10723) 2019-11-16 10:15:15 +01:00
Arun Kumar Mohan
1b75fe3cba chore: fix typo: prest -> preset (#10726) [ci-skip] 2019-11-15 23:56:59 -05:00
Huáng Jùnliàng
3846d2a7fa chore: fix typo (#10725) 2019-11-15 20:56:32 -06:00
Huáng Jùnliàng
6c7f8291d4 polish: skip creating extra reference for safely re-used node (#10720)
* polish: skip creating extra reference for safely re-used node

* reimplement using scope.maybeGenerateMemoised
2019-11-16 01:11:03 +01:00
Nicolò Ribaudo
d56911b88d
Reorganize meta files for ESLint packages (#10714)
* Move COC and CONTRIBUTING

* Add changelog links

* Reorganize gitignore and licenses
2019-11-16 01:10:26 +01:00
Nicolò Ribaudo
72eca8f0c2
Fix publishing broken by eslint packages (#10721) 2019-11-15 20:54:04 +01:00
Huáng Jùnliàng
5bb4ee73da chore: use loose mode of transform (#10718) 2019-11-15 10:48:37 -06:00
Nicolò Ribaudo
b4c42601d1
Fix linting in ESLint packages (#10712)
* Lint eslint/*

* Run "make fix-js"

* Fix remaining problems

* Remove linting from subpackages

* Remove husky

* Add back eslint dep
2019-11-14 22:05:26 +01:00
Huáng Jùnliàng
17dfdab7d2 chore: ignore engines for eslint packages (#10713) 2019-11-14 22:00:46 +01:00
Raja Sekar
927b89bec8 removed yarn lock from eslint packages (#10711) 2019-11-14 21:46:40 +01:00
dependabot[bot]
ec18c30ce7 Bump js-yaml from 3.12.0 to 3.13.1 (babel/eslint-plugin-babel-plugin#2)
Bumps [js-yaml](https://github.com/nodeca/js-yaml) from 3.12.0 to 3.13.1.
- [Release notes](https://github.com/nodeca/js-yaml/releases)
- [Changelog](https://github.com/nodeca/js-yaml/blob/master/CHANGELOG.md)
- [Commits](https://github.com/nodeca/js-yaml/compare/3.12.0...3.13.1)

Signed-off-by: dependabot[bot] <support@github.com>
2019-07-08 21:05:37 +02:00
Nicolò Ribaudo
f7c3d0717a 1.0.1 2018-12-18 22:35:38 +01:00
Nicolò Ribaudo
f5e482d3f6 Add repo url 2018-12-18 22:35:25 +01:00
Nicolò Ribaudo
31c3de6bfa Typo 🤦 2018-12-18 22:33:27 +01:00
Nicolò Ribaudo
cc78743ac8 Add .npmignore 2018-12-18 22:09:51 +01:00
Nicolò Ribaudo
1bd82dd6c1 1.0.0 2018-12-18 21:24:54 +01:00
Nicolò Ribaudo
cc2d738343 Update readme with the new package name 2018-12-18 21:23:50 +01:00
Nicolò Ribaudo
76ece4576e Add publishConfig to package.json 2018-12-18 21:04:36 +01:00
Nicolò Ribaudo
ef29bf53ff Rename to @babel/eslint-plugin-developement. Fixes babel/eslint-plugin-babel-plugin#1 2018-12-18 19:59:26 +01:00
Nicolò Ribaudo
e146ae748e Create Test workflow 2018-12-17 21:15:50 +01:00
Nicolò Ribaudo
ed1cee365f Update package.json#main 2018-12-17 20:13:53 +01:00
Nicolò Ribaudo
b615efba87 Export rules 2018-11-20 21:20:58 +01:00
Nicolò Ribaudo
69cc2c30c5 Docs 2018-11-20 21:11:47 +01:00
Nicolò Ribaudo
110191d81e Add plugin-name rule 2018-11-20 20:30:08 +01:00
Nicolò Ribaudo
c59db52954 Extract isBabelPluginFactory helper 2018-11-20 20:30:02 +01:00
Nicolò Ribaudo
2be54111c0 Add no-undefined-identifier rule 2018-11-20 18:13:37 +01:00
Nicolò Ribaudo
1f7197ec16 Extract isFromBabelTypes helper 2018-11-20 18:02:40 +01:00
Nicolò Ribaudo
6285cb9b64 Add no-deprecated-clone rule 2018-11-19 00:53:17 +01:00
Nicolò Ribaudo
3243af3e07 First commit 2018-11-18 23:57:36 +01:00
fergald
f3e2752df3 Support private properties in no-invalid-this (babel/eslint-plugin-babel#183)
* add failing test

* support ClassPrivateProperty
2019-08-24 17:12:15 +09:00
dependabot[bot]
693fa1aa0d Bump js-yaml from 3.11.0 to 3.13.1 (babel/eslint-plugin-babel#177)
Bumps [js-yaml](https://github.com/nodeca/js-yaml) from 3.11.0 to 3.13.1.
- [Release notes](https://github.com/nodeca/js-yaml/releases)
- [Changelog](https://github.com/nodeca/js-yaml/blob/master/CHANGELOG.md)
- [Commits](https://github.com/nodeca/js-yaml/compare/3.11.0...3.13.1)

Signed-off-by: dependabot[bot] <support@github.com>
2019-07-15 18:52:01 +02:00
dependabot[bot]
7061d966ab Bump lodash from 4.17.4 to 4.17.14 (babel/eslint-plugin-babel#181)
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.4 to 4.17.14.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.4...4.17.14)

Signed-off-by: dependabot[bot] <support@github.com>
2019-07-12 20:20:59 -05:00
Brian Ng
ebe197f12e 5.3.0 2018-11-15 09:13:03 -06:00
Ville Saukkonen
eccbdab734 Camelcase - support for optional chaining (babel/eslint-plugin-babel#163) 2018-11-08 17:47:03 +02:00
Brian Ng
2358ed1bf9 5.2.1 2018-09-27 09:09:40 -05:00
Brian Ng
e8c0f529a0 Fix missing valid-typeof export (babel/eslint-plugin-babel#165) 2018-09-27 08:20:52 -05:00
Brian Ng
7c97b5587a 5.2.0 2018-09-06 10:45:30 -05:00
Brian Ng
d86c6dd449 Add valid-typeof rule with support for BigInt (babel/eslint-plugin-babel#161) 2018-09-06 10:39:48 -05:00
Brian Ng
f70f68e44a Update readme for opt call support in no-unused-expressions [skip ci] (babel/eslint-plugin-babel#160) 2018-09-05 09:41:55 -05:00
Brian Ng
d03a00c1a4 mocha@5.2.0 (babel/eslint-plugin-babel#159) 2018-09-05 09:26:43 -05:00
Brian Ng
b3ce66b1ff Merge pull request babel/eslint-plugin-babel#158 from lehni/fix/optional-call-expression-in-no-unused-expressions 2018-09-05 09:20:31 -05:00
Brian Ng
2ea80c845e Merge pull request babel/eslint-plugin-babel#157 from amilajack/patch-1
Test against modern node versions
2018-09-04 10:34:28 -05:00
Brian Ng
3e7fe7b25e 5.1.0 2018-04-20 08:49:02 -05:00
Brian Ng
562deb8f09 Merge pull request babel/eslint-plugin-babel#144 from babel/issue142
Fix bug with semi rule with class properties and omitLastInOneLineBlock option
2018-04-19 23:30:41 -05:00
Brian Ng
ae68b5bf24 Refresh new-cap tests 2018-04-18 20:33:36 -05:00
Brian Ng
5b5d9a5dec eslint-rule-composer@0.3.0 2018-04-18 20:29:53 -05:00
Brian Ng
bc15f0627d Merge pull request babel/eslint-plugin-babel#131 from lyleunderwood/do-expressions
add no-unused-expressions with do expressions support
2018-04-18 20:25:42 -05:00
Henry Zhu
1037e37418 5.0.0 2018-03-31 08:42:29 -04:00
Brian Ng
8e49bbbb09 Add quotes rule to index 2018-03-30 09:28:48 -05:00
Brian Ng
550dcfc96a Merge pull request babel/eslint-plugin-babel#139 from babel/quotes-jsxfragment
Add babel/quotes rule for JSXFragment workaround
2018-03-30 09:11:10 -05:00
Brian Ng
2624190887 Update deprecation table with versions 2018-03-30 09:09:23 -05:00
Brian Ng
b41b3af879 Merge pull request babel/eslint-plugin-babel#138 from babel/composer
Refactor rules to use eslint-rule-composer
2018-03-30 08:34:43 -05:00
Henry Zhu
15c5245d55 4.1.2 2017-07-25 16:42:26 -04:00
Brandon Kobel
da75b8484f Modifying semi rule to support for await (babel/eslint-plugin-babel#126) 2017-05-10 12:09:23 -04:00
Henry Zhu
dc0109ad3d 4.1.1 2017-03-06 10:48:48 -05:00
Jason Quense
399c182ab5 Merge pull request babel/eslint-plugin-babel#123 from daltones/master
Deprecate rule `no-await-in-loop`
2017-03-04 09:35:33 -05:00
Henry Zhu
c548da9d36 4.1.0 2017-02-27 15:00:01 -05:00
Aaron Jensen
71202609b5 Add babel semi (babel/eslint-plugin-babel#121)
* Add semi from eslint

* Add ClassProperty support to semi rule

Fixes babel/eslint-plugin-babel#43
2017-02-27 11:58:50 -08:00
Henry Zhu
4b52a4c707 4.0.1 2017-01-18 18:03:24 -05:00
Matthew Wagerfield
7f94d5f75f Updated rules to new format, added deprecated flag (babel/eslint-plugin-babel#119) 2017-01-18 23:01:31 +00:00
Henry Zhu
3855f28ebb 4.0.0 2016-11-17 16:46:29 -05:00
Henry Zhu
9c9bff745c readme: drop node < 4 [skip ci] 2016-11-17 16:45:47 -05:00
Henry Zhu
d38551cc23 Breaking: Deprecate built-in rules (babel/eslint-plugin-babel#115)
* Deprecate built-in rules

* fix update to babel-eslint 7 with awaitexpression

* deprecate flow-object-type
2016-11-17 16:39:04 -05:00
greenkeeper[bot]
48010c551b chore(package): update dependencies (babel/eslint-plugin-babel#109)
https://greenkeeper.io/
2016-11-17 15:23:38 -05:00
Mathieu M-Gosselin
5b5f8e32a0 Updated Node versions to test against in the Travis configuration. (babel/eslint-plugin-babel#110) 2016-11-17 15:23:23 -05:00
Plusb Preco
c7d8d991a8 Drop support of Node < 4 (babel/eslint-plugin-babel#113)
* Drop support Node < 4

* Add missing changes

* Update `.travis.yml`
2016-11-18 05:21:46 +09:00
Jason Quense
2b52d67ebc Merge pull request babel/eslint-plugin-babel#101 from mathieumg/no-invalid-this
Added `babel/no-invalid-this`
2016-11-02 14:38:46 -04:00
Greenkeeper
831a217d00 chore(package): update mocha to version 3.0.0 (babel/eslint-plugin-babel#79)
https://greenkeeper.io/
2016-09-22 10:27:31 +02:00
Greenkeeper
57b06a504a chore(package): update eslint to version 3.0.0 (babel/eslint-plugin-babel#70)
https://greenkeeper.io/
2016-07-01 21:27:59 +02:00
Kai Cataldo
6e4d44f312 Update Dependencies (babel/eslint-plugin-babel#67)
* Update Dependencies

fixes babel/eslint-plugin-babel#65

* Remove PhantomJS & is-my-json-valid

PhantomJS & is-my-json-valid is not actually used anywhere

* Change ESLint peerDependency version back to >=1.0.0
2016-07-01 10:15:59 -04:00
Henry Zhu
f6c2d2e0e5 --save-dev instead of -D [skip ci] 2016-07-01 08:24:41 -04:00
Kai Cataldo
1daf7f9865 Run Travis CI in same Node versions as babel-eslint (babel/eslint-plugin-babel#68) 2016-07-01 07:58:05 -04:00
Henry Zhu
cae8513636 3.3.0 2016-06-21 16:17:06 -04:00
Henry Zhu
8cd329f611 Merge pull request babel/eslint-plugin-babel#64 from zertosh/master
Add func-params-comma-dangle rule
2016-06-21 16:15:36 -04:00
Henry Zhu
148e6be60f show which rules are fixable 2016-06-01 18:13:06 -04:00
Jason Quense
f57dc5227a Merge pull request babel/eslint-plugin-babel#62 from lemonmade/fix-for-arrow-parens
Add an automated fix for arrow-parens
2016-06-01 16:45:26 -04:00
Henry Zhu
8487ec8a67 3.2.0 2016-04-07 18:25:57 -04:00
Henry Zhu
ba2b2bc04d Merge pull request babel/eslint-plugin-babel#57 from nmote/docs
Add docs for flow-object-type rule
2016-04-07 18:24:59 -04:00
Jason Quense
5363ff85cc Merge pull request babel/eslint-plugin-babel#56 from nmote/flow-object-type
Add flow-object-type rule
2016-04-05 16:19:28 -04:00
jquense
6ac58744fe update readme 2016-02-03 19:30:16 -05:00
jquense
7fa3aa9116 3.1.0 2016-02-03 19:28:25 -05:00
Jason Quense
7a2ecd2516 Merge pull request babel/eslint-plugin-babel#44 from ssorallen/arrow-type-annotations
Add type annotations to arrow-parens "as-needed"
2016-01-21 20:20:23 -05:00
Jason Quense
d58dc7bd1d Merge pull request babel/eslint-plugin-babel#41 from zaygraveyard/issue35
Fix: array-bracket-spacing for destructuring typed parameter (fixes babel/eslint-plugin-babel#35)
2015-12-20 19:45:01 -05:00
Jason Quense
8bc70e3aac Merge pull request babel/eslint-plugin-babel#40 from zaygraveyard/issue18
Update: Add tests to check the issue babel/eslint-plugin-babel#18
2015-12-20 19:13:30 -05:00
Jason Quense
b5cdcbe06e Merge pull request babel/eslint-plugin-babel#39 from zaygraveyard/issue37
Update: Implement auto fix for object-curly-spacing (fixes babel/eslint-plugin-babel#37)
2015-12-20 17:14:32 -05:00
Jason Quense
9eebd7b057 Merge pull request babel/eslint-plugin-babel#38 from zaygraveyard/issue36
Fix: `object-curly-spacing` had been crashing on an empty object patt…
2015-12-20 16:43:33 -05:00
Henry Zhu
885bfe95dc Merge pull request babel/eslint-plugin-babel#32 from hawkrives/patch-1
Fix typo in README rules section
2015-11-29 19:28:01 -05:00
Henry Zhu
1168d60564 3.0.0 2015-11-25 18:51:45 -05:00
Jason Quense
a2c695275d Merge pull request babel/eslint-plugin-babel#29 from evocateur/no-deps
Future-proofing
2015-11-25 14:47:17 -05:00
jquense
fcdf7ec95d v2.2.0 2015-11-23 19:16:41 -05:00
Jason Quense
dd8f357639 Merge pull request babel/eslint-plugin-babel#22 from nmote/await
Add no-await-in-loop rule.
2015-11-01 11:46:24 -05:00
Jason Quense
9d8a2f14dd Merge pull request babel/eslint-plugin-babel#23 from LegNeato/master
Support trailing commas in import and export statements. Fixes babel/eslint-plugin-babel#21
2015-10-26 10:36:36 +07:00
Jason Quense
64291d8d52 Merge pull request babel/eslint-plugin-babel#11 from pascalduez/pr__fix-readme
Improve the Readme
2015-08-18 15:30:38 -04:00
Henry Zhu
eb438f0f98 2.1.1 2015-08-18 10:53:41 -04:00
Henry Zhu
cc73bb56b6 Merge pull request babel/eslint-plugin-babel#10 from aruberto/master
add arrow-parens to index.js
2015-08-18 10:52:55 -04:00
Henry Zhu
902ae7e6e7 2.1.0 2015-08-15 21:08:57 -04:00
Henry Zhu
f5f7b50e17 Merge pull request babel/eslint-plugin-babel#9 from babel/arrow-parens
Add support for async functions in arrow-parens
2015-08-15 21:05:46 -04:00
jquense
fc31183a20 v2.0.0 2015-08-04 23:33:06 -04:00
Jason Quense
3eeaa4aa36 Merge pull request babel/eslint-plugin-babel#7 from mathieumg/eslint1.0
Updated for ESLint 1.0
2015-08-04 23:30:13 -04:00
Jason Quense
89011d92fc Merge pull request babel/eslint-plugin-babel#5 from deepsweet/eslint-1.0-rc
support eslint@>=1.0.0-rc-1
2015-07-24 14:14:14 -04:00
jquense
f0a2fb6b7b v1.2.0 2015-07-20 14:55:25 -04:00
Jason Quense
51d6ba733f Merge pull request babel/eslint-plugin-babel#4 from mathieumg/objectcurlyspacing_export
Added support for experimental exports in the `object-curly-spacing` rule
2015-07-16 09:17:20 -04:00
jquense
1bfe4aa02f v1.1.0 2015-07-07 19:40:03 -04:00
Jason Quense
fadd5b55ca Merge pull request babel/eslint-plugin-babel#3 from mathieumg/spaceinbrackets_export
Added support for experimental exports in the `space-in-brackets` rule.
2015-07-03 23:15:14 -04:00
Jason Quense
c2c9933797 Merge pull request babel/eslint-plugin-babel#1 from mathieumg/blockscopedvar_export
Added support for experimental export types
2015-07-03 23:14:57 -04:00
Jason Quense
382c3f2bb9 Merge pull request babel/eslint-plugin-babel#2 from mathieumg/newcap_decorators
Added support for decorators in the new-cap rule.
2015-07-01 13:39:08 -04:00
jquense
e9e6dee39a Typos and copy 2015-06-19 00:08:09 -04:00
Jason Quense
cc35677cff Update README.md 2015-06-19 00:04:01 -04:00
jquense
c442efa7c5 Initial 2015-06-19 00:01:10 -04:00
Brian Ng
5b35722d63 Bump semver@6 (babel/babel-eslint#802) 2019-11-01 18:08:47 -05:00
Chiawen Chen
3396fdd7f7 Breaking: make AST match Espree 6 (babel/babel-eslint#785) 2019-11-02 07:08:32 +08:00
dependabot[bot]
6b3e9e3f1e Bump eslint-utils from 1.4.0 to 1.4.2 (babel/babel-eslint#796)
Bumps [eslint-utils](https://github.com/mysticatea/eslint-utils) from 1.4.0 to 1.4.2.
- [Release notes](https://github.com/mysticatea/eslint-utils/releases)
- [Commits](https://github.com/mysticatea/eslint-utils/compare/v1.4.0...v1.4.2)

Signed-off-by: dependabot[bot] <support@github.com>
2019-08-26 21:16:13 -05:00
Daniel Tschinder
030fddb0b8 chore: Update deps and fix tests for new mocha and eslint (babel/babel-eslint#781) 2019-07-15 18:49:52 +02:00
dependabot[bot]
8635063118 Bump js-yaml from 3.12.0 to 3.13.1 (babel/babel-eslint#780)
Bumps [js-yaml](https://github.com/nodeca/js-yaml) from 3.12.0 to 3.13.1.
- [Release notes](https://github.com/nodeca/js-yaml/releases)
- [Changelog](https://github.com/nodeca/js-yaml/blob/master/CHANGELOG.md)
- [Commits](https://github.com/nodeca/js-yaml/compare/3.12.0...3.13.1)

Signed-off-by: dependabot[bot] <support@github.com>
2019-07-15 18:27:39 +02:00
dependabot[bot]
6748797681 Bump lodash from 4.17.5 to 4.17.14 (babel/babel-eslint#779)
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.5 to 4.17.14.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.5...4.17.14)

Signed-off-by: dependabot[bot] <support@github.com>
2019-07-15 18:25:29 +02:00
Param Aggarwal
f9836caee5 fix typo in README.md (babel/babel-eslint#762) 2019-04-04 19:51:25 +05:30
Yosuke Ota
3fcfc90a12 Fix to convert hash token. (babel/babel-eslint#753) 2019-02-15 07:56:30 +09:00
Kai Cataldo
025fff7871 Docs: Add glob-based configuration example (babel/babel-eslint#748)
* Docs: Add glob-based configuration example

* Fix quotes style for consistency
2019-01-29 10:56:54 -05:00
Henry Zhu
2d64900b46 11.0.0-beta.0 2019-01-21 16:29:18 -05:00
Kai Cataldo
37cf65c6f8 Add requireConfigFile option (babel/babel-eslint#743)
* Add requireConfigFile option

* Update README.md
2019-01-21 11:06:29 -05:00
Kai Cataldo
0581ce1559 Add code of conduct (same as Babel) (babel/babel-eslint#740) [skip ci] 2019-01-11 15:27:36 -05:00
Kai Cataldo
bbce2b3807 Remove comment attachment (babel/babel-eslint#736)
* Remove comment attachment

* Simplify error messaging in tests
2019-01-11 12:23:34 -05:00
Kai Cataldo
2b9ee42ded Remove monkeypatching dead code (babel/babel-eslint#737) 2019-01-10 18:28:40 -05:00
Kai Cataldo
47de99e1b8 Use @babel/core#parse (babel/babel-eslint#711) 2019-01-10 15:25:00 -05:00
Kai Cataldo
bede064c0b Major: remove parseNoPatch (babel/babel-eslint#733) 2019-01-07 09:55:16 -05:00
Kai Cataldo
c209725ada Test Node v11 in CI (babel/babel-eslint#712) 2018-11-08 10:43:04 -05:00
Emerson Laurentino
de38cfc510 fix index path typo (babel/babel-eslint#709) 2018-11-07 16:36:11 -03:00
Kai Cataldo
22a1681e11 Merge pull request babel/babel-eslint#706 from kaicataldo/es6
Update ESLint config
2018-10-30 14:48:37 -05:00
Henry Zhu
40d9bb3a77 10.0.1 2018-09-27 10:29:57 -04:00
Henry Zhu
e56b342e59 Revert babel/babel-eslint#584 (babel/babel-eslint#697)
* Revert "Treat type alias declarationlike function declaration (babel/babel-eslint#584)"

This reverts commit 020d012c554913fea137f4129798ce31a4896dfe.
2018-09-27 10:29:29 -04:00
Henry Zhu
9adb82e68a 10.0.0 2018-09-25 15:32:56 -04:00
Henry Zhu
742aa412a7 test value should be switched 2018-09-25 15:29:14 -04:00
Joa Ebert
22fa8e6f20 Treat type alias declarationlike function declaration (babel/babel-eslint#584)
A type alias shouldn't trigger a no-use-before-define warning just
like a function declaration.

Cyclic type dependencies are common when using flow.
For instance: type Node<T> = { head: T; tail: Node<T> }

Fixes babel/babel-eslint#485
2018-09-25 20:39:43 +02:00
Henry Zhu
78a2f603ce Test eslint5, update peerDep (babel/babel-eslint#690)
* test against eslint 5
* set peerDep
2018-09-25 14:32:16 -04:00
Brian Ng
990ea0f1ae Drop old monkeypatching behavior (babel/babel-eslint#689)
An alternative to adding a direct dep on estraverse (https://github.com/babel/babel-eslint/pull/685), let's just drop the old monkeypatching behavior.

Closes babel/babel-eslint#685, Closes babel/babel-eslint#680
2018-09-25 13:07:46 -05:00
Henry Zhu
dae75e1853 9.0.0 2018-08-27 18:09:21 -04:00
Brian Ng
b6a7601e4a Bump to babel@7.0.0 🎉 (babel/babel-eslint#676) 2018-08-27 17:04:26 -05:00
Ed Morley
c456fdddd7 Docs: Make the default parserOptions more explicit (babel/babel-eslint#673)
In particular, previously the `.eslintrc` example implied that the default value for `codeFrame` was `false`, when in fact it is `true`:
https://github.com/babel/babel-eslint/blob/v9.0.0-beta.3/lib/parse.js#L14
2018-08-23 06:23:06 +01:00
Alexandre Borela
2a1c76e070 Add logical assignment plugin (babel/babel-eslint#674)
Fix babel/babel-eslint#672
2018-08-23 02:21:45 -03:00
Brian Ng
57c825eebb Bump some devDeps 2018-08-21 15:18:02 -05:00
Leo Yin
6ab458b512 build(deps): upgrade @babel/* to 7.0.0-rc.2 (babel/babel-eslint#668) 2018-08-22 04:00:17 +08:00
Henry Zhu
35c49ddf97 9.0.0-beta.3 2018-07-12 09:50:58 -04:00
Henry Zhu
098ab73be1 update lock 2018-07-12 09:50:30 -04:00
Mark Tse
e675cd7445 chore - fixing eslint-scope to a safe version; resolves babel/babel-eslint#656. (babel/babel-eslint#657) 2018-07-12 09:49:43 -04:00
Brian Ng
a1f9458052 9.0.0-beta.2 2018-07-06 11:24:45 -05:00
Rubén Norte
a17917810d Merge pull request babel/babel-eslint#645 from rubennorte/support-new-flow-syntax-in-scope-analysis
Support new flow syntax in scope analysis
2018-07-06 17:20:52 +01:00
Rubén Norte
dcf55cb730 Upgrade Babel to v7.0.0-beta.52 (babel/babel-eslint#650)
* Upgrade Babel to v7.0.0-beta.52

* Fixed failing test
2018-07-06 14:50:59 +01:00
Brian Ng
28c4507866 9.0.0-beta.1 2018-06-29 08:37:18 -05:00
Rubén Norte
4f9e2a5be6 Breaking: Upgraded Babel to 7.0.0-beta.51 (babel/babel-eslint#642)
* Upgraded Babel to 7.0.0-beta.51, with changes to decorators

* Removed support for Node 4 and added it for Node 10

* nit: fix typo [skip ci]
2018-06-29 14:26:43 +01:00
Brian Ng
8dae11e6d2 8.2.5 2018-06-23 08:20:40 -05:00
Brian Ng
9342a5b74c Revert bump to babel 51 (babel/babel-eslint#640) 2018-06-23 08:20:08 -05:00
Brian Ng
92507e598f 8.2.4 2018-06-22 13:39:23 -05:00
Brian Ng
42d0769683 Add test for template string with object with template string inside (babel/babel-eslint#639)
Closes https://github.com/babel/babel-eslint/pull/538.
Fixes https://github.com/babel/babel-eslint/issues/537.

Now that https://github.com/babel/babel-eslint/pull/610 has landed, I wanted to make sure this case was covered.
2018-06-22 11:12:54 -05:00
Brian Ng
6a6c2bad50 Support OptionalMemberExpression with scope too (babel/babel-eslint#634) 2018-06-22 11:03:15 -05:00
Brian Ng
b537da9b53 Drop node4 in travis 2018-06-15 16:39:58 -05:00
Brian Ng
85d8f70478 Bump Babel deps 2018-06-11 08:47:15 -05:00
Cristian Pallarés
da43afb5de refactor: rename babylon to @babel/parser 2018-06-06 00:18:13 +02:00
Brian Ng
077bea0a45 Fix converting template types to handle nested templates (babel/babel-eslint#610)
Fixes https://github.com/babel/babel-eslint/issues/603 (and the fixture from https://github.com/babel/babel-eslint/issues/609 works).

Reworks our code that converts the format of Babylon template tokens to be a bit more robust, especially with things like nested templates with arrows.

(Adapted the logic from https://github.com/eslint/espree/blob/master/lib/token-translator.js)
2018-06-18 16:46:31 -05:00
Rubén Norte
99968db2b1 Fix token types for experimental operators (babel/babel-eslint#632)
* Added failing tests

* Recognized nullish coalescing, optional chaining and pipeline operators as Punctuator tokens
2018-06-15 15:42:05 +01:00
Rubén Norte
3477626973 Add support for the optional chaining operator (babel/babel-eslint#630) 2018-06-15 15:31:43 +01:00
jmurretxactly
735abb06b4 don't require unpad per test fixture, fixes babel/babel-eslint#572 (babel/babel-eslint#618) 2018-05-08 05:52:59 -06:00
Ankur Oberoi
cadb22334e updates readme for latest eslint & babel-eslint (babel/babel-eslint#607) [skip ci] 2018-04-13 09:26:41 -07:00
Henry Zhu
b2bc4fe4f4 8.2.3 2018-04-13 11:25:03 -04:00
Henry Zhu
2f7aea98eb lock to beta.44 2018-04-13 11:23:59 -04:00
Bary Levi
b2c065976b Save babel beta packages as exact versions (babel/babel-eslint#606) [skip ci] 2018-04-13 18:23:03 +03:00
Daniel Tschinder
f75f7a0601 8.2.2 2018-02-20 11:57:07 +01:00
Daniel Tschinder
1bd58fa018 Allow newer versions of babel 2018-02-20 11:56:40 +01:00
Daniel Tschinder
c27c2b6e68 Update dependencies 2018-02-20 11:54:09 +01:00
Daniel Tschinder
c03d5c41a5 chore(package): update lint-staged to version 6.1.1 (babel/babel-eslint#592)
Closes babel/babel-eslint#539
2018-02-20 11:49:19 +01:00
Brian Ng
7057e9fb73 Bump deps (babel/babel-eslint#591) 2018-02-15 21:39:42 -06:00
Toru Nagashima
fbb7ff6e44 Fix: wrong token type of ! and ~ (fixes babel/babel-eslint#576) (babel/babel-eslint#577) 2018-01-17 15:10:55 +09:00
Henry Zhu
6d37c551dd 8.2.1 2018-01-08 19:15:40 -05:00
Henry Zhu
23d12acd15 fix export change (babel/babel-eslint#571) 2018-01-08 19:15:22 -05:00
Kai Cataldo
b6ce2b649f 8.2.0 2018-01-08 18:06:57 -05:00
Henry Zhu
2afde99434 Add other parser plugins, update yarn.lock (babel/babel-eslint#569) 2018-01-08 17:46:57 -05:00
Kai Cataldo
97c9442511 Make 2018 the default ecmaVersion for rules relying on parserOptions (babel/babel-eslint#556) 2018-01-08 17:45:24 -05:00
jony89
660180b932 update babel packages (babel/babel-eslint#565)
* update babel packages

There is some critical bug fixes in version babylon#7.0.0-beta.33 regard `async` - `await` syntax which is needed pretty immediately :)

* remove test 42 (test for import type *)

`import type *` is invalid, since the namespace can't be a type
2018-01-09 00:40:11 +02:00
Toru Nagashima
d0d84aca9b 8.1.2 2017-12-26 10:59:19 +09:00
Toru Nagashima
624a425f7d Fix: add Literal type to visitorKeys (babel/babel-eslint#562)
* Fix: add Literal type to visitorKeys
* Fix: use ./visitor-keys
2017-12-26 10:50:13 +09:00
Toru Nagashima
3cb154df82 Fix: ignore eval (fixes babel/babel-eslint#560) (babel/babel-eslint#561) 2017-12-26 10:49:36 +09:00
Toru Nagashima
a706e85b19 8.1.1 2017-12-25 15:57:19 +09:00
Teddy Katz
e988a88af0 Fix: Prevent parseForESLint() behavior from changing after parse() is called (fixes babel/babel-eslint#558)(babel/babel-eslint#559)
* Prevent parseForESLint() behavior from changing after parse() is called

(fixes https://github.com/babel/babel-eslint/issues/558, fixes https://github.com/eslint/eslint/issues/9767)

* Avoid using the enhanced referencer after monkeypatching

* Chore: add test for babel/babel-eslint#558

* Pass correct scope analyzer options

* fix escope patch and improve tests

* remove process.exit(1)
2017-12-25 01:52:36 -05:00
Teddy Katz
5b08714a4d 8.1.0 2017-12-24 02:02:44 -05:00
Teddy Katz
d33839a9c3 Re-add parseNoPatch function (accidentally removed) (babel/babel-eslint#557) 2017-12-24 02:00:29 -05:00
Toru Nagashima
5d6d52f04e Use new scopeManager/visitorKeys APIs (babel/babel-eslint#542)
(fixes https://github.com/eslint/eslint/issues/9762)
2017-12-24 15:42:17 +09:00
Logan Smyth
7ed6bfb925 8.0.3 2017-12-01 10:06:40 -08:00
Logan Smyth
3a36eca1b4 Fix mocha command path. 2017-12-01 10:06:24 -08:00
Logan Smyth
b6172b2ed3 Lock down dependency versions. 2017-12-01 10:05:34 -08:00
Henry Zhu
39cef92885 8.0.2 2017-11-06 15:00:41 -05:00
Henry Zhu
0e2bbc3705 require correct deps 2017-11-06 14:57:56 -05:00
Henry Zhu
090269e5a0 Always use unpad (babel/babel-eslint#535) 2017-11-06 12:51:19 -05:00
Henry Zhu
f43062ebbb Allow ^ version for babel dependencies (babel/babel-eslint#534) 2017-11-06 12:47:47 -05:00
greenkeeper[bot]
38f372b8ea fix(package): update babylon to version 7.0.0-beta.31 (babel/babel-eslint#533) 2017-11-06 12:25:35 -05:00
Henry Zhu
c958724bbd 8.0.1 2017-09-26 16:18:43 -04:00
Clement Hoang
b0d8baf320 Update README.md support (babel/babel-eslint#531) [skip ci]
#linting channel is now archived in babel slack.
2017-10-31 11:50:35 -07:00
greenkeeper[bot]
5b3caf7b66 chore(package): update mocha to version 4.0.0 (babel/babel-eslint#524) 2017-10-11 14:14:29 +02:00
Jordan Gensler
04cf4246b8 Adding optionalCatchBinding to plugins. (babel/babel-eslint#521) 2017-09-26 13:17:44 -07:00
Henry Zhu
b576677e9f 8.0.0 2017-09-12 09:44:23 -04:00
Henry Zhu
d61b06b8b5 update to beta.0 2017-09-12 09:42:30 -04:00
Daniel Tschinder
15e2aa0a24 Remove already fixed workaround (babel/babel-eslint#508) 2017-08-02 14:37:01 +02:00
Henry Zhu
bc9b69590b 8.0.0-alpha.17 2017-07-26 16:19:29 -04:00
Henry Zhu
cf86d94597 alpha.17 2017-07-26 16:18:45 -04:00
Henry Zhu
35f79cb272 8.0.0-alpha.15 2017-07-13 13:01:31 -04:00
Henry Zhu
522140b43f update (babel/babel-eslint#504) 2017-07-13 12:58:45 -04:00
Evan Brodie
c9b8d2dfd1 Readme update usage section (babel/babel-eslint#501) [skip ci]
* Updates README: Consolidates versioning table

Basically a revert of 52b4a13. It is easier to read a single table instead of two locations in the README for the version compatabilities between ESLint and babel-eslint

* Updates README: Add yarn command for installation

* [skip ci]
2017-07-09 21:03:59 -04:00
greenkeeper[bot]
469e679b6d Update eslint to the latest version 🚀 (babel/babel-eslint#500)
* chore(package): update eslint to version 4.1.0

* escope -> eslint-scope

* Fix linting
2017-06-25 08:30:29 -07:00
greenkeeper[bot]
dcb4bffee5 chore(package): update husky to version 0.14.0 (babel/babel-eslint#498) 2017-06-22 13:18:47 -07:00
Kevin Mårtensson
9a791d175c Update install instructions to use latest stable release (babel/babel-eslint#497) [skip ci] 2017-06-20 23:49:46 +02:00
Henry Zhu
d40a6dd9b7 8.0.0-alpha.13 2017-06-18 18:33:40 -04:00
Henry Zhu
6aec93c468 Merge pull request babel/babel-eslint#493 from danez/regression-test
Test for babylon regression
2017-06-18 18:30:59 -04:00
Brian Ng
94e69f399b Add Prettier (babel/babel-eslint#491) 2017-06-17 14:14:42 -05:00
Henry Zhu
001064885d 8.0.0-alpha.12 2017-06-16 16:56:32 -04:00
Daniel Tschinder
bffbaff7e2 Use babylon estree and ranges (babel/babel-eslint#489) 2017-06-15 23:03:02 +02:00
Mark Banner
36a630e023 Fix: allow options to be optional when monkey patching escope.analyze (fixes babel/babel-eslint#470). (babel/babel-eslint#484) 2017-06-08 17:23:08 +01:00
Reyad Attiyat
45a9f64174 Use Node 8 and drop Node 5 from travis (babel/babel-eslint#483)
* Use Node 8 and drop Node 5 from travis

* switch the order [skip ci]
2017-06-06 20:38:49 -05:00
Reyad Attiyat
4e4aa05639 Update to Babylon 7 (fixes babel/babel-eslint#481) (babel/babel-eslint#482)
* Update to Babylon 7 (fixes babel/babel-eslint#481)

* Pin dependencies to alpha version

* fix deprecation, add other plugins

* oops

* Update index.js

* Add tests for private class properties with rules no-undef no-unused-vars
2017-06-06 20:37:57 -05:00
Reyad Attiyat
cb2eb3a1fb Fix: Convert RegExpLieteral value to RegExp object (fixes babel/babel-eslint#477) (babel/babel-eslint#478) 2017-05-29 20:41:14 -05:00
Sebastian McKenzie
b4daa5eae2 7.2.3 2017-04-21 22:14:19 +01:00
Andres Suarez
6feaee84e0 Fix flow type spread handling (babel/babel-eslint#465) 2017-04-21 11:48:52 -04:00
Henry Zhu
b5c058bf6e 7.2.2 2017-04-12 12:07:05 -04:00
Vitor Balocco
267731917b Fix: use eslint-scope instead of escope if present (babel/babel-eslint#461) 2017-04-12 17:59:23 +02:00
Andres Suarez
b8a3af8cd6 Separate finding peer deps from monkeypatching (babel/babel-eslint#460) 2017-03-30 13:49:51 -04:00
Andres Suarez
9a558bd942 Remove unused .gitmodules (babel/babel-eslint#457) 2017-03-25 19:36:10 -04:00
Andres Suarez
d78b0debd7 Use dedent for unpadding (babel/babel-eslint#456) 2017-03-25 19:32:05 -04:00
Henry Zhu
711c1e2f4b Merge pull request babel/babel-eslint#455 from babel/babylon-to-espree-tidy
Tidy up babylon-to-espree
2017-03-25 19:15:23 -04:00
Andres Suarez
2ca65d5451 Add type parameter scope tests (babel/babel-eslint#454) 2017-03-23 15:46:48 -04:00
Henry Zhu
e8b91f8862 7.2.1 2017-03-23 14:03:23 -04:00
Andres Suarez
26daac8690 Remove left over eslint 2 estraverse code (babel/babel-eslint#452)
This was missed in babel/babel-eslint#361
2017-03-23 14:02:24 -04:00
Andres Suarez
1c5400a670 Fix type param and interface declaration scoping (babel/babel-eslint#449) 2017-03-23 12:49:19 -04:00
Andres Suarez
700f62e28e Remove lodash dependency (babel/babel-eslint#450) 2017-03-22 22:35:31 -04:00
Andres Suarez
371488c102 Format non-regression errors for legibility (babel/babel-eslint#451) 2017-03-22 22:34:13 -04:00
Luís Couto
1cda9b6a80 Update README.md with codeFrame option (babel/babel-eslint#448) 2017-03-21 00:11:30 +00:00
Henry Zhu
f9b19189d7 7.2.0 2017-03-20 17:53:26 -04:00
wtgtybhertgeghgtwtg
d3c40a1851 Use lodash instead of lodash.pickby. (babel/babel-eslint#435) 2017-03-20 14:50:09 -07:00
Alex Rattray
65413344bd [flow] Process polymorphic type bounds on functions (babel/babel-eslint#444) 2017-03-20 14:46:07 -07:00
Luís Couto
2bee348c9a Add option to disable code frame. (babel/babel-eslint#446)
* Add option to disable code hightlight.

* Rename codeHighlight with codeFrame

* Add codeFrame tests

* Remove colors from test assertions
2017-03-20 21:45:11 +00:00
Henry Zhu
dccd5a7593 Merge pull request babel/babel-eslint#447 from kaicataldo/clean-up-eslint
Chore: Clean up and upgrades
2017-03-20 11:44:33 -04:00
Henry Zhu
b3c41bd5d7 remove deprecated rule examples [skip ci] 2017-02-28 23:41:03 -05:00
Henry Zhu
ad8a7e78e1 update readme [skip ci] 2017-02-28 23:39:49 -05:00
Henry Zhu
4f4d229e0a chore(package): update eslint-config-babel to version 6.0.0 (babel/babel-eslint#433)
* chore(package): update eslint-config-babel to version 6.0.0

Closes babel/babel-eslint#432

https://greenkeeper.io/

* Fix linting
2017-01-15 06:59:51 -05:00
Nazim Hajidin
d76cfe05b1 Update to use Node 4 features (babel/babel-eslint#425)
* Change for loops to forEach

* Change more for loops

* Arrow functions

* Use object shorthand

* Put this on one line

* Change back to using for loops
2017-01-14 17:15:54 -05:00
greenkeeper[bot]
fd2093914e chore(package): update eslint-config-babel to version 4.0.0 (babel/babel-eslint#430)
https://greenkeeper.io/
2017-01-10 19:36:02 +01:00
Henry Zhu
10864cfa71 add badges [skip ci] 2016-12-06 18:02:37 -05:00
Henry Zhu
38072c0716 Revert "use *" (babel/babel-eslint#426) 2016-12-02 16:51:16 -05:00
Henry Zhu
122acf8f81 use * (babel/babel-eslint#421) 2016-11-18 08:52:17 -05:00
greenkeeper[bot]
332da936b7 chore(package): update eslint-config-babel to version 3.0.0 (babel/babel-eslint#423)
https://greenkeeper.io/
2016-11-17 18:05:03 -05:00
Henry Zhu
f78ab342fd 7.1.1 2016-11-17 17:59:19 -05:00
greenkeeper[bot]
49625639f2 chore(package): update dependencies (babel/babel-eslint#422)
https://greenkeeper.io/
2016-11-17 17:57:52 -05:00
Henry Zhu
838bada36d append code frame on parse error (babel/babel-eslint#418) 2016-11-17 17:48:58 -05:00
Henry Zhu
1be2c47da6 chore(package): update babylon to version 6.13.0 (babel/babel-eslint#420)
https://greenkeeper.io/
2016-11-03 09:37:12 -04:00
Henry Zhu
8c12b515b8 chore(package): update eslint to version 3.9.1 (babel/babel-eslint#419)
https://greenkeeper.io/
2016-11-03 09:36:59 -04:00
Henry Zhu
93a4c3c699 7.1.0 2016-10-26 14:36:47 -04:00
Jordan Gensler
1d52247080 [import()] Adding support to lint dynamic imports (babel/babel-eslint#413)
* [import()] Adding support to lint dynamic imports

* [import()] Adding regression test to import
2016-10-17 14:40:06 -04:00
Steven Job
1f04cab99f Now using template strings (babel/babel-eslint#410)
* Use template strings in non-regression tests

* Refactor non-regression tests to fix test failures

Moved backtick to fix test 'getter/setter babel/babel-eslint#218' as indent matters
Fixed line numbers for some tests

* Use template strings in babel-eslint tests

* Fix tests for babel-eslint

Avoids error that shows when using template strings for tests:
	line 253 line comments
	line 260 block comments
	line 306 jsdoc

Error: At loc.start.column: are different (6 !== 0)

* Other small template literal changes

* Add unpad to correctly indent template literals
2016-10-17 19:27:20 +01:00
Daniel Tschinder
31f48f0651 Update test for eslint 3.8 (babel/babel-eslint#412)
* Update test for eslint 3.8

also ignore yarn lock

* Run lint only on latest version
2016-10-15 11:04:55 +02:00
Greenkeeper
610cf28dab Update eslint-config-babel to version 2.0.1 🚀 (babel/babel-eslint#408)
* chore(package): update eslint-config-babel to version 2.0.1

https://greenkeeper.io/

* Fix plugin
2016-10-10 14:36:10 +02:00
Nick
994eea7a53 docs: Update built-in support notes in README (babel/babel-eslint#398) [skip ci]
* docs: Update built-in support notes in README

eslint v3.6.0 supports ES2017 features

* docs: Update built-in support notes in README

eslint v3.6.0 supports ES2017 features
2016-09-29 21:25:35 +01:00
Henry Zhu
8d48eecc2f 7.0.0 2016-09-27 12:35:24 -04:00
Henry Zhu
aa6c5ccd45 updates 2016-09-27 12:34:26 -04:00
Henry Zhu
3c414db312 remove eslint 2 logic (babel/babel-eslint#361)
* remove old code

* remove async/await logic before eslint supported it

* not needed
2016-09-27 12:32:10 -04:00
Ville Immonen
ce6d9df192 Remove the lodash.assign dependency (babel/babel-eslint#393)
lodash.assign is deprecated:
```
npm WARN deprecated lodash.assign@4.2.0: This package is deprecated.
Use Object.assign.
```
2016-09-27 18:32:52 +03:00
Greenkeeper
33343e6688 chore(package): update babylon to version 6.11.2 (babel/babel-eslint#391)
https://greenkeeper.io/
2016-09-27 14:43:22 +02:00
Greenkeeper
2339c8af0f chore(package): update espree to version 3.3.1 (babel/babel-eslint#394)
https://greenkeeper.io/
2016-09-27 14:43:14 +02:00
Greenkeeper
93a73cc483 chore(package): update eslint to version 3.6.0 (babel/babel-eslint#392)
https://greenkeeper.io/
2016-09-27 14:43:03 +02:00
Henry Zhu
3d4e8cfea3 update test line number [skip ci] 2016-09-27 08:42:41 -04:00
Dan Harper
f97d83d847 eslint-plugin-flow-vars -> eslint-plugin-flowtype (babel/babel-eslint#374) [skip ci] 2016-09-09 16:28:19 +01:00
Henry Zhu
9c70c76cfd add deps for npm 2 2016-09-09 11:26:47 -04:00
Henry Zhu
313388b293 typo 2016-08-03 09:36:15 -04:00
Henry Zhu
2b812b087c Merge pull request babel/babel-eslint#354 from babel/eslint-config-babel
Use eslint-config-babel
2016-08-03 09:34:51 -04:00
Greenkeeper
481329a47e chore(package): update mocha to version 3.0.0 (babel/babel-eslint#356)
https://greenkeeper.io/
2016-08-02 04:34:39 +02:00
Henry Zhu
50e0abfd16 Drop node < 4 (babel/babel-eslint#358) 2016-08-01 15:00:01 -04:00
Daniel Tschinder
0534eb7644 Fix tests for eslint 3.2 (babel/babel-eslint#352) 2016-07-30 19:44:42 +02:00
Daniel Tschinder
289bf4f84a Add note about eslint 3 [skip ci] 2016-07-11 01:18:41 +02:00
Daniel Tschinder
af44a1cc83 Test eslint 3 and 2 on travis (babel/babel-eslint#340)
closes babel/babel-eslint#332
2016-07-11 00:28:57 +02:00
Daniel Tschinder
0cb35ab04e Fix tests for eslint 3.0
Seems that eslint got a lot smarter and reports vars that are used, but are useless as unused
These examples are also failing with espree
2016-07-10 23:47:44 +02:00
Henry Zhu
b0dbbfcc03 6.1.2 2016-07-09 11:40:34 -04:00
Toru Nagashima
1766a21145 Fix: improve handling of class properties (fixes babel/babel-eslint#337) (babel/babel-eslint#338)
I added ClassProperty method into Referencer of escope. This method will
address class properties and those type anotations.
2016-07-10 00:40:08 +09:00
Henry Zhu
52d9c34465 6.1.1 2016-07-08 14:23:39 -04:00
Henry Zhu
9ee5e6e59c Create a variable for class properties in scope instead of deleting the key (babel/babel-eslint#336) 2016-07-08 14:23:04 -04:00
Henry Zhu
66a4cf578f remove hardcoded strict mode value (babel/babel-eslint#331) 2016-06-27 01:53:27 -04:00
Daniel Tschinder
19baee2242 Add testcase for space-comment and shebang babel/babel-eslint#163
This works as of babylon 6.8.2
2016-06-26 22:50:50 +02:00
Daniel Tschinder
ce54b07e2d Testcase for newline-before-return shouldn't fail with comments. (babel/babel-eslint#300) 2016-06-26 21:52:39 +02:00
Henry Zhu
167b8bf0a0 6.1.0 2016-06-22 16:37:11 -04:00
rhettlivingston
ab9afd33d1 Add allowImportExportEverywhere parserOption (babel/babel-eslint#327) (babel/babel-eslint#329)
* Add allowImportExportEverywhere parserOption (babel/babel-eslint#327)

* Added "allowImportExportEverywhere option (babel/babel-eslint#327)" test.
2016-06-22 16:36:47 -04:00
Henry Zhu
4d473c3305 6.0.5 2016-06-20 17:12:33 -04:00
Daniel Tschinder
93a9a8d638 Reset TypeParameters to Identifier (babel/babel-eslint#325) 2016-06-20 23:11:38 +02:00
Henry Zhu
c8fe9136d7 add a message about using the default parser (babel/babel-eslint#306)
* add a message about using the default parser

* decrease the size
2016-05-02 08:41:41 -04:00
Daniel Tschinder
97af2b0b62 Add regression test for babel/babel-eslint#223 (babel/babel-eslint#305) 2016-04-29 23:23:13 +02:00
Daniel Tschinder
81ce743986 Add node 6 to travis tests. 2016-04-29 23:22:40 +02:00
Daniel Tschinder
2b66040f0d Add tests for two issues and rename test suite (babel/babel-eslint#304) 2016-04-29 23:07:02 +02:00
Daniel Tschinder
872449d6fc Add configuration section to README (babel/babel-eslint#303) 2016-04-26 18:11:33 +02:00
Henry Zhu
a2f345b24b add changelog command 2016-04-25 18:00:58 -04:00
Henry Zhu
161edcca48 6.0.4 2016-04-25 17:55:19 -04:00
Rafał Ruciński
cfd35799da Fix parent not being set for decorator nodes. (babel/babel-eslint#296) 2016-04-25 23:51:43 +02:00
Daniel Tschinder
0ccbceb9e8 Ensure strictmode is enabled/disabled when changing sourceType (babel/babel-eslint#302) 2016-04-25 15:41:43 +02:00
Daniel Tschinder
cbc0475634 Update lodash and replace pick by pickBy (babel/babel-eslint#301) 2016-04-25 01:14:39 +02:00
Daniel Tschinder
cf456bfe4a Fix escope to take sourceType and ecmaVersion from options (babel/babel-eslint#288)
escope was hardcoded to sourcetype: "module" and ecmaVersion: "6"
This changes it to take the configuration from the eslint options and still
defaulting to "module" and "6".
This is done by having to global variables, as monkeypatch is only triggered once.
To fix scoping issues, the same logic as in eslint is applied. It disables the nodejs scope
if the sourceType is module.
2016-04-20 02:56:15 +02:00
Rafał Ruciński
fd36e3cf8d Declare eslint call more simply in the scripts. (babel/babel-eslint#297) 2016-04-20 02:55:24 +02:00
Rafał Ruciński
149dd082f3 Add root: true to eslint config. (babel/babel-eslint#294)
This prevents taking user's eslint config files that are higher in the
directory structure into consideration.
2016-04-18 04:01:15 +02:00
Rafał Ruciński
44ff360379 Make npm scripts work on Windows too. (babel/babel-eslint#295) 2016-04-18 03:59:08 +02:00
Henry Zhu
8a089b65fb 6.0.2 2016-03-31 19:14:07 -04:00
Henry Zhu
3c9ef8ec7e Merge pull request babel/babel-eslint#285 from josh/revert-282-no-implicit-globals-regression
Revert "Fix processing sourceType: script"
2016-03-31 19:09:30 -04:00
Henry Zhu
1fe0d4a94b Merge pull request babel/babel-eslint#282 from josh/no-implicit-globals-regression
Fix processing sourceType: script
2016-03-31 16:49:31 -04:00
Henry Zhu
cccce9d0ab update install instructions for eslint 1 and 2 2016-03-28 18:23:37 -04:00
Henry Zhu
c6401945d9 6.0.0 2016-03-25 23:51:29 -04:00
Henry Zhu
c6a69b763f 6.0.0-beta.6 2016-03-14 08:37:34 -04:00
Henry Zhu
080f0c7b22 Merge pull request babel/babel-eslint#273 from mysticatea/fix-monkeypatching-for-2.3.0
Fix: Remove throwing an error when estraverse-fb has not found.
2016-03-14 08:36:44 -04:00
Henry Zhu
2c6b323a62 6.0.0-beta.5 2016-03-08 11:06:58 -05:00
Henry Zhu
b42d59b29c errror on estraverse-fb.. 2016-03-08 11:06:47 -05:00
Henry Zhu
c8ff9bad93 6.0.0-beta.4 2016-03-08 11:04:19 -05:00
Henry Zhu
7fbf6111e3 just throw an error right now instead of it silently working but with bugs 2016-03-08 10:57:22 -05:00
Henry Zhu
d75bd7b82c 6.0.0-beta.3 2016-03-07 23:13:50 -05:00
Henry Zhu
217f83fd56 Merge pull request babel/babel-eslint#271 from danez/fix-use-before-define
Remove visiting of properties left of spread, fixes babel/babel-eslint#249.
2016-03-07 23:09:46 -05:00
Henry Zhu
6e3aa3357c Merge pull request babel/babel-eslint#272 from kaicataldo/fixes259
Update readme to fix npm registry escaped HTML (fixes babel/babel-eslint#259)
2016-03-07 23:09:33 -05:00
Henry Zhu
e886404171 6.0.0-beta.2 2016-03-07 12:34:10 -05:00
Henry Zhu
4a8c6d8a8b Merge pull request babel/babel-eslint#270 from danez/cleanup-monkey
remove monkey-patching of patternVisitor as unused
2016-03-07 08:31:48 -05:00
Henry Zhu
a827ab2d4e Merge pull request babel/babel-eslint#269 from babel/eslint-2.3.0
try catch estraverse-fb since eslint removed it in 2.3.0, temp skip b…
2016-03-06 22:29:51 -05:00
Henry Zhu
c3915b9798 6.0.0-beta.1 2016-03-01 22:39:34 -05:00
Henry Zhu
c28b839c17 Update README.md 2016-03-01 22:37:28 -05:00
Henry Zhu
511862c4ee Merge pull request babel/babel-eslint#264 from hzoo/eslint2
ESLint 2
2016-03-01 22:34:53 -05:00
Henry Zhu
dce22ce5f6 Merge pull request babel/babel-eslint#257 from gmaclennan/patch-1
Update README.md install docs for eslint v1.x
2016-02-27 10:23:01 -05:00
Henry Zhu
edc91849cb Update .travis.yml 2016-02-16 18:13:32 -05:00
Henry Zhu
f117721251 5.0.0 2016-02-16 18:06:37 -05:00
Henry Zhu
5df6babfad Update README.md 2016-02-16 17:43:05 -05:00
Henry Zhu
e4f43aa51b Merge pull request babel/babel-eslint#255 from deepsweet/npm-ignore
include only necessary files in npm package
2016-02-16 12:32:56 -05:00
Henry Zhu
05f708c330 Merge pull request babel/babel-eslint#250 from danez/patch-1
Testcase for babel/babel-eslint#239
2016-02-02 17:11:01 -05:00
Henry Zhu
8f9f800dc5 5.0.0-beta10 2016-02-01 23:06:09 -05:00
Henry Zhu
83debbfda0 Merge pull request babel/babel-eslint#246 from babel/escope-patterns
Prevent escope referencer from traversing into param pattern type annotations
2016-02-01 23:05:06 -05:00
Henry Zhu
c1bec5c4de check using __esModule 2016-02-01 20:22:03 -05:00
Henry Zhu
740a546249 5.0.0-beta9 2016-02-01 14:40:54 -05:00
Henry Zhu
a55236d383 Merge pull request babel/babel-eslint#244 from christophehurpeau/patch-1
fix babel/babel-eslint#243
2016-02-01 14:40:01 -05:00
Henry Zhu
e2464f462e 5.0.0-beta8 2016-01-30 12:20:15 -05:00
Henry Zhu
177c0b4979 Add a test for use strict and directive ast change
Fixes babel/babel-eslint#242
2016-01-30 12:19:44 -05:00
Henry Zhu
167741b80b 5.0.0-beta7 2016-01-30 10:37:21 -05:00
Henry Zhu
f083e49a63 Merge pull request babel/babel-eslint#241 from jmm/rule-strict
Add tests for `strict` rule
2016-01-30 10:34:38 -05:00
Henry Zhu
9380324a0f temporarily remove test 2016-01-30 10:32:47 -05:00
Henry Zhu
0778f623fb Merge pull request babel/babel-eslint#232 from vaibhavmule/patch-1
update Licenses date
2016-01-16 00:16:50 -05:00
Henry Zhu
1adc834b10 skip for now 2015-12-29 13:48:29 -05:00
Henry Zhu
c510fa79d0 add test for es6 unicode escapes 2015-12-29 13:44:12 -05:00
Henry Zhu
02d63b7ec4 5.0.0-beta6 2015-12-09 08:42:02 -05:00
Henry Zhu
c35137040a update acorn-to-esprima, account for getter/setter kind property 2015-12-09 08:40:27 -05:00
Henry Zhu
3b673ef4b6 5.0.0-beta5 2015-12-09 08:27:37 -05:00
Henry Zhu
318a530dfa update acorn-to-esprima, add getter/setter tests 2015-12-09 08:27:19 -05:00
Henry Zhu
fa7dfc272a update eslint 2015-12-01 09:58:43 -05:00
Henry Zhu
423683e7ef 5.0.0-beta4 2015-11-29 08:24:29 -05:00
Henry Zhu
c078e11bcf update acorn-to-esprima to 2.0.1 2015-11-29 08:24:10 -05:00
Henry Zhu
61e1c5b546 5.0.0-beta3 2015-11-28 16:31:24 -05:00
Henry Zhu
4249dcd353 update acorn-to-esprima, add tests for babel/babel-eslint#216 2015-11-28 16:31:13 -05:00
Henry Zhu
f76be581b3 5.0.0-beta2 2015-11-27 15:45:09 -05:00
Henry Zhu
faa003168c add functionSent to parser 2015-11-27 15:44:07 -05:00
Henry Zhu
204ba86418 Merge pull request babel/babel-eslint#215 from zertosh/master
babylon/espree option alignment
2015-11-27 15:42:16 -05:00
Henry Zhu
c435628b6a 5.0.0-beta1 2015-11-26 14:46:42 -05:00
Henry Zhu
72e8f9d969 Merge pull request babel/babel-eslint#202 from hzoo/babel6
Update to babel 6
2015-11-26 14:44:37 -05:00
Henry Zhu
27c9abfae5 4.1.6 2015-11-23 21:19:53 -05:00
Henry Zhu
78361c1518 skip for now 2015-11-23 21:19:08 -05:00
Henry Zhu
12dd87f96b add node 5 2015-11-23 20:38:48 -05:00
Henry Zhu
2ddb2d4c89 test for no-redeclare 2015-11-23 20:37:44 -05:00
Henry Zhu
3d901f5960 Merge pull request babel/babel-eslint#212 from evocateur/fix-with-latest-eslint
Avoid errors with eslint 1.10.x when excluding destructured properties
2015-11-23 20:33:39 -05:00
Henry Zhu
0859607b4e Merge pull request babel/babel-eslint#209 from Constellation/pattern-visitor
Patch SpreadProperty to escope's PatternVisitor
2015-11-23 13:34:48 -05:00
Henry Zhu
5352ad41c5 mention eslint-plugin-flow-vars for flow issues 2015-11-15 20:59:48 -05:00
Henry Zhu
8f9cc6b827 4.1.5 2015-11-09 21:11:56 -05:00
Henry Zhu
a294ab4545 Merge pull request babel/babel-eslint#206 from mysticatea/fix-for-eslint-1.9
Fix for ESLint@1.9 and npm@3
2015-11-09 21:04:45 -05:00
Henry Zhu
d08053d483 4.1.4 2015-11-04 09:51:00 -05:00
Henry Zhu
677d42f7ad update eslint, acorn-to-esprima 2015-11-01 10:10:08 -05:00
Henry Zhu
b4fb1d3aca test with ecmaFeatures on by default, add test for babel/babel-eslint#192
Ref babel/babel-eslint#192
2015-10-07 20:23:41 -04:00
Henry Zhu
dd8ba490ee update readme, add contributing 2015-10-07 20:11:00 -04:00
Henry Zhu
afd72ba541 update packages 2015-10-07 20:05:11 -04:00
Henry Zhu
463cda9a10 4.1.3 2015-09-17 09:42:26 -04:00
Henry Zhu
b5e0dbe8e8 check AssignmentPattern types - fixes babel/babel-eslint#184 2015-09-17 09:42:18 -04:00
Henry Zhu
6dc026c203 un-comment babel/babel-eslint#124 test 2015-09-15 09:20:14 -04:00
Henry Zhu
cc4ce5bbed add node 4 to travis 2015-09-14 14:48:14 -04:00
Henry Zhu
95c4c77df1 4.1.2 2015-09-14 14:45:10 -04:00
Henry Zhu
c0a7ebf51b fix attachComment typo, add comment tests 2015-09-14 14:26:21 -04:00
Henry Zhu
742b1cb65d Merge pull request babel/babel-eslint#182 from bryanrsmith/patch-1
fix typo in comment
2015-09-11 18:38:53 -04:00
Henry Zhu
229a1922d8 4.1.1 2015-08-31 10:23:10 -04:00
Henry Zhu
2b17528c5d Merge pull request babel/babel-eslint#180 from hzoo/master
update eslint, acorn-to-esprima - ref eslint/eslint#3596
2015-08-31 10:22:52 -04:00
Henry Zhu
61243967ac 4.1.0 2015-08-25 12:14:17 -04:00
Henry Zhu
4cdf59532d Merge pull request babel/babel-eslint#177 from hzoo/use-acorn-to-esprima
use `acorn-to-esprima` package
2015-08-25 12:11:24 -04:00
Henry Zhu
b2405a9924 lint fix, lint task 2015-08-20 15:07:05 -04:00
Henry Zhu
8812bf735e update espree, update eslintester for eslint 1.0 2015-08-20 15:04:30 -04:00
Henry Zhu
ac163a64fe do not use local 2015-08-20 14:41:06 -04:00
Henry Zhu
412aee0be0 update eslint to 1.2.0 2015-08-20 14:39:37 -04:00
Henry Zhu
fea7ef937e remove note about babel-eslint being experimental 2015-08-19 09:46:50 -04:00
Henry Zhu
03492bae52 4.0.10 2015-08-16 22:49:15 -04:00
Henry Zhu
e8c6b4e988 Merge pull request babel/babel-eslint#165 from hzoo/remove-spread-transform
use SpreadProperty type, revert other transforms
2015-08-16 22:48:56 -04:00
Henry Zhu
8d46c00125 4.0.9 2015-08-16 22:33:38 -04:00
Henry Zhu
2140a08e3e Merge pull request babel/babel-eslint#170 from hzoo/remove-super-transform
remove super transform since it should be in espree
2015-08-16 21:54:01 -04:00
Henry Zhu
d06c003344 4.0.8 2015-08-16 16:12:18 -04:00
Henry Zhu
9740af8be4 Merge pull request babel/babel-eslint#169 from hzoo/i-168
async func and space-before-function-paren
2015-08-16 16:11:57 -04:00
Henry Zhu
5b57763788 4.0.7 2015-08-15 19:49:44 -04:00
Henry Zhu
69c303ea00 Merge pull request babel/babel-eslint#166 from hzoo/remove-async-transform
remove async func transform
2015-08-15 19:49:21 -04:00
Henry Zhu
7d8de4e2ae 4.0.6 2015-08-15 09:25:14 -04:00
Henry Zhu
cd0f5ccc93 add older tests 2015-08-15 09:24:14 -04:00
Henry Zhu
6476a8d916 Merge pull request babel/babel-eslint#164 from hzoo/remove-rest-transform
Remove rest transform
2015-08-15 08:48:41 -04:00
Henry Zhu
839c5ed577 use --follow-tags 2015-08-14 22:00:25 -04:00
Henry Zhu
21294eb228 update to eslint@1.1.0 2015-08-14 22:00:10 -04:00
Henry Zhu
71ab33eff4 update to eslint 1.0.0, fix tests 2015-08-03 10:57:06 -04:00
Sebastian McKenzie
4255c0f812 4.0.5 2015-07-27 04:20:26 +01:00
Sebastian McKenzie
436716fdd7 update babel-core to 5.6.9 2015-07-27 04:20:19 +01:00
Sebastian McKenzie
f79577a7ec add Makefile 2015-07-27 04:07:19 +01:00
Sebastian McKenzie
18b029ca88 4.0.4 2015-07-27 04:04:37 +01:00
Sebastian McKenzie
2c868efbad fix range generation for template tokens - fixes babel/babel-eslint#156 2015-07-27 04:04:30 +01:00
Sebastian McKenzie
39e9fc9e40 4.0.3 2015-07-27 02:58:45 +01:00
Sebastian McKenzie
19e2f1bb33 use start/end rather than directly using range in attachComments 2015-07-27 02:58:37 +01:00
Sebastian McKenzie
af51b545ba 4.0.2 2015-07-27 02:44:56 +01:00
Sebastian McKenzie
582cf6cc8a add missing ranges 2015-07-27 02:44:49 +01:00
Sebastian McKenzie
06ccbca763 4.0.1 2015-07-27 02:21:29 +01:00
Sebastian McKenzie
56a27a0647 add range property - fixes babel/babel-eslint#155 2015-07-27 02:21:18 +01:00
Henry Zhu
4437132372 4.0.0 2015-07-25 11:08:25 -04:00
Henry Zhu
c5bbf91892 Merge pull request babel/babel-eslint#152 from bgw/line-x
Replace 'Line X' with actual line number
2015-07-25 11:08:08 -04:00
Henry Zhu
d4318aa0d8 Merge pull request babel/babel-eslint#128 from hzoo/i-124
add tests - for babel/babel-eslint#124
2015-07-25 11:00:42 -04:00
Henry Zhu
80888a1b23 3.1.27 2015-07-25 10:53:17 -04:00
Henry Zhu
8d65e3e894 Merge pull request babel/babel-eslint#154 from alexkuz/master
fix visiting filter in comprehension
2015-07-25 10:08:31 -04:00
Henry Zhu
bb29041dce 3.1.26 2015-07-22 01:35:33 -04:00
Henry Zhu
9c452f5b14 remove estraverse attach comments method, fix up tests 2015-07-22 00:36:03 -04:00
Henry Zhu
2bb5101112 add test for babel/babel-eslint#149 2015-07-21 23:57:13 -04:00
Sebastian McKenzie
ec9a75173b 3.1.25 2015-07-22 01:19:45 +01:00
Sebastian McKenzie
c551545f29 filter comment tokens - fixes babel/babel-eslint#153 2015-07-22 01:19:23 +01:00
Sebastian McKenzie
8baea68c6c 3.1.24 2015-07-21 22:34:24 +01:00
Sebastian McKenzie
e7aecdce71 convert comment node types from babel to espree - ref facebook/react#4449 2015-07-21 22:34:14 +01:00
Henry Zhu
61555c6ebd fix typo: attachComment -> attachComments 2015-07-10 18:37:45 -04:00
Henry Zhu
efef3af7b8 update readme - separate channel/signup, categorize known issues better 2015-07-09 13:11:14 -04:00
Henry Zhu
39fa1c4ac2 3.1.23 2015-07-06 10:40:56 -04:00
Henry Zhu
05f5cc3ea8 Merge pull request babel/babel-eslint#146 from hzoo/i-142-2
use node.babelType for SpreadProperty
2015-07-06 10:40:11 -04:00
Henry Zhu
f57dde1ac3 3.1.22 2015-07-06 09:38:11 -04:00
Henry Zhu
d9bf8d252e fix no-unused-vars issue with spread
Use a private _spread property on Property node instead of SpreadProperty

Fixes https://github.com/babel/babel-eslint/issues/142#issuecomment-118707124
2015-07-06 09:36:34 -04:00
Henry Zhu
8c4adbf98d 3.1.21 2015-07-05 22:08:19 -04:00
Henry Zhu
4e884f439e Merge pull request babel/babel-eslint#143 from hzoo/i-142
only visit properties in object destructuring when there is a SpreadP…
2015-07-05 22:06:15 -04:00
Henry Zhu
78a7af3c0a add known issue for babel/babel-eslint#130 - no-undef for global flow types 2015-07-01 11:38:00 -04:00
Henry Zhu
b26b8efca4 add known issue for babel/babel-eslint#136 2015-07-01 11:27:42 -04:00
Henry Zhu
0de11015cc update devDep eslint@0.24.0 2015-06-29 14:19:06 -04:00
Henry Zhu
6b05576d99 3.1.20 2015-06-29 13:51:50 -04:00
Henry Zhu
dee7261bbe Merge pull request babel/babel-eslint#140 from hzoo/i-138
create scope for each comprehension - fixes babel/babel-eslint#138
2015-06-29 13:48:19 -04:00
Sebastian McKenzie
1502bf6a2d 3.1.19 2015-06-26 15:06:21 +01:00
Sebastian McKenzie
e72e79694f attempt to resolve estraverse relative to esrecurse if found - this is necessary because of the tree flattening in npm 3 2015-06-26 15:06:18 +01:00
Henry Zhu
b05ae77e41 3.1.18 2015-06-23 18:32:44 -04:00
Henry Zhu
7ff5dd56e8 Merge pull request babel/babel-eslint#135 from PiPeep/fix-jest
Fix eslint module path resolution in jest
2015-06-23 18:32:09 -04:00
Henry Zhu
c22414c1fd fix tests after updating babel 2015-06-22 17:00:31 -04:00
Henry Zhu
96a9af0a06 update eslint, update tests 2015-06-22 16:48:51 -04:00
Henry Zhu
cec51daa04 add message about using eslint-plugin-babel 2015-06-18 21:22:59 -04:00
Henry Zhu
c3b0bb21e9 3.1.17 2015-06-17 20:32:16 -04:00
Henry Zhu
cf57c817cb Known Issues: add flow declarations with 'no-unused-vars' 2015-06-17 20:31:58 -04:00
Henry Zhu
0de733b66a flow: create var declaration for flow declarations 2015-06-17 09:18:51 -04:00
Henry Zhu
d16f726b15 3.1.16 2015-06-17 07:18:47 -04:00
Henry Zhu
d224153cba Merge pull request babel/babel-eslint#133 from hzoo/i-132
support flow declarations correctly, lint - fixes babel/babel-eslint#132
2015-06-17 07:17:26 -04:00
Henry Zhu
da3d4bf537 Known Issue: object-shorthand with spread operator 2015-06-15 20:25:44 -04:00
Henry Zhu
0c47ebe881 fix build.. 2015-06-10 17:11:21 -04:00
Henry Zhu
eaec0f1595 remove uneeded param 2015-06-10 17:07:53 -04:00
Henry Zhu
d5e2ac1fb6 3.1.15 2015-06-09 15:01:13 -04:00
Henry Zhu
1c25c8eed3 Merge pull request babel/babel-eslint#126 from leebyron/fix-flow-type
Fixes flow type scoping issues - fixes babel/babel-eslint#123
2015-06-09 15:00:38 -04:00
Henry Zhu
d83aa7f6ce clarify known eslint issues, add to link slack channel for questions 2015-06-08 09:41:12 -04:00
Henry Zhu
4ba3178d8e Merge pull request babel/babel-eslint#116 from hzoo/eslint-tests
Add eslint submodule to run eslint tests - Ref babel/babel-eslint#62
2015-06-08 09:37:55 -04:00
Henry Zhu
5d23153aed 3.1.14 2015-06-06 16:55:00 -04:00
Henry Zhu
adc009b832 Merge pull request babel/babel-eslint#122 from hzoo/i-95
visit properties in ObjectPattern - fixes babel/babel-eslint#95
2015-06-06 16:54:05 -04:00
Henry Zhu
c15a7c6b65 lint: fix quotes, rule 2015-06-06 09:21:23 -04:00
Henry Zhu
face6ff6af add lint config from babel, lint 2015-06-06 09:14:24 -04:00
Henry Zhu
c38ea387e5 3.1.13 2015-06-05 05:29:59 -04:00
Henry Zhu
84a8d342f2 Merge pull request babel/babel-eslint#121 from hzoo/i-120
don't visit var decl - fixes babel/babel-eslint#120
2015-06-05 05:24:20 -04:00
Sebastian McKenzie
8d3a7244c3 3.1.12 2015-06-05 10:00:26 +01:00
Sebastian McKenzie
b10c9b0357 update to babel 5.5.1 2015-06-05 10:00:15 +01:00
Henry Zhu
6bcdfb11cc 3.1.11 2015-06-03 17:13:06 -04:00
Henry Zhu
6a2938deaa Merge pull request babel/babel-eslint#118 from hzoo/poly-types
add flow exceptions for polymorphic types (<A>) - Ref babel/babel-eslint#109
2015-06-03 17:11:28 -04:00
Henry Zhu
ade0b3b21b Merge pull request babel/babel-eslint#114 from hzoo/i-9
support comprehensions (no-undef) - fixes babel/babel-eslint#9
2015-06-03 17:06:42 -04:00
Henry Zhu
e6ba27075e 3.1.10 2015-06-01 21:18:54 -04:00
Henry Zhu
a4f6edab85 Merge pull request babel/babel-eslint#109 from hzoo/i-108
visit flow types - fixes babel/babel-eslint#108
2015-06-01 21:16:02 -04:00
Henry Zhu
866a77a8cc Merge pull request babel/babel-eslint#117 from hzoo/eslint-0.22.1
update to eslint@0.22.1
2015-06-01 21:14:33 -04:00
Sebastian McKenzie
b95ea1092e 3.1.9 2015-05-25 05:48:21 +01:00
Sebastian McKenzie
7f0ce79fae Merge pull request babel/babel-eslint#113 from babel/paths
Use Path-based introspection methods rather than node-based
2015-05-25 05:48:08 +01:00
Henry Zhu
813ede0cd5 3.1.8 2015-05-22 21:05:00 -04:00
Henry Zhu
b845304ce2 update readme about issues/jsx 2015-05-22 21:04:00 -04:00
Henry Zhu
9cc077638a add all espree ecmaFeatures, fixes babel/babel-eslint#31 again 2015-05-21 07:46:01 -04:00
Henry Zhu
573020678a 3.1.7 2015-05-21 06:51:52 -04:00
Henry Zhu
48c23ad8ef remove from dependency (update devDependency 2015-05-21 06:51:17 -04:00
Henry Zhu
1230588b98 3.1.6 2015-05-20 19:06:06 -04:00
Henry Zhu
0e50a0b6e0 Merge pull request babel/babel-eslint#105 from hzoo/visit-decorators
patch escope to visit decorators - fixes babel/babel-eslint#72
2015-05-20 19:03:56 -04:00
Henry Zhu
80114dda35 Merge pull request babel/babel-eslint#107 from hzoo/update-eslint
eslint@0.21.2
2015-05-20 18:14:18 -04:00
Henry Zhu
a5f9a8fea0 3.1.5 2015-05-17 17:13:40 -04:00
Henry Zhu
7fa06fa566 add test for babel/babel-eslint#66 2015-05-16 23:26:48 -04:00
Henry Zhu
47a771a7b1 Merge pull request babel/babel-eslint#100 from babel/es7.functionBind
add ES7 function bind (::) as Punctuator
2015-05-16 23:23:28 -04:00
Henry Zhu
82f3fe4147 Merge pull request babel/babel-eslint#101 from hzoo/more-jsx
add JSXText type, more tests
2015-05-16 23:22:53 -04:00
Sebastian McKenzie
54adf244dd 3.1.4 2015-05-16 23:17:12 +01:00
Sebastian McKenzie
b699e4f2aa add support for type cast expressions - fixes babel/babel-eslint#102 2015-05-16 23:17:03 +01:00
Sebastian McKenzie
5ba504f809 3.1.3 2015-05-15 20:55:56 +01:00
Henry Zhu
730f2528dc Merge pull request babel/babel-eslint#97 from hzoo/fix-templates
fix template type issues
2015-05-15 14:42:28 -04:00
Sebastian McKenzie
9731e496c8 3.1.2 2015-05-14 21:39:13 +01:00
Sebastian McKenzie
d84fc559f2 Merge pull request babel/babel-eslint#94 from hzoo/support-templates
support template strings - Fixes babel/babel-eslint#31
2015-05-14 21:38:56 +01:00
Sebastian McKenzie
527287aa29 Merge pull request babel/babel-eslint#93 from hzoo/tokenTypes
add tokenTypes: Null, Boolean, RegularExpression
2015-05-13 00:27:19 +01:00
Sebastian McKenzie
758e8d40e5 Merge pull request babel/babel-eslint#90 from hzoo/morePunctuatorTypes
change more tokentypes to be punctuator - fixes babel/babel-eslint#59
2015-05-11 08:15:41 +01:00
Sebastian McKenzie
0f13e5708b 3.1.1 2015-05-07 13:49:05 +01:00
Sebastian McKenzie
77c5b0f3b7 Merge pull request babel/babel-eslint#86 from hzoo/patchestraverse-fb
also patch estraverse-fb - fixes babel/babel-eslint#73
2015-05-07 13:48:32 +01:00
Sebastian McKenzie
e571aec2ff 3.1.0 2015-05-06 17:19:48 +01:00
Sebastian McKenzie
46f65bcf49 Merge pull request babel/babel-eslint#76 from Cellule/attach_comments
Attach comments to ast using estraverse
2015-05-06 17:19:30 +01:00
Sebastian McKenzie
47c1673092 remove flow types and class property keys 2015-04-13 18:05:58 -07:00
Sebastian McKenzie
d301c8e099 upgrade to babel 5.1.8 2015-04-13 17:12:08 -07:00
Sebastian McKenzie
729cedc925 Merge branch 'master' of github.com:babel/babel-eslint 2015-04-08 22:07:28 -07:00
Sebastian McKenzie
4a531aaba4 port to babel 5.0.0 2015-04-08 22:07:21 -07:00
Sebastian McKenzie
ded2e420b1 bump version 2015-03-16 12:49:43 +11:00
Sebastian McKenzie
b9ae556f9f add sourceType property 2015-03-16 12:49:38 +11:00
Sebastian McKenzie
ce91f1869b Merge pull request babel/babel-eslint#50 from UltCombo/fix-48
acorn-to-esprima: fix ExportNamedDeclaration, closes babel/babel-eslint#48
2015-03-16 12:42:57 +11:00
Sebastian McKenzie
0d0cc6bb83 Merge pull request babel/babel-eslint#44 from Globegitter/patch-1
Added global flag to install command
2015-03-11 21:35:12 +11:00
Sebastian McKenzie
665f0d6002 upgrade babel-core to 4.7.8 2015-03-11 01:15:32 +11:00
Sebastian McKenzie
fcb367666d add class usage non regression test 2015-03-11 01:15:15 +11:00
Sebastian McKenzie
cbe8c84ec1 add messages to non regression test output 2015-03-11 00:40:11 +11:00
Sebastian McKenzie
3fced333e8 bump to 2.0.0 2015-03-11 00:40:00 +11:00
Sebastian McKenzie
6762396aec fix module conversion 2015-03-11 00:35:00 +11:00
Sebastian McKenzie
7625971974 Merge branch 'master' of github.com:babel/babel-eslint 2015-03-11 00:17:22 +11:00
Sebastian McKenzie
24eef21756 convert playground assignment operators - fixes babel/babel-eslint#40 2015-03-11 00:15:07 +11:00
Sebastian McKenzie
64b63e44bf update to babel-core and eslint 0.16 2015-03-11 00:13:34 +11:00
Sebastian McKenzie
47e3808aa4 update to eslint 0.16, remove certain mangling 2015-03-10 18:18:35 +11:00
Sebastian McKenzie
78ca83eb6f 1.0.14 2015-03-09 02:46:17 +11:00
Sebastian McKenzie
6556b06f23 Merge branch 'master' of github.com:babel/babel-eslint 2015-03-09 02:45:56 +11:00
Sebastian McKenzie
a31835836d bump version 2015-03-04 22:29:49 +11:00
Sebastian McKenzie
71a5782ab7 make spread properties computed - fixes babel/babel-eslint#16 2015-03-02 12:31:08 +11:00
Sebastian McKenzie
9a77a7dbaa ensure function expression body is a block statement - fixes babel/babel-eslint#20 2015-03-02 12:25:08 +11:00
Sebastian McKenzie
955dd1e126 turn async functions into generators - fixes babel/babel-eslint#22 2015-03-02 12:04:59 +11:00
Sebastian McKenzie
02f4f5e885 turn super references into a this expression - fixes babel/babel-eslint#10 2015-02-28 17:37:12 +11:00
Sebastian McKenzie
e08a0fab99 Merge branch 'master' of github.com:babel/babel-eslint 2015-02-28 17:07:28 +11:00
Sebastian McKenzie
e4cee14aa6 better XJSIdentifier -> Identifier logic - fixes babel/babel-eslint#12 2015-02-28 17:07:11 +11:00
Sebastian McKenzie
0f1910891d explode all rest elements - fixes babel/babel-eslint#11 2015-02-28 16:33:21 +11:00
Sebastian McKenzie
1cc579cb5d move up explantory paragraph 2015-02-28 12:09:20 +11:00
Sebastian McKenzie
e891659b21 bump version 2015-02-28 12:07:33 +11:00
Sebastian McKenzie
bde03060a5 remove ClassDeclaration transformation 2015-02-28 12:07:21 +11:00
Sebastian McKenzie
24aa904d99 add how does it work section to readme 2015-02-28 12:03:01 +11:00
Sebastian McKenzie
5b2df4ce30 bump version 2015-02-28 11:59:26 +11:00
Sebastian McKenzie
1ca488c3ec turn class declarations into variable declarations - fixes babel/babel-eslint#8 2015-02-28 11:58:56 +11:00
Sebastian McKenzie
9117398452 bump version 2015-02-28 11:50:44 +11:00
Sebastian McKenzie
1d1d7a5145 transform JSX identifiers and member expressions - fixes babel/babel-eslint#5 2015-02-28 11:31:54 +11:00
Sebastian McKenzie
a14e1e8fd1 clean up toAst method and properly transform rest elements away - fixes babel/babel-eslint#7 2015-02-28 11:28:22 +11:00
Sebastian McKenzie
932d799e28 pop off last token which will be an EOF, currently not used anywhere by espree and it runs into issues with some rules - fixes babel/babel-eslint#2 2015-02-27 23:40:59 +11:00
Sebastian McKenzie
be9da7ef08 output esprima compatible error messages - fixes babel/babel-eslint#3 2015-02-27 23:23:15 +11:00
Sebastian McKenzie
65a6fce75c turn ArrowFunctionExpression into a FunctionExpression - fixes babel/babel-eslint#1 2015-02-27 23:06:47 +11:00
Sebastian McKenzie
041c7e246f add support for spread property 2015-02-27 22:40:56 +11:00
Sebastian McKenzie
5c226d0451 add more comments to acorn-to-esprima source 2015-02-27 21:57:03 +11:00
Sebastian McKenzie
d70e358a94 clean up readme 2015-02-27 21:49:54 +11:00
Sebastian McKenzie
5d5c7c6ae1 first commit 2015-02-27 21:44:06 +11:00
Daniel Tschinder
b0fcf28267 9.0.0 2019-02-10 14:19:02 -08:00
Daniel Tschinder
3a5d6ee433 Update peer dependencies and allow babel-eslint 11 2019-02-10 14:17:27 -08:00
Brian Ng
7c39f9477f 8.0.2 2018-11-21 09:10:50 -06:00
Brian Ng
0076d85f5d Relax eslint-plugin-flowtype peerDep 2018-11-21 09:04:12 -06:00
Brian Ng
ad2ca8dd4b Merge tag 'v8.0.1'
8.0.1
2018-11-21 09:09:28 -06:00
Brian Ng
a3230ce730 Merge pull request babel/eslint-config-babel#29 from babel/babel-eslint 2018-09-25 16:24:38 -05:00
Brian Ng
e13c2f535c 8.0.0 2018-09-11 11:20:13 -05:00
Brian Ng
7499b0cab0 Merge pull request babel/eslint-config-babel#20 from babel/existentialism-patch-1 2018-09-11 10:28:37 -05:00
Brian Ng
74d47288c0 Merge pull request babel/eslint-config-babel#28 from babel/b 2018-09-11 10:28:24 -05:00
Henry Zhu
a47d722c07 7.0.2 2017-08-07 19:59:01 -04:00
Brian Ng
85d858984b Update babel-eslint peer dep (babel/eslint-config-babel#25) 2017-08-07 18:58:40 -05:00
Henry Zhu
794e8b12eb 7.0.1 2017-06-17 14:53:43 -04:00
Brian Ng
288a74e55f Re-add es6 env option (babel/eslint-config-babel#24) 2017-06-17 13:53:32 -05:00
Henry Zhu
4b35717b04 7.0.0 2017-06-17 14:35:27 -04:00
Brian Ng
a2f678151d Breaking: Drop style rules (babel/eslint-config-babel#22)
* Drop style rules

* es tweaks

* fix

* Update index.js
2017-06-17 13:35:03 -05:00
Daniel Tschinder
8a527d1ef5 Enable comma-dangle (babel/eslint-config-babel#19) 2017-02-20 17:45:06 +01:00
Daniel Tschinder
1ce807d5de Enable key-spacing and no-multi-spaces (babel/eslint-config-babel#18)
Fixes babel/eslint-config-babel#16
2017-02-20 17:14:45 +01:00
Daniel Tschinder
773c340514 Add func-call-spacing rule (babel/eslint-config-babel#15) 2017-02-20 16:59:50 +01:00
Henry Zhu
50122b7078 6.0.0 2017-01-14 16:01:07 -05:00
Daniel Tschinder
3bbc507a3f Add object-curly-spacing rule (babel/eslint-config-babel#14)
Fixes babel/eslint-config-babel#12
2017-01-14 22:00:42 +01:00
Henry Zhu
cada67daeb 5.0.0 2017-01-14 07:54:17 -05:00
Daniel Tschinder
af4dcb616d better indent switch, iife, multiline functions (babel/eslint-config-babel#10) 2017-01-14 13:51:41 +01:00
Daniel Tschinder
d4a1e97249 Add comma-spacing rule (babel/eslint-config-babel#11) 2017-01-14 13:51:22 +01:00
Kai Cataldo
292003444d peerDeps: remove eslint-plugin-babel (babel/eslint-config-babel#13) 2017-01-14 07:51:07 -05:00
Henry Zhu
d9b467403a 4.0.1 2017-01-10 12:27:01 -05:00
Henry Zhu
ff304c3890 fix 2017-01-10 12:26:45 -05:00
Henry Zhu
42ad818e3f 4.0.0 2017-01-08 22:19:51 -05:00
Henry Zhu
6117b83b55 Merge pull request babel/eslint-config-babel#9 from kaicataldo/prefer-const
Enable prefer-const
2017-01-08 22:19:01 -05:00
Henry Zhu
1f4e239217 3.0.0 2016-11-17 18:03:35 -05:00
Henry Zhu
4819beb149 use builtin (babel/eslint-config-babel#8)
* use built-in

* Update package.json
2016-11-17 18:03:01 -05:00
Henry Zhu
9279489413 2.0.1 2016-10-05 16:36:03 -04:00
Dan Harper
1536dfda0a flowtype plugin (babel/eslint-config-babel#6) 2016-10-05 21:35:44 +01:00
Henry Zhu
b2b1416fbc 2.0.0 2016-10-05 16:32:27 -04:00
Henry Zhu
c3bc500240 update info/links 2016-10-05 16:32:19 -04:00
Daniel Tschinder
0f87764827 Ensure unix line endings (babel/eslint-config-babel#4) 2016-10-01 18:12:35 +02:00
Daniel Tschinder
978f3392c5 Do not allow trailing spaces (babel/eslint-config-babel#3) 2016-10-01 18:12:29 +02:00
Henry Zhu
c88f903374 readme [skip ci] 2016-09-24 02:10:40 -04:00
Daniel Tschinder
edcf1b59dd Exchange flow plugin with new one (babel/eslint-config-babel#2)
* Change to eslint-plugin-flowtype

* Use new plugin

* Make dependencies peerDependencies

* Readd babel-eslint
2016-09-24 08:09:47 +02:00
Henry Zhu
b95c7aa556 1.0.2 2016-09-02 18:49:34 -04:00
Bo Borgerson
bfa69bbdb6 Add the "space-infix-ops" rule (babel/eslint-config-babel#1)
Require whitespace around infix operators.

The babel code base already mostly satisfies this.  Nice to keep it that way.

This is used by Lerna, too.
2016-09-02 15:48:46 -07:00
Henry Zhu
5706f0531b 1.0.1 2016-06-29 17:33:34 -04:00
Henry Zhu
a48f2e209c fix bug with config, use other way of specifying severity 2016-06-29 17:33:26 -04:00
Henry Zhu
13feb7278e init 2016-06-29 16:40:35 -04:00
Kai Cataldo
15b0283650 2019-11-13 19:40:27 -05:00
Huáng Jùnliàng
e1839e5ec9 Circumvent typeof transform for umd build template (#10701)
* add test case

* fix: circumvent typeof transform

* chore: update test fixtures
2019-11-13 22:47:56 +01:00
Jaideep Bhoosreddy
433b6ba3a4 Ignore PR job on master branch (#10702) 2019-11-13 21:42:44 +01:00
ZYSzys
1d1101eb7c Add missing flow type to babel-cli for consistency (#10692) 2019-11-13 17:39:19 +01:00
Jaideep Bhoosreddy
67ea7f4b4d Implement PR workflow for running test262 on babel PRs (#10579)
* Implement PR workflow with test262

* revisions
2019-11-13 17:31:29 +01:00
Huáng Jùnliàng
7633f09479 Babel should not silently remove unknown options after command… (#10698)
* chore: add test case

* chore: bump commander to 4.0.1

* fix: let commander.js throw on unknown options after args
2019-11-13 00:25:24 +01:00
Huáng Jùnliàng
ce070ce422 bump @babel/* dev dependencies (#10648)
* bump @babel/* dev dependencies

* chore: align version to @babel/runtime

* chore: bump to 7.7.1

* chore: bump to 7.7.2
2019-11-13 00:05:38 +01:00
Nicolò Ribaudo
f71338baf9
E2E test Babel with itself before publishing (#10569)
* Add e2e test using Babel itself

* Make checks run again
2019-11-12 23:55:36 +01:00
Shriram Balaji
ecad667dda Fix optional method chaining in derived classes (#10694) 2019-11-12 10:28:40 -06:00
4geru koichi uchinishi
d9fd07929a chore: add missing new line to fixture (#10697) 2019-11-12 11:08:35 -05:00
Huáng Jùnliàng
d413a3078c Add asserts this [is type] parsing support (#10677) 2019-11-11 16:36:10 -06:00
Sakibul Mowla
4cb5e0a013 Allow TypeScript type assertions in array destructuring (#10592)
* Add test

* Add fix

* Fix test, destructure with as assertion

* Add angle-bracket assertion case

* Use isBinding to make typeCastToParameter decision
2019-11-11 22:38:13 +01:00
Benjamin Blackwood
b2767c7d8a Add funding field to package.json (#10687) [ci-skip] 2019-11-11 08:08:18 -05:00
1665 changed files with 47866 additions and 12668 deletions

View File

@ -1,4 +1,5 @@
version: 2 version: 2.1
aliases: aliases:
- &restore-node-modules-cache - &restore-node-modules-cache
keys: keys:
@ -39,50 +40,57 @@ aliases:
- &artifact_test262_xunit - &artifact_test262_xunit
path: ~/test-results path: ~/test-results
jobs: - &artifact_test262_diff_tap
test: path: ~/diff.tap
working_directory: ~/babel
executors:
node-executor:
docker: docker:
- image: circleci/node:13 - image: circleci/node:13
working_directory: ~/babel
# e2e-vue-cli test requires chromium
node-browsers-executor:
docker:
- image: circleci/node:13-browsers
working_directory: ~/babel
jobs:
build-standalone:
executor: node-executor
steps: steps:
- checkout - checkout
- restore-cache: *restore-yarn-cache - restore_cache: *restore-yarn-cache
- restore-cache: *restore-node-modules-cache - restore_cache: *restore-node-modules-cache
- run: yarn --version # Builds babel-standalone with the regular Babel config
- run: make test-ci-coverage # test-ci-coverage doesn't test babel-standalone, as trying to gather coverage
# Builds babel-standalone with the regular Babel config - run: IS_PUBLISH=true make -j build-standalone-ci
- run: IS_PUBLISH=true make build # data for a JS file that's several megabytes large is bound to fail. Here,
# test-ci-coverage doesn't test babel-standalone, as trying to gather coverage # we just run the babel-standalone test separately.
# data for a JS file that's several megabytes large is bound to fail. Here, - run: yarn jest "\-standalone/test"
# we just run the babel-standalone test separately.
- run: ./node_modules/.bin/jest packages/babel-standalone/test/
- run: ./node_modules/.bin/jest packages/babel-preset-env-standalone/test/
- store_artifacts: *artifact_babel - store_artifacts: *artifact_babel
- store_artifacts: *artifact_babel_min - store_artifacts: *artifact_babel_min
- store_artifacts: *artifact_env - store_artifacts: *artifact_env
- store_artifacts: *artifact_env_min - store_artifacts: *artifact_env_min
- save_cache: *save-node-modules-cache - save_cache: *save-node-modules-cache
- save_cache: *save-yarn-cache - save_cache: *save-yarn-cache
test262: test262:
working_directory: ~/babel executor: node-executor
docker:
- image: circleci/node:12
steps: steps:
- checkout - checkout
- restore-cache: *restore-yarn-cache - run:
- restore-cache: *restore-node-modules-cache name: Sync with latest master branch (only on PRs)
command: |
if [ -n "$CIRCLE_PULL_REQUEST" ]
then
git fetch origin refs/pull/$CIRCLE_PR_NUMBER/merge
git checkout -qf FETCH_HEAD
fi
- restore_cache: *restore-yarn-cache
- restore_cache: *restore-node-modules-cache
- run: - run:
name: Build Babel name: Build Babel
command: BABEL_ENV=test make bootstrap command: BABEL_ENV=test make bootstrap
- run:
name: Link Babel
command: |
cd packages
for package in */; do
cd $package
yarn link
cd ..
done
- run: - run:
name: Setup Test Runner name: Setup Test Runner
command: | command: |
@ -90,32 +98,111 @@ jobs:
cd babel-test262-runner cd babel-test262-runner
yarn yarn
yarn add tap-mocha-reporter --dev yarn add tap-mocha-reporter --dev
curl -L https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64 > jq
chmod +x ./jq
for package in ../packages/*/package.json; do
yarn link $(./jq -j ".name" $package)
done
node lib/download-node node lib/download-node
- run:
name: Download master branch Test262 artifact
command: node lib/download-master-artifact ~/master.tap
<<: *test262_workdir
- run: - run:
name: Run Test262 name: Run Test262
command: node lib/run-tests I_AM_SURE | tee ~/test262.tap command: BABEL_PATH=.. node lib/run-tests I_AM_SURE | tee ~/test262.tap
<<: *test262_workdir <<: *test262_workdir
- store_artifacts: *artifact_test262_tap - store_artifacts: *artifact_test262_tap
- run: - run:
name: Output test262 results name: Output Test262 results
command: | command: |
cat ~/test262.tap | $(npm bin)/tap-mocha-reporter spec || true cat ~/test262.tap | $(npm bin)/tap-mocha-reporter spec || true
<<: *test262_workdir <<: *test262_workdir
- run:
name: Compare previous master branch & current job results
command: |
mkdir -p ~/test-results/test262
node lib/compare-results ~/master.tap ~/test262.tap | tee ~/diff.tap
<<: *test262_workdir
- store_artifacts: *artifact_test262_diff_tap
- run:
name: Output comparision results and report to CircleCI
command: |
mkdir -p ~/test-results/test262
cat ~/diff.tap | $(npm bin)/tap-merge | $(npm bin)/tap-mocha-reporter xunit | tee ~/test-results/test262/results.xml
<<: *test262_workdir
- store_test_results: *artifact_test262_xunit
- save_cache: *save-node-modules-cache
- save_cache: *save-yarn-cache
publish-verdaccio:
executor: node-executor
steps:
- checkout
- run: yarn install
- run: ./scripts/integration-tests/publish-local.sh
- persist_to_workspace:
root: /tmp/verdaccio-workspace
paths:
- storage
- htpasswd
e2e-babel:
executor: node-executor
steps:
- checkout
- attach_workspace:
at: /tmp/verdaccio-workspace
- run: ./scripts/integration-tests/e2e-babel.sh
e2e-create-react-app:
executor: node-executor
steps:
- checkout
- attach_workspace:
at: /tmp/verdaccio-workspace
- run: ./scripts/integration-tests/e2e-create-react-app.sh
e2e-vue-cli:
executor: node-browsers-executor
steps:
- checkout
- attach_workspace:
at: /tmp/verdaccio-workspace
- run: ./scripts/integration-tests/e2e-vue-cli.sh
workflows: workflows:
version: 2 version: 2
test: build-standalone:
jobs: jobs:
- test - build-standalone
master: test262-master:
jobs: jobs:
- test262: - test262:
filters: filters:
branches: branches:
only: only:
- master - master
test262:
jobs:
- approve-test262-run:
type: approval
filters:
branches:
ignore:
- master
- test262:
requires:
- approve-test262-run
filters:
branches:
ignore:
- master
e2e:
jobs:
- publish-verdaccio
- e2e-babel:
requires:
- publish-verdaccio
- e2e-create-react-app:
requires:
- publish-verdaccio
- e2e-vue-cli:
requires:
- publish-verdaccio

5
.codesandbox/ci.json Normal file
View File

@ -0,0 +1,5 @@
{
"installCommand": "bootstrap",
"buildCommand": false,
"sandboxes": ["kypop"]
}

View File

@ -17,10 +17,15 @@ codemods/*/lib
codemods/*/dist codemods/*/dist
codemods/*/test/fixtures codemods/*/test/fixtures
codemods/*/test/tmp codemods/*/test/tmp
packages/babel-preset-env/data packages/babel-preset-env/data/[^(plugin-features|shipped-proposals).js]
packages/babel-preset-env/test/debug-fixtures packages/babel-preset-env/test/debug-fixtures
packages/babel-preset-env-standalone/babel-preset-env.js packages/babel-preset-env-standalone/babel-preset-env.js
packages/babel-preset-env-standalone/babel-preset-env.min.js packages/babel-preset-env-standalone/babel-preset-env.min.js
packages/babel-standalone/babel.js packages/babel-standalone/babel.js
packages/babel-standalone/babel.min.js packages/babel-standalone/babel.min.js
packages/babel-parser/test/expressions packages/babel-parser/test/expressions
eslint/*/lib
eslint/*/node_modules
eslint/*/test
eslint/*/tests

48
.eslintrc.js Normal file
View File

@ -0,0 +1,48 @@
module.exports = {
root: true,
plugins: ["prettier", "@babel/development", "import"],
extends: "babel",
rules: {
"prettier/prettier": "error",
// TODO: remove after babel-eslint-config-internal is fully integrated into this repository.
"max-len": "off",
},
env: {
node: true,
},
overrides: [
{
files: [
"packages/*/src/**/*.js",
"codemods/*/src/**/*.js",
"eslint/*/src/**/*.js",
],
rules: {
"@babel/development/no-undefined-identifier": "error",
"@babel/development/no-deprecated-clone": "error",
"import/no-extraneous-dependencies": "error",
"guard-for-in": "error",
},
},
{
files: [
"packages/*/test/**/*.js",
"codemods/*/test/**/*.js",
"eslint/*/test/**/*.js",
"packages/babel-helper-transform-fixture-test-runner/src/helpers.js",
"test/**/*.js",
],
env: {
jest: true,
},
},
{
files: ["packages/babel-plugin-*/src/index.js"],
excludedFiles: ["packages/babel-plugin-transform-regenerator/**/*.js"],
rules: {
"@babel/development/plugin-name": "error",
eqeqeq: ["error", "always", { null: "ignore" }],
},
},
],
};

View File

@ -1,41 +0,0 @@
{
"root": true,
"plugins": ["prettier", "@babel/development", "import"],
"extends": "babel",
"rules": {
"prettier/prettier": "error"
},
"env": {
"node": true
},
"overrides": [
{
"files": ["packages/*/src/**/*.js", "codemods/*/src/**/*.js"],
"rules": {
"@babel/development/no-undefined-identifier": "error",
"@babel/development/no-deprecated-clone": "error",
"import/no-extraneous-dependencies": "error",
"guard-for-in": "error"
}
},
{
"files": [
"packages/*/test/**/*.js",
"codemods/*/test/**/*.js",
"packages/babel-helper-transform-fixture-test-runner/src/helpers.js",
"test/**/*.js"
],
"env": {
"jest": true
}
},
{
"files": ["packages/babel-plugin-*/src/index.js"],
"excludedFiles": ["packages/babel-plugin-transform-regenerator/**/*.js"],
"rules": {
"@babel/development/plugin-name": "error",
"eqeqeq": ["error", "always", { "null": "ignore" }]
}
}
]
}

View File

@ -9,6 +9,14 @@ assignees: ''
## Bug Report ## Bug Report
<!-- Check this if you would like to implement a PR, we are more than happy to help you go through the process !-->
- [ ] I would like to work on a fix!
<!--
@babel/eslint-parser:
If you are having issues with JSX you might want to check out eslint-plugin-react. If there's an issue with new experimental syntax you might need check if it's supported by @babel/eslint-plugin.
-->
**Current Behavior** **Current Behavior**
A clear and concise description of the behavior. A clear and concise description of the behavior.
@ -22,7 +30,8 @@ var your => (code) => here;
**Expected behavior/code** **Expected behavior/code**
A clear and concise description of what you expected to happen (or code). A clear and concise description of what you expected to happen (or code).
**Babel Configuration (.babelrc, package.json, cli command)** **Babel Configuration (babel.config.js, .babelrc, package.json#babel, cli command, .eslintrc)**
- Filename: `babel.config.js`
```js ```js
{ {
@ -31,6 +40,10 @@ A clear and concise description of what you expected to happen (or code).
``` ```
**Environment** **Environment**
<!--- Tip: Instead of filling out the questions below, you can run `npx envinfo --preset babel` and paste the result below ``` -->
```
```
- Babel version(s): [e.g. v6.0.0, v7.0.0-beta.34] - Babel version(s): [e.g. v6.0.0, v7.0.0-beta.34]
- Node/npm version: [e.g. Node 8/npm 5] - Node/npm version: [e.g. Node 8/npm 5]
- OS: [e.g. OSX 10.13.4, Windows 10] - OS: [e.g. OSX 10.13.4, Windows 10]
@ -38,7 +51,7 @@ A clear and concise description of what you expected to happen (or code).
- How you are using Babel: [e.g. `cli`, `register`, `loader`] - How you are using Babel: [e.g. `cli`, `register`, `loader`]
**Possible Solution** **Possible Solution**
<!--- Only if you have suggestions on a fix for the bug --> <!--- If you have suggestions on a fix for the bug -->
**Additional context/Screenshots** **Additional context/Screenshots**
Add any other context about the problem here. If applicable, add screenshots to help explain. Add any other context about the problem here. If applicable, add screenshots to help explain.

View File

@ -9,6 +9,9 @@ assignees: ''
## Feature Request ## Feature Request
<!-- Check this if you would like to implement a PR, we are more than happy to help you go through the process !-->
- [ ] I would like to work on this feature!
**Is your feature request related to a problem? Please describe.** **Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I have an issue when [...] A clear and concise description of what the problem is. Ex. I have an issue when [...]

View File

@ -10,6 +10,9 @@ assignees: ''
# v7 Regression # v7 Regression
<!-- Check this if you would like to implement a PR, we are more than happy to help you go through the process !-->
- [ ] I would like to work on a fix!
> First check out: https://babeljs.io/docs/en/v7-migration > First check out: https://babeljs.io/docs/en/v7-migration
> Also a partial upgrade tool: https://github.com/babel/babel-upgrade > Also a partial upgrade tool: https://github.com/babel/babel-upgrade
@ -26,7 +29,10 @@ A clear and concise description of what the regression is.
var your => (code) => here; var your => (code) => here;
``` ```
**Babel Configuration (.babelrc, package.json, cli command)** **Expected behavior/code**
A clear and concise description of what you expected to happen (or code).
**Babel Configuration (babel.config.js, .babelrc, package.json#babel, cli command)**
```js ```js
{ {
@ -34,10 +40,11 @@ var your => (code) => here;
} }
``` ```
**Expected behavior/code**
A clear and concise description of what you expected to happen (or code).
**Environment** **Environment**
<!--- Tip: Instead of filling out the questions below, you can run `npx envinfo --preset babel` and paste the result below ``` -->
```
```
- Babel version(s): [e.g. v6.0.0, v7.0.0-beta.34] - Babel version(s): [e.g. v6.0.0, v7.0.0-beta.34]
- Node/npm version: [e.g. Node 8/npm 5] - Node/npm version: [e.g. Node 8/npm 5]
- OS: [e.g. OSX 10.13.4, Windows 10] - OS: [e.g. OSX 10.13.4, Windows 10]

29
.github/workflows/coverage.yml vendored Normal file
View File

@ -0,0 +1,29 @@
name: Report Coverage
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [13.x]
steps:
- name: Checkout code
uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Environment log
id: env
run: |
yarn --version
- name: Generate coverage report
run: |
yarn --version
make -j test-ci-coverage
- name: Upload coverage report
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}

11
.gitignore vendored
View File

@ -20,6 +20,8 @@ dist
package-lock.json package-lock.json
!/.github/actions/*/package-lock.json !/.github/actions/*/package-lock.json
/packages/babel-compat-data/build
/packages/babel-runtime/helpers/*.js /packages/babel-runtime/helpers/*.js
!/packages/babel-runtime/helpers/toArray.js !/packages/babel-runtime/helpers/toArray.js
!/packages/babel-runtime/helpers/iterableToArray.js !/packages/babel-runtime/helpers/iterableToArray.js
@ -35,7 +37,7 @@ package-lock.json
!/packages/babel-runtime-corejs2/helpers/temporalRef.js !/packages/babel-runtime-corejs2/helpers/temporalRef.js
/packages/babel-runtime-corejs2/helpers/esm/*.js /packages/babel-runtime-corejs2/helpers/esm/*.js
!/packages/babel-runtime-corejs2/helpers/esm/toArray.js !/packages/babel-runtime-corejs2/helpers/esm/toArray.js
/packages/babel-runtime-corejs2/helpers/esm/iterableToArray.js !/packages/babel-runtime-corejs2/helpers/esm/iterableToArray.js
!/packages/babel-runtime-corejs2/helpers/esm/temporalRef.js !/packages/babel-runtime-corejs2/helpers/esm/temporalRef.js
/packages/babel-runtime-corejs2/core-js/**/*.js /packages/babel-runtime-corejs2/core-js/**/*.js
!/packages/babel-runtime-corejs2/core-js/map.js !/packages/babel-runtime-corejs2/core-js/map.js
@ -52,11 +54,18 @@ package-lock.json
.nyc_output .nyc_output
/babel.sublime-workspace /babel.sublime-workspace
packages/babel-standalone/babel.js packages/babel-standalone/babel.js
packages/babel-standalone/babel.js.map
packages/babel-standalone/babel.min.js packages/babel-standalone/babel.min.js
packages/babel-preset-env-standalone/babel-preset-env.js packages/babel-preset-env-standalone/babel-preset-env.js
packages/babel-preset-env-standalone/babel-preset-env.js.map
packages/babel-preset-env-standalone/babel-preset-env.min.js packages/babel-preset-env-standalone/babel-preset-env.min.js
/codemods/*/lib /codemods/*/lib
/codemods/*/node_modules /codemods/*/node_modules
/packages/babel-parser/build /packages/babel-parser/build
.idea/ .idea/
/.changelog /.changelog
/eslint/*/lib
/eslint/*/node_modules
/eslint/*/LICENSE
!/packages/babel-eslint-plugin/LICENSE

View File

@ -1,5 +1,7 @@
package.json package.json
packages/babel-preset-env/data packages/babel-preset-env/data
packages/babel-compat-data/data
packages/babel-compat-data/scripts/data/overlapping-plugins.js
packages/*/test/fixtures/**/input.* packages/*/test/fixtures/**/input.*
packages/*/test/fixtures/**/exec.* packages/*/test/fixtures/**/exec.*
packages/*/test/fixtures/**/output.* packages/*/test/fixtures/**/output.*

View File

@ -13,10 +13,12 @@
"**/codemods/*/src/**/*.js", "**/codemods/*/src/**/*.js",
"**/codemods/*/test/**/*.js", "**/codemods/*/test/**/*.js",
"**/packages/*/src/**/*.js", "**/packages/*/src/**/*.js",
"**/packages/*/test/**/*.js" "**/packages/*/test/**/*.js",
"**/eslint/*/src/**/*.js",
"**/eslint/*/test/**/*.js"
], ],
"parser": "babylon",
"options": { "options": {
"parser": "babel",
"trailingComma": "all" "trailingComma": "all"
} }
}] }]

View File

@ -20,6 +20,7 @@ script:
- if [ "$JOB" = "test" ]; then make -j test-ci; fi - if [ "$JOB" = "test" ]; then make -j test-ci; fi
- if [ "$JOB" = "lint" ]; then make -j code-quality-ci; fi - if [ "$JOB" = "lint" ]; then make -j code-quality-ci; fi
- if [ "$JOB" = "babel-parser-flow-tests" ]; then make -j test-flow-ci; fi - if [ "$JOB" = "babel-parser-flow-tests" ]; then make -j test-flow-ci; fi
- if [ "$JOB" = "babel-parser-typescript-tests" ]; then make -j test-typescript-ci; fi
- if [ "$JOB" = "babel-parser-test262-tests" ]; then make -j test-test262-ci; fi - if [ "$JOB" = "babel-parser-test262-tests" ]; then make -j test-test262-ci; fi
matrix: matrix:
@ -36,12 +37,18 @@ matrix:
- JOB=test - JOB=test
# https://travis-ci.community/t/build-doesnt-finish-after-completing-tests/288/9 # https://travis-ci.community/t/build-doesnt-finish-after-completing-tests/288/9
- YARN_GPG=no - YARN_GPG=no
cache:
yarn: true
directories:
- $HOME/AppData/Local/Temp/chocolatey
# Continue node_js matrix # Continue node_js matrix
- node_js: "6" - node_js: "6"
- node_js: "10" - node_js: "10"
- node_js: "8" - node_js: "8"
- node_js: "node" - node_js: "node"
env: JOB=babel-parser-flow-tests env: JOB=babel-parser-flow-tests
- node_js: "node"
env: JOB=babel-parser-typescript-tests
- node_js: "node" - node_js: "node"
env: JOB=babel-parser-test262-tests env: JOB=babel-parser-test262-tests

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
---- ---
<p align="center" class="toc"> <p align="center" class="toc">
<strong><a href="#setup">Setup</a></strong> <strong><a href="#setup">Setup</a></strong>
@ -12,8 +12,7 @@
<strong><a href="#internals">Internals</a></strong> <strong><a href="#internals">Internals</a></strong>
</p> </p>
---- ---
# Contributing # Contributing
@ -24,13 +23,13 @@ contributing, please read the
## Not sure where to start? ## Not sure where to start?
- If you aren't just making a documentation change, you'll probably want to learn a bit about a few topics. - If you aren't just making a documentation change, you'll probably want to learn a bit about a few topics.
- [ASTs](https://en.wikipedia.org/wiki/Abstract_syntax_tree) (Abstract Syntax Tree): The Babel AST [spec](https://github.com/babel/babel/blob/master/packages/babel-parser/ast/spec.md) is a bit different from [ESTree](https://github.com/estree/estree). The differences are listed [here](https://babeljs.io/docs/en/next/babel-parser.html#output). - [ASTs](https://en.wikipedia.org/wiki/Abstract_syntax_tree) (Abstract Syntax Tree): The Babel AST [spec](https://github.com/babel/babel/blob/master/packages/babel-parser/ast/spec.md) is a bit different from [ESTree](https://github.com/estree/estree). The differences are listed [here](https://babeljs.io/docs/en/next/babel-parser.html#output).
- Check out [`/doc`](https://github.com/babel/babel/tree/master/doc) for information about Babel's internals - Check out [`/doc`](https://github.com/babel/babel/tree/master/doc) for information about Babel's internals
- Check out [the Babel Plugin Handbook](https://github.com/thejameskyle/babel-handbook/blob/master/translations/en/plugin-handbook.md#babel-plugin-handbook) - core plugins are written the same way as any other plugin! - Check out [the Babel Plugin Handbook](https://github.com/thejameskyle/babel-handbook/blob/master/translations/en/plugin-handbook.md#babel-plugin-handbook) - core plugins are written the same way as any other plugin!
- Check out [AST Explorer](http://astexplorer.net/#/scUfOmVOG5) to learn more about ASTs or make your own plugin in the browser - Check out [AST Explorer](http://astexplorer.net/#/scUfOmVOG5) to learn more about ASTs or make your own plugin in the browser
- When you feel ready to jump into the Babel source code, a good place to start is to look for issues tagged with [help wanted](https://github.com/babel/babel/labels/help%20wanted) and/or [good first issue](https://github.com/babel/babel/labels/good%20first%20issue). - When you feel ready to jump into the Babel source code, a good place to start is to look for issues tagged with [help wanted](https://github.com/babel/babel/labels/help%20wanted) and/or [good first issue](https://github.com/babel/babel/labels/good%20first%20issue).
- Follow along with what we are working on by joining our [Slack](https://babeljs.slack.com) (you can sign-up [here](https://slack.babeljs.io/) - Follow along with what we are working on by joining our [Slack](https://babeljs.slack.com) (you can sign-up [here](https://slack.babeljs.io/)
for an invite), following our announcements on [Twitter](https://twitter.com/babeljs), and reading (or participating!) in our [meeting notes](https://github.com/babel/notes). for an invite), following our announcements on [Twitter](https://twitter.com/babeljs), and reading (or participating!) in our [meeting notes](https://github.com/babel/notes).
- Check out our [website](http://babeljs.io/) and the [repo](https://github.com/babel/website) - Check out our [website](http://babeljs.io/) and the [repo](https://github.com/babel/website)
- You can contribute by triaging issues which may include reproducing bug reports or asking for vital information, such as version numbers or reproduction instructions. If you would like to start triaging issues, one easy way to get started is to [subscribe to babel on CodeTriage](https://www.codetriage.com/babel/babel). [![Open Source Helpers](https://www.codetriage.com/babel/babel/badges/users.svg)](https://www.codetriage.com/babel/babel) - You can contribute by triaging issues which may include reproducing bug reports or asking for vital information, such as version numbers or reproduction instructions. If you would like to start triaging issues, one easy way to get started is to [subscribe to babel on CodeTriage](https://www.codetriage.com/babel/babel). [![Open Source Helpers](https://www.codetriage.com/babel/babel/badges/users.svg)](https://www.codetriage.com/babel/babel)
@ -49,8 +48,12 @@ Installation instructions can be found here: https://yarnpkg.com/en/docs/install
### Setup ### Setup
Fork the `babel` repository to your GitHub Account.
Then, run:
```sh ```sh
$ git clone https://github.com/babel/babel $ git clone https://github.com/<your-github-username>/babel
$ cd babel $ cd babel
$ make bootstrap $ make bootstrap
``` ```
@ -158,12 +161,12 @@ $ ./scripts/test-cov.sh
In case you're not able to reproduce an error on CI locally, it may be due to In case you're not able to reproduce an error on CI locally, it may be due to
- Node Version: Travis CI runs the tests against all major node versions. If your tests use JavaScript features unsupported by lower versions of node, then use [minNodeVersion option](#writing-tests) in options.json. - Node Version: Travis CI runs the tests against all major node versions. If your tests use JavaScript features unsupported by lower versions of node, then use [minNodeVersion option](#writing-tests) in options.json.
- Timeout: Check the CI log and if the only errors are timeout errors and you are sure that it's not related to the changes you made, ask someone in the slack channel to trigger rebuild on the CI build and it might be resolved - Timeout: Check the CI log and if the only errors are timeout errors and you are sure that it's not related to the changes you made, ask someone in the slack channel to trigger rebuild on the CI build and it might be resolved
In case you're locally getting errors which are not on the CI, it may be due to In case you're locally getting errors which are not on the CI, it may be due to
- Updates in Dependencies: Make sure you run `make bootstrap` before you run `make build` or `make watch` before you run the tests. - Updates in Dependencies: Make sure you run `make bootstrap` before you run `make build` or `make watch` before you run the tests.
### Writing tests ### Writing tests
@ -177,15 +180,16 @@ For example, in [`@babel/plugin-transform-exponentiation-operator/test`](https:/
- There is an `index.js` file. It imports our [test helper](https://github.com/babel/babel/tree/master/packages/babel-helper-plugin-test-runner). (You don't have to worry about this). - There is an `index.js` file. It imports our [test helper](https://github.com/babel/babel/tree/master/packages/babel-helper-plugin-test-runner). (You don't have to worry about this).
- There can be multiple folders under [`/fixtures`](https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-exponentiation-operator/test/fixtures) - There can be multiple folders under [`/fixtures`](https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-exponentiation-operator/test/fixtures)
- There is an [`options.json`](https://github.com/babel/babel/blob/master/packages/babel-plugin-transform-exponentiation-operator/test/fixtures/exponentian-operator/options.json) file whose function is similar to a `.babelrc` file, allowing you to pass in the plugins and settings you need for your tests.
- For this test, we only need the relevant plugin, so it's just `{ "plugins": ["@babel/plugin-transform-exponentiation-operator"] }`. - There is an [`options.json`](https://github.com/babel/babel/blob/master/packages/babel-plugin-transform-exponentiation-operator/test/fixtures/exponentian-operator/options.json) file whose function is similar to a `.babelrc` file, allowing you to pass in the plugins and settings you need for your tests.
- If necessary, you can have an `options.json` with different options in each subfolder. - For this test, we only need the relevant plugin, so it's just `{ "plugins": ["@babel/plugin-transform-exponentiation-operator"] }`.
- If necessary, you can have an `options.json` with different options in each subfolder.
- In each subfolder, you can organize your directory structure by categories of tests. (Example: these folders can be named after the feature you are testing or can reference the issue number they fix) - In each subfolder, you can organize your directory structure by categories of tests. (Example: these folders can be named after the feature you are testing or can reference the issue number they fix)
- Generally, there are two kinds of tests for plugins - Generally, there are two kinds of tests for plugins
  - The first is a simple test of the input and output produced by running Babel on some code. We do this by creating an [`input.js`](https://github.com/babel/babel/blob/master/packages/babel-plugin-transform-exponentiation-operator/test/fixtures/exponentian-operator/binary/input.js) file and an [`output.js`](https://github.com/babel/babel/blob/master/packages/babel-plugin-transform-exponentiation-operator/test/fixtures/exponentian-operator/binary/output.js) file. This kind of test only works in sub-subdirectories of `/fixtures`, i.e. `/fixtures/exponentian-operator/binary/input.js` and **not** `/fixtures/exponentian-operator/input.js`.   - The first is a simple test of the input and output produced by running Babel on some code. We do this by creating an [`input.js`](https://github.com/babel/babel/blob/master/packages/babel-plugin-transform-exponentiation-operator/test/fixtures/exponentian-operator/binary/input.js) file and an [`output.js`](https://github.com/babel/babel/blob/master/packages/babel-plugin-transform-exponentiation-operator/test/fixtures/exponentian-operator/binary/output.js) file. This kind of test only works in sub-subdirectories of `/fixtures`, i.e. `/fixtures/exponentian-operator/binary/input.js` and **not** `/fixtures/exponentian-operator/input.js`.
- If you need to expect an error, you can ignore creating the `output.js` file and pass a new `throws` key to the `options.json` that contains the error string that is created. - If you need to expect an error, you can ignore creating the `output.js` file and pass a new `throws` key to the `options.json` that contains the error string that is created.
- The second and preferred type is a test that actually evaluates the produced code and asserts that certain properties are true or false. We do this by creating an [`exec.js`](https://github.com/babel/babel/blob/master/packages/babel-plugin-transform-exponentiation-operator/test/fixtures/exponentian-operator/comprehensive/exec.js) file. - The second and preferred type is a test that actually evaluates the produced code and asserts that certain properties are true or false. We do this by creating an [`exec.js`](https://github.com/babel/babel/blob/master/packages/babel-plugin-transform-exponentiation-operator/test/fixtures/exponentian-operator/comprehensive/exec.js) file.
In a fixture test, you simply write out the code you want to transform in `input.js`. In a fixture test, you simply write out the code you want to transform in `input.js`.
@ -200,6 +204,7 @@ and the expected output after transforming it with your `options.json` in `outpu
// output.js // output.js
Math.pow(2, 2); Math.pow(2, 2);
``` ```
In an `exec.js` test, we run or check that the code actually does what it's supposed to do rather than just check the static output. In an `exec.js` test, we run or check that the code actually does what it's supposed to do rather than just check the static output.
```js ```js
@ -235,9 +240,9 @@ Inside the `packages/babel-parser/test/fixtures` folder are categories/groupings
etc.). To add a test, create a folder under one of these groupings (or create a new one) with a etc.). To add a test, create a folder under one of these groupings (or create a new one) with a
descriptive name, and add the following: descriptive name, and add the following:
* Create an `input.js` file that contains the code you want the babel parser to parse. - Create an `input.js` file that contains the code you want the babel parser to parse.
* Add an `output.json` file with the expected parser output. For added convenience, if there is no `output.json` present, the test runner will generate one for you. - Add an `output.json` file with the expected parser output. For added convenience, if there is no `output.json` present, the test runner will generate one for you.
After writing tests for @babel/parser, just build it by running: After writing tests for @babel/parser, just build it by running:
@ -317,6 +322,7 @@ Note that the code shown in Chrome DevTools is compiled code and therefore diffe
- Start working about the Babel transform itself! - Start working about the Babel transform itself!
## Internals ## Internals
- AST spec ([babel-parser/ast/spec.md](https://github.com/babel/babel/blob/master/packages/babel-parser/ast/spec.md)) - AST spec ([babel-parser/ast/spec.md](https://github.com/babel/babel/blob/master/packages/babel-parser/ast/spec.md))
- Versioning ([doc/design/versioning.md](https://github.com/babel/babel/blob/master/doc/design/versioning.md)) - Versioning ([doc/design/versioning.md](https://github.com/babel/babel/blob/master/doc/design/versioning.md))
- Monorepo ([doc/design/monorepo.md](https://github.com/babel/babel/blob/master/doc/design/monorepo.md)) - Monorepo ([doc/design/monorepo.md](https://github.com/babel/babel/blob/master/doc/design/monorepo.md))

View File

@ -10,14 +10,19 @@ const fancyLog = require("fancy-log");
const filter = require("gulp-filter"); const filter = require("gulp-filter");
const gulp = require("gulp"); const gulp = require("gulp");
const path = require("path"); const path = require("path");
const webpack = require("webpack");
const rollup = require("rollup"); const rollup = require("rollup");
const rollupAlias = require("@rollup/plugin-alias");
const rollupBabel = require("rollup-plugin-babel"); const rollupBabel = require("rollup-plugin-babel");
const rollupBabelSource = require("./scripts/rollup-plugin-babel-source");
const rollupCommonJs = require("rollup-plugin-commonjs");
const rollupJson = require("@rollup/plugin-json");
const rollupNodeBuiltins = require("rollup-plugin-node-builtins");
const rollupNodeGlobals = require("rollup-plugin-node-globals");
const rollupNodeResolve = require("rollup-plugin-node-resolve"); const rollupNodeResolve = require("rollup-plugin-node-resolve");
const rollupReplace = require("rollup-plugin-replace"); const rollupReplace = require("rollup-plugin-replace");
const { registerStandalonePackageTask } = require("./scripts/gulp-tasks"); const { terser: rollupTerser } = require("rollup-plugin-terser");
const defaultSourcesGlob = "./@(codemods|packages)/*/src/**/*.js"; const defaultSourcesGlob = "./@(codemods|packages|eslint)/*/src/**/*.js";
function swapSrcWithLib(srcPath) { function swapSrcWithLib(srcPath) {
const parts = srcPath.split(path.sep); const parts = srcPath.split(path.sep);
@ -75,42 +80,209 @@ function buildBabel(exclude, sourcesGlob = defaultSourcesGlob) {
.pipe(gulp.dest(base)); .pipe(gulp.dest(base));
} }
let babelVersion = require("./packages/babel-core/package.json").version;
function buildRollup(packages) { function buildRollup(packages) {
const sourcemap = process.env.NODE_ENV === "production";
const minify = !!process.env.IS_PUBLISH;
return Promise.all( return Promise.all(
packages.map(pkg => { packages.map(
const input = getIndexFromPackage(pkg); ({ src, format, dest, name, filename, version = babelVersion }) => {
fancyLog(`Compiling '${chalk.cyan(input)}' with rollup ...`); const extraPlugins = [];
return rollup let inputExternal = undefined,
.rollup({ outputGlobals = undefined,
input, nodeResolveBrowser = false,
plugins: [ babelEnvName = "rollup";
rollupReplace({ switch (src) {
"process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV), case "packages/babel-standalone":
}), nodeResolveBrowser = true;
rollupBabel({ babelEnvName = "standalone";
envName: "babel-parser", if (minify) {
}), extraPlugins.push(
rollupNodeResolve(), rollupTerser({
], include: /^.+\.min\.js$/,
}) })
.then(bundle => { );
return bundle.write({ }
file: path.join(pkg, "lib/index.js"), break;
format: "cjs", case "packages/babel-preset-env-standalone":
name: "babel-parser", nodeResolveBrowser = true;
sourcemap: process.env.NODE_ENV !== "production", babelEnvName = "standalone";
if (minify) {
extraPlugins.push(
rollupTerser({
include: /^.+\.min\.js$/,
})
);
}
inputExternal = ["@babel/standalone"];
outputGlobals = {
"@babel/standalone": "Babel",
};
extraPlugins.push(
rollupAlias({
entries: [
{
find: "./available-plugins",
replacement: require.resolve(
path.join(__dirname, src, "./src/available-plugins")
),
},
{
find: "caniuse-lite/data/regions",
replacement: require.resolve(
path.join(__dirname, src, "./src/caniuse-lite-regions")
),
},
],
})
);
break;
}
// If this build is part of a pull request, include the pull request number in
// the version number.
if (process.env.CIRCLE_PR_NUMBER) {
const prVersion = "+pr." + process.env.CIRCLE_PR_NUMBER;
babelVersion += prVersion;
version += prVersion;
}
const input = getIndexFromPackage(src);
fancyLog(`Compiling '${chalk.cyan(input)}' with rollup ...`);
return rollup
.rollup({
input,
external: inputExternal,
plugins: [
...extraPlugins,
rollupBabelSource(),
rollupReplace({
"process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV),
BABEL_VERSION: JSON.stringify(babelVersion),
VERSION: JSON.stringify(version),
}),
rollupBabel({
envName: babelEnvName,
babelrc: false,
extends: "./babel.config.js",
}),
rollupNodeResolve({
browser: nodeResolveBrowser,
preferBuiltins: true,
//todo: When Yarn workspaces is enabled, remove `dedupe` option
dedupe(importee) {
return (
importee.startsWith("lodash/") ||
[
"babel-plugin-dynamic-import-node/utils",
"esutils",
"semver",
"source-map",
].includes(importee)
);
},
}),
rollupCommonJs({
include: [
/node_modules/,
"packages/babel-runtime/regenerator/**",
"packages/babel-preset-env/data/*.js",
// Rollup doesn't read export maps, so it loads the cjs fallback
"packages/babel-compat-data/*.js",
],
namedExports: {
"babel-plugin-dynamic-import-node/utils.js": [
"createDynamicImportTransform",
"getImportSource",
],
"@babel/standalone": ["availablePlugins", "registerPlugin"],
},
}),
rollupJson(),
rollupNodeBuiltins(),
rollupNodeGlobals({ sourceMap: sourcemap }),
],
})
.then(bundle => {
const outputFile = path.resolve(src, dest, filename || "index.js");
return bundle
.write({
file: outputFile,
format,
name,
globals: outputGlobals,
sourcemap: sourcemap,
})
.then(() => {
if (!process.env.IS_PUBLISH) {
fancyLog(
chalk.yellow(
`Skipped minification of '${chalk.cyan(
path.relative(path.join(__dirname, ".."), outputFile)
)}' because not publishing`
)
);
return undefined;
}
fancyLog(
`Minifying '${chalk.cyan(
path.relative(path.join(__dirname, ".."), outputFile)
)}'...`
);
return bundle.write({
file: outputFile.replace(/\.js$/, ".min.js"),
format,
name,
globals: outputGlobals,
sourcemap: sourcemap,
});
});
}); });
}); }
}) )
); );
} }
const bundles = ["packages/babel-parser"]; const libBundles = [
{
src: "packages/babel-parser",
format: "cjs",
dest: "lib",
version: require("./packages/babel-parser/package").version,
},
];
gulp.task("build-rollup", () => buildRollup(bundles)); const standaloneBundle = [
gulp.task("build-babel", () => buildBabel(/* exclude */ bundles)); {
src: "packages/babel-standalone",
format: "umd",
name: "Babel",
filename: "babel.js",
dest: "",
version: require("./packages/babel-core/package").version,
},
];
const presetEnvStandaloneBundle = [
{
src: "packages/babel-preset-env-standalone",
format: "umd",
name: "BabelPresetEnv",
filename: "babel-preset-env.js",
dest: "",
version: require("./packages/babel-preset-env/package").version,
},
];
gulp.task("build-rollup", () => buildRollup(libBundles));
gulp.task("build-babel-standalone", () => buildRollup(standaloneBundle));
gulp.task("build-babel-preset-env-standalone", () =>
buildRollup(presetEnvStandaloneBundle)
);
gulp.task("build-babel", () => buildBabel(/* exclude */ libBundles));
gulp.task("build-babel-types", () => gulp.task("build-babel-types", () =>
buildBabel(/* exclude */ bundles, "packages/babel-types/src/**/*.js") buildBabel(/* exclude */ libBundles, "packages/babel-types/src/**/*.js")
); );
gulp.task("build", gulp.parallel("build-rollup", "build-babel")); gulp.task("build", gulp.parallel("build-rollup", "build-babel"));
@ -128,41 +300,3 @@ gulp.task(
); );
}) })
); );
registerStandalonePackageTask(
gulp,
"babel",
"Babel",
path.join(__dirname, "packages"),
require("./packages/babel-standalone/package.json").version
);
const presetEnvWebpackPlugins = [
new webpack.NormalModuleReplacementPlugin(
/\.\/available-plugins/,
require.resolve(
path.join(
__dirname,
"./packages/babel-preset-env-standalone/src/available-plugins"
)
)
),
new webpack.NormalModuleReplacementPlugin(
/caniuse-lite\/data\/regions\/.+/,
require.resolve(
path.join(
__dirname,
"./packages/babel-preset-env-standalone/src/caniuse-lite-regions"
)
)
),
];
registerStandalonePackageTask(
gulp,
"babel-preset-env",
"babelPresetEnv",
path.join(__dirname, "packages"),
require("./packages/babel-preset-env-standalone/package.json").version,
presetEnvWebpackPlugins
);

View File

@ -1,10 +1,19 @@
FLOW_COMMIT = 09669846b7a7ca5a6c23c12d56bb3bebdafd67e9 FLOW_COMMIT = a1f9a4c709dcebb27a5084acf47755fbae699c25
TEST262_COMMIT = 8688c4ab79059c3097098605e69f1ee5eda6c409 TEST262_COMMIT = 28b4fcca4b1b1d278dfe0cc0e69c7d9d59b31aab
TYPESCRIPT_COMMIT = 5fc917be2e4dd64c8e9504d36615cd7fbfdd4cd3
FORCE_PUBLISH = "@babel/runtime,@babel/runtime-corejs2,@babel/runtime-corejs3,@babel/standalone,@babel/preset-env-standalone"
# Fix color output until TravisCI fixes https://github.com/travis-ci/travis-ci/issues/7967 # Fix color output until TravisCI fixes https://github.com/travis-ci/travis-ci/issues/7967
export FORCE_COLOR = true export FORCE_COLOR = true
SOURCES = packages codemods SOURCES = packages codemods eslint
COMMA := ,
EMPTY :=
SPACE := $(EMPTY) $(EMPTY)
COMMA_SEPARATED_SOURCES = $(subst $(SPACE),$(COMMA),$(SOURCES))
.PHONY: build build-dist watch lint fix clean test-clean test-only test test-ci publish bootstrap .PHONY: build build-dist watch lint fix clean test-clean test-only test test-ci publish bootstrap
@ -103,7 +112,7 @@ lint-js:
yarn eslint scripts $(SOURCES) '*.js' --format=codeframe yarn eslint scripts $(SOURCES) '*.js' --format=codeframe
lint-ts: lint-ts:
scripts/tests/typescript/lint.sh scripts/lint-ts-typings.sh
fix: fix-json fix-js fix: fix-json fix-js
@ -111,7 +120,7 @@ fix-js:
yarn eslint scripts $(SOURCES) '*.js' --format=codeframe --fix yarn eslint scripts $(SOURCES) '*.js' --format=codeframe --fix
fix-json: fix-json:
yarn prettier "{packages,codemod}/*/test/fixtures/**/options.json" --write --loglevel warn yarn prettier "{$(COMMA_SEPARATED_SOURCES)}/*/test/fixtures/**/options.json" --write --loglevel warn
clean: test-clean clean: test-clean
rm -f .npmrc rm -f .npmrc
@ -127,7 +136,8 @@ test-clean:
# Does not work on Windows; use "yarn jest" instead # Does not work on Windows; use "yarn jest" instead
test-only: test-only:
BABEL_ENV=test ./scripts/test.sh BABEL_ENV=test ./scripts/test.sh
$(MAKE) test-clean YARN jest
#$(MAKE) test-clean
test: lint test-only test: lint test-only
@ -151,28 +161,43 @@ bootstrap-flow:
cd build/flow && git checkout $(FLOW_COMMIT) cd build/flow && git checkout $(FLOW_COMMIT)
test-flow: test-flow:
node scripts/tests/flow/run_babel_parser_flow_tests.js node scripts/parser-tests/flow
test-flow-ci: build-bundle-ci bootstrap-flow test-flow-ci: build-bundle-ci bootstrap-flow
$(MAKE) test-flow $(MAKE) test-flow
test-flow-update-whitelist: test-flow-update-whitelist:
node scripts/tests/flow/run_babel_parser_flow_tests.js --update-whitelist node scripts/parser-tests/flow --update-whitelist
bootstrap-typescript:
rm -rf ./build/typescript
mkdir -p ./build
git clone --branch=master --single-branch --shallow-since=2019-09-01 https://github.com/microsoft/TypeScript.git ./build/typescript
cd build/typescript && git checkout $(TYPESCRIPT_COMMIT)
test-typescript:
node scripts/parser-tests/typescript
test-typescript-ci: build-bundle-ci bootstrap-typescript
$(MAKE) test-typescript
test-typescript-update-whitelist:
node scripts/parser-tests/typescript --update-whitelist
bootstrap-test262: bootstrap-test262:
rm -rf build/test262 rm -rf build/test262
mkdir -p build mkdir -p build
git clone --branch=master --single-branch --shallow-since=2019-09-01 https://github.com/tc39/test262.git build/test262 git clone --branch=master --single-branch --shallow-since=2019-12-01 https://github.com/tc39/test262.git build/test262
cd build/test262 && git checkout $(TEST262_COMMIT) cd build/test262 && git checkout $(TEST262_COMMIT)
test-test262: test-test262:
node scripts/tests/test262/run_babel_parser_test262.js node scripts/parser-tests/test262
test-test262-ci: build-bundle-ci bootstrap-test262 test-test262-ci: build-bundle-ci bootstrap-test262
$(MAKE) test-test262 $(MAKE) test-test262
test-test262-update-whitelist: test-test262-update-whitelist:
node scripts/tests/test262/run_babel_parser_test262.js --update-whitelist node scripts/parser-tests/test262 --update-whitelist
# Does not work on Windows # Does not work on Windows
clone-license: clone-license:
@ -185,14 +210,17 @@ prepublish-build: clean-lib clean-runtime-helpers
prepublish: prepublish:
$(MAKE) bootstrap-only $(MAKE) bootstrap-only
$(MAKE) prepublish-build $(MAKE) prepublish-build
$(MAKE) test #$(MAKE) test #fuck your tests babel...
new-version: new-version:
git pull --rebase git pull --rebase
yarn lerna version --force-publish="@babel/runtime,@babel/runtime-corejs2,@babel/runtime-corejs3,@babel/standalone,@babel/preset-env-standalone" yarn lerna version --force-publish=$(FORCE_PUBLISH)
version-cerxes:
yarn lerna version prerelease --allow-branch initializers-fix --preid csx
publish-cerxes: prepublish publish-cerxes: prepublish
yarn lerna publish --registry="https://npm.cerxes.net" --force-publish --allow-branch initializers-fix --canary --preid csx --dist-tag csx yarn lerna publish --registry="https://npm.cerxes.net" --force-publish --allow-branch initializer-fix-v7.8.3 --dist-tag csx --skip-git --exact
# NOTE: Run make new-version first # NOTE: Run make new-version first
publish: prepublish publish: prepublish
@ -210,24 +238,43 @@ endif
rm -f .npmrc rm -f .npmrc
$(MAKE) clean $(MAKE) clean
publish-test:
ifneq ("$(I_AM_USING_VERDACCIO)", "I_AM_SURE")
echo "You probably don't know what you are doing"
exit 1
endif
$(MAKE) prepublish-build
yarn lerna version patch --force-publish=$(FORCE_PUBLISH) --no-push --yes --tag-version-prefix="version-e2e-test-"
yarn lerna publish from-git --registry http://localhost:4873 --yes --tag-version-prefix="version-e2e-test-"
$(MAKE) clean
publish-eslint:
$(call set-json-field, ./eslint/$(PKG)/package.json, private, false)
cd eslint/$(PKG); yarn publish
$(call set-json-field, ./eslint/$(PKG)/package.json, private, true)
bootstrap-only: lerna-bootstrap bootstrap-only: lerna-bootstrap
yarn-install: clean-all yarn-install: clean-all
yarn --ignore-engines yarn --ignore-engines
lerna-bootstrap: yarn-install lerna-bootstrap: yarn-install
yarn lerna bootstrap # todo: remove `-- -- --ignore-engines` in Babel 8
yarn lerna bootstrap -- -- --ignore-engines
bootstrap: bootstrap-only bootstrap: bootstrap-only
$(MAKE) build $(MAKE) build
clean-lib: clean-lib:
# TODO: Don't delete eslint/*/lib when they use src
$(foreach source, $(SOURCES), \ $(foreach source, $(SOURCES), \
$(call clean-source-lib, $(source))) $(if $(filter-out $(source), eslint), \
$(call clean-source-lib, $(source))))
clean-runtime-helpers: clean-runtime-helpers:
rm -rf packages/babel-runtime/helpers rm -f packages/babel-runtime/helpers/**/*.js
rm -rf packages/babel-runtime-corejs2/helpers rm -f packages/babel-runtime-corejs2/helpers/**/*.js
rm -f packages/babel-runtime-corejs3/helpers/**/*.js
rm -rf packages/babel-runtime-corejs2/core-js rm -rf packages/babel-runtime-corejs2/core-js
clean-all: clean-all:
@ -240,6 +287,12 @@ clean-all:
$(MAKE) clean $(MAKE) clean
update-env-corejs-fixture:
rm -rf packages/babel-preset-env/node_modules/core-js-compat
$(YARN) lerna bootstrap
$(MAKE) build-bundle
OVERWRITE=true $(YARN) jest packages/babel-preset-env
define clean-source-lib define clean-source-lib
rm -rf $(1)/*/lib rm -rf $(1)/*/lib
@ -252,8 +305,16 @@ define clean-source-test
endef endef
define clean-source-all define clean-source-all
rm -rf $(1)/*/lib # TODO: Don't delete eslint/*/lib when they use src
$(if $(filter-out $1, eslint), $(call clean-source-lib, $1))
rm -rf $(1)/*/node_modules rm -rf $(1)/*/node_modules
rm -rf $(1)/*/package-lock.json rm -rf $(1)/*/package-lock.json
endef endef
define set-json-field
node -e "\
require('fs').writeFileSync('$1'.trim(), \
JSON.stringify({ ...require('$1'.trim()), $2: $3 }, null, 2) + '\\n' \
)"
endef

View File

@ -4,17 +4,10 @@
</a> </a>
</p> </p>
<p align="center">
<span style="color:darkred">
<b><i>WARNING</i> This is a fork of babel to test a fix for initializer-variables with class-properties (proposals-stuff)</b>
</span>
</p>
<p align="center"> <p align="center">
The compiler for writing next generation JavaScript. The compiler for writing next generation JavaScript.
</p> </p>
<p align="center"> <p align="center">
<a href="https://www.npmjs.com/package/@babel/core"><img alt="v7 npm Downloads" src="https://img.shields.io/npm/dm/@babel/core.svg?maxAge=43200&label=v7%20downloads"></a> <a href="https://www.npmjs.com/package/@babel/core"><img alt="v7 npm Downloads" src="https://img.shields.io/npm/dm/@babel/core.svg?maxAge=43200&label=v7%20downloads"></a>
<a href="https://www.npmjs.com/package/babel-core"><img alt="v6 npm Downloads" src="https://img.shields.io/npm/dm/babel-core.svg?maxAge=43200&label=v6%20downloads"></a> <a href="https://www.npmjs.com/package/babel-core"><img alt="v6 npm Downloads" src="https://img.shields.io/npm/dm/babel-core.svg?maxAge=43200&label=v6%20downloads"></a>
@ -115,7 +108,7 @@ Some resources:
- Our [CONTRIBUTING.md](CONTRIBUTING.md) to get started with setting up the repo. - Our [CONTRIBUTING.md](CONTRIBUTING.md) to get started with setting up the repo.
- Our discussions/notes/roadmap: [babel/notes](https://github.com/babel/notes) - Our discussions/notes/roadmap: [babel/notes](https://github.com/babel/notes)
- Our progress on TC39 proposals: [babel/proposals](https://github.com/babel/proposals) - Our progress on TC39 proposals: [babel/proposals](https://github.com/babel/proposals)
- Our blog which contains release posts and explainations: [/blog](https://babeljs.io/blog) - Our blog which contains release posts and explanations: [/blog](https://babeljs.io/blog)
- Our videos page with talks about open source and Babel: [/videos](https://babeljs.io/videos) - Our videos page with talks about open source and Babel: [/videos](https://babeljs.io/videos)
- Our [podcast](https://podcast.babeljs.io) - Our [podcast](https://podcast.babeljs.io)

View File

@ -14,22 +14,38 @@ module.exports = function(api) {
let convertESM = true; let convertESM = true;
let ignoreLib = true; let ignoreLib = true;
let includeRuntime = false; let includeRegeneratorRuntime = false;
let transformRuntimeOptions;
const nodeVersion = "6.9"; const nodeVersion = "6.9";
// The vast majority of our src files are modules, but we use
// unambiguous to keep things simple until we get around to renaming
// the modules to be more easily distinguished from CommonJS
const unambiguousSources = [
"packages/*/src",
"packages/*/test",
"codemods/*/src",
"codemods/*/test",
"eslint/*/src",
"eslint/*/test",
];
switch (env) { switch (env) {
// Configs used during bundling builds. // Configs used during bundling builds.
case "babel-parser":
convertESM = false;
ignoreLib = false;
envOpts.targets = {
node: nodeVersion,
};
break;
case "standalone": case "standalone":
includeRegeneratorRuntime = true;
unambiguousSources.push("packages/babel-runtime/regenerator");
case "rollup":
convertESM = false; convertESM = false;
ignoreLib = false; ignoreLib = false;
includeRuntime = true; // rollup-commonjs will converts node_modules to ESM
unambiguousSources.push(
"**/node_modules",
"packages/babel-preset-env/data",
"packages/babel-compat-data"
);
if (env === "rollup") envOpts.targets = { node: nodeVersion };
break; break;
case "production": case "production":
// Config during builds before publish. // Config during builds before publish.
@ -50,6 +66,16 @@ module.exports = function(api) {
break; break;
} }
if (includeRegeneratorRuntime) {
const babelRuntimePkgPath = require.resolve("@babel/runtime/package.json");
transformRuntimeOptions = {
helpers: false, // Helpers are handled by rollup when needed
regenerator: true,
version: require(babelRuntimePkgPath).version,
};
}
const config = { const config = {
// Our dependencies are all standard CommonJS, along with all sorts of // Our dependencies are all standard CommonJS, along with all sorts of
// other random files in Babel's codebase, so we use script as the default, // other random files in Babel's codebase, so we use script as the default,
@ -77,10 +103,14 @@ module.exports = function(api) {
"@babel/proposal-object-rest-spread", "@babel/proposal-object-rest-spread",
{ useBuiltIns: true, loose: true }, { useBuiltIns: true, loose: true },
], ],
"@babel/plugin-proposal-optional-chaining", ["@babel/plugin-proposal-optional-chaining", { loose: true }],
"@babel/plugin-proposal-nullish-coalescing-operator", ["@babel/plugin-proposal-nullish-coalescing-operator", { loose: true }],
convertESM ? "@babel/transform-modules-commonjs" : null, convertESM ? "@babel/transform-modules-commonjs" : null,
// Until Jest supports native mjs, we must simulate it 🤷
env === "test" || env === "development"
? "@babel/plugin-proposal-dynamic-import"
: null,
].filter(Boolean), ].filter(Boolean),
overrides: [ overrides: [
{ {
@ -104,28 +134,12 @@ module.exports = function(api) {
presets: [["@babel/env", envOptsNoTargets]], presets: [["@babel/env", envOptsNoTargets]],
}, },
{ {
// The vast majority of our src files are modules, but we use test: unambiguousSources,
// unambiguous to keep things simple until we get around to renaming
// the modules to be more easily distinguished from CommonJS
test: [
"packages/*/src",
"packages/*/test",
"codemods/*/src",
"codemods/*/test",
],
sourceType: "unambiguous", sourceType: "unambiguous",
}, },
{ includeRegeneratorRuntime && {
// The runtime transform shouldn't process its own runtime or core-js. exclude: /regenerator-runtime/,
exclude: [ plugins: [["@babel/transform-runtime", transformRuntimeOptions]],
"packages/babel-runtime",
/[\\/]node_modules[\\/](?:@babel\/runtime|babel-runtime|core-js)[\\/]/,
],
plugins: [
includeRuntime
? ["@babel/transform-runtime", { version: "7.4.4" }]
: null,
].filter(Boolean),
}, },
].filter(Boolean), ].filter(Boolean),
}; };

View File

@ -5,7 +5,7 @@ coverage:
status: status:
project: project:
default: default:
target: "80%" target: "90%"
patch: patch:
enabled: false enabled: false
ignore: ignore:

View File

@ -1,6 +1,6 @@
{ {
"name": "@babel/plugin-codemod-object-assign-to-object-spread", "name": "@babel/plugin-codemod-object-assign-to-object-spread",
"version": "7.0.0", "version": "7.7.4",
"description": "Transforms Object.assign into object spread syntax", "description": "Transforms Object.assign into object spread syntax",
"repository": "https://github.com/babel/babel/tree/master/codemods/babel-plugin-codemod-object-assign-to-object-spread", "repository": "https://github.com/babel/babel/tree/master/codemods/babel-plugin-codemod-object-assign-to-object-spread",
"license": "MIT", "license": "MIT",
@ -13,16 +13,13 @@
"@babel/plugin" "@babel/plugin"
], ],
"dependencies": { "dependencies": {
"@babel/plugin-syntax-object-rest-spread": "^7.0.0" "@babel/plugin-syntax-object-rest-spread": "^7.7.4"
}, },
"peerDependencies": { "peerDependencies": {
"@babel/core": "^7.0.0-0 || csx" "@babel/core": "^7.0.0-0 || csx"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.0.0", "@babel/core": "^7.7.4",
"@babel/helper-plugin-test-runner": "^7.0.0" "@babel/helper-plugin-test-runner": "^7.7.4"
},
"publishConfig": {
"access": "public"
} }
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "@babel/plugin-codemod-optional-catch-binding", "name": "@babel/plugin-codemod-optional-catch-binding",
"version": "7.0.0", "version": "7.7.4",
"description": "Remove unused catch bindings", "description": "Remove unused catch bindings",
"repository": "https://github.com/babel/babel/tree/master/codemods/babel-plugin-codemod-remove-unused-catch-binding", "repository": "https://github.com/babel/babel/tree/master/codemods/babel-plugin-codemod-remove-unused-catch-binding",
"license": "MIT", "license": "MIT",
@ -13,13 +13,13 @@
"@babel/plugin" "@babel/plugin"
], ],
"dependencies": { "dependencies": {
"@babel/plugin-syntax-optional-catch-binding": "^7.0.0" "@babel/plugin-syntax-optional-catch-binding": "^7.7.4"
}, },
"peerDependencies": { "peerDependencies": {
"@babel/core": "^7.0.0-0 || csx" "@babel/core": "^7.0.0-0 || csx"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.0.0", "@babel/core": "^7.7.4",
"@babel/helper-plugin-test-runner": "^7.0.0" "@babel/helper-plugin-test-runner": "^7.7.4"
} }
} }

View File

@ -1,3 +1,3 @@
{ {
"plugins": ["../../../../lib"] "plugins": ["../../../../lib"]
} }

View File

@ -0,0 +1,4 @@
src
test
.*
*.log

View File

@ -0,0 +1,4 @@
## @babel/eslint-config-internal
---
ESLint config for the Babel codebase (originally taken from `eslint-config-kittens`)

View File

@ -0,0 +1,49 @@
"use strict";
module.exports = {
parser: "babel-eslint",
extends: "eslint:recommended",
plugins: ["flowtype"],
parserOptions: {
ecmaVersion: 2020,
sourceType: "module",
},
globals: {
// Flow
Iterator: true,
$Keys: true,
},
env: {
node: true,
es2020: true,
browser: true,
},
rules: {
camelcase: "off",
"consistent-return": "off",
curly: ["error", "multi-line"],
"linebreak-style": ["error", "unix"],
"new-cap": "off",
"no-case-declarations": "error",
"no-cond-assign": "off",
"no-confusing-arrow": "error",
"no-console": "off",
"no-constant-condition": "off",
"no-empty": "off",
"no-fallthrough": "off",
"no-inner-declarations": "off",
"no-labels": "off",
"no-loop-func": "off",
"no-process-exit": "off",
"no-return-assign": "off",
"no-shadow": "off",
"no-underscore-dangle": "off",
"no-unreachable": "off",
"no-use-before-define": "off",
"no-var": "error",
"prefer-const": "error",
strict: "off",
"flowtype/define-flow-type": "warn",
"flowtype/use-flow-type": "warn",
},
};

View File

@ -0,0 +1,15 @@
{
"name": "@babel/eslint-config-internal",
"version": "7.8.3-csx.2",
"description": "The Babel Team's ESLint configuration. Since it's internal, it might not respect semver.",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://babeljs.io/",
"license": "MIT",
"private": true,
"repository": "https://github.com/babel/babel/tree/master/eslint/babel-eslint-config-internal",
"main": "lib/index.js",
"peerDependencies": {
"babel-eslint": "^10.0.0 || ^11.0.0-0",
"eslint-plugin-flowtype": "^3.0.0"
}
}

View File

@ -0,0 +1,4 @@
src
test
.*
*.log

View File

@ -0,0 +1,124 @@
# @babel/eslint-parser [![npm](https://img.shields.io/npm/v/@babel/eslint-parser.svg)](https://www.npmjs.com/package/@babel/eslint-parser) [![travis](https://img.shields.io/travis/babel/@babel/eslint-parser/master.svg)](https://travis-ci.org/babel/@babel/eslint-parser) [![npm-downloads](https://img.shields.io/npm/dm/@babel/eslint-parser.svg)](https://www.npmjs.com/package/@babel/eslint-parser)
**@babel/eslint-parser** allows you to lint **ALL** valid Babel code with the fantastic
[ESLint](https://github.com/eslint/eslint).
## When should I use @babel/eslint-parser?
ESLint's default parser and core rules [only support the latest final ECMAScript standard](https://github.com/eslint/eslint/blob/a675c89573836adaf108a932696b061946abf1e6/README.md#what-about-experimental-features) and do not support experimental (such as new features) and non-standard (such as Flow or TypeScript types) syntax provided by Babel. @babel/eslint-parser is a parser that allows ESLint to run on source code that is transformed by Babel.
**Note:** You only need to use @babel/parser-eslint if you are using Babel to transform your code. If this is not the case, please use the relevant parser for your chosen flavor of ECMAScript (note that the default parser supports all non-experimental syntax as well as JSX).
## How does it work?
ESLint allows for the use of [custom parsers](https://eslint.org/docs/developer-guide/working-with-custom-parsers). When using this plugin, your code is parsed by Babel's parser (using the configuration specified in your [Babel configuration file](https://babeljs.io/docs/en/configuration)) and the resulting AST is
transformed into an [ESTree](https://github.com/estree/estree)-compliant structure that ESLint can understand. All location info such as line numbers,
columns is also retained so you can track down errors with ease.
**Note:** ESLint's core rules do not support experimental syntax and may therefore not work as expected when using `@babel/eslint-parser`. Please use the companion [`@babel/eslint-plugin`](https://github.com/babel/babel/tree/master/eslint/babel-eslint-plugin) plugin for core rules that you have issues with.
## Usage
### Installation
```sh
$ npm install eslint @babel/core @babel/eslint-parser --save-dev
# or
$ yarn add eslint @babel/core @babel/eslint-parser -D
```
**Note:** @babel/eslint-parser requires `@babel/core@>=7.2.0` and a valid Babel configuration file to run. If you do not have this already set up, please see the [Babel Usage Guide](https://babeljs.io/docs/en/usage).
### Setup
To use @babel/eslint-parser, `"@babel/eslint-parser"` must be specified as the `parser` in your ESLint configuration file (see [here](https://eslint.org/docs/user-guide/configuring#specifying-parser) for more detailed information).
**.eslintrc.js**
```js
module.exports = {
parser: "@babel/eslint-parser",
};
```
With the parser set, your configuration can be configured as described in the [Configuring ESLint](https://eslint.org/docs/user-guide/configuring) documentation.
**Note:** The `parserOptions` described in the [official documentation](https://eslint.org/docs/user-guide/configuring#specifying-parser-options) are for the default parser and are not necessarily supported by @babel/eslint-parser. Please see the section directly below for supported `parserOptions`.
### Additional parser configuration
Additional configuration options can be set in your ESLint configuration under the `parserOptions` key. Please note that the `ecmaFeatures` config property may still be required for ESLint to work properly with features not in ECMAScript 5 by default.
- `requireConfigFile` (default `true`) can be set to `false` to allow @babel/eslint-parser to run on files that do not have a Babel configuration associated with them. This can be useful for linting files that are not transformed by Babel (such as tooling configuration files), though we recommend using the default parser via [glob-based configuration](https://eslint.org/docs/user-guide/configuring#configuration-based-on-glob-patterns). Note: @babel/eslint-parser will not parse any experimental syntax when no configuration file is found.
- `sourceType` can be set to `"module"`(default) or `"script"` if your code isn't using ECMAScript modules.
- `allowImportExportEverywhere` (default `false`) can be set to `true` to allow import and export declarations to appear anywhere a statement is allowed if your build environment supports that. Otherwise import and export declarations can only appear at a program's top level.
- `ecmaFeatures.globalReturn` (default `false`) allow return statements in the global scope when used with `sourceType: "script"`.
- `babelOptions` passes through Babel's configuration [loading](https://babeljs.io/docs/en/options#config-loading-options) and [merging](https://babeljs.io/docs/en/options#config-merging-options) options (for instance, in case of a monorepo). When not defined, @babel/eslint-parser will use Babel's default configuration file resolution logic.
**.eslintrc.js**
```js
module.exports = {
parser: "@babel/eslint-parser",
parserOptions: {
sourceType: "module",
allowImportExportEverywhere: false,
ecmaFeatures: {
globalReturn: false,
},
babelOptions: {
configFile: "path/to/config.js",
},
},
};
```
**.eslintrc.js using glob-based configuration**
This configuration would use the default parser for all files except for those found by the `"files/transformed/by/babel/*.js"` glob.
```js
module.exports = {
rules: {
indent: "error"
},
overrides: [
{
files: ["files/transformed/by/babel/*.js"],
parser: "@babel/eslint-parser",
}
]
};
```
### Run
```sh
$ ./node_modules/.bin/eslint yourfile.js
```
## Known issues
Flow:
> Check out [eslint-plugin-flowtype](https://github.com/gajus/eslint-plugin-flowtype): An `eslint` plugin that makes flow type annotations global variables and marks declarations as used. Solves the problem of false positives with `no-undef` and `no-unused-vars`.
- `no-undef` for global flow types: `ReactElement`, `ReactClass` [#130](https://github.com/babel/@babel/eslint-parser/issues/130#issuecomment-111215076)
- Workaround: define types as globals in `.eslintrc` or define types and import them `import type ReactElement from './types'`
- `no-unused-vars/no-undef` with Flow declarations (`declare module A {}`) [#132](https://github.com/babel/@babel/eslint-parser/issues/132#issuecomment-112815926)
Modules/strict mode
- `no-unused-vars: ["error", { vars: local }]` [#136](https://github.com/babel/@babel/eslint-parser/issues/136)
Please check out [eslint-plugin-react](https://github.com/yannickcr/eslint-plugin-react) for React/JSX issues.
- `no-unused-vars` with jsx
Please check out [eslint-plugin-babel](https://github.com/babel/eslint-plugin-babel) for other issues.
## Questions and support
If you have an issue, please first check if it can be reproduced with the default parser and with the latest versions of `eslint` and `@babel/eslint-parser`. If it is not reproducible with the default parser, it is most likely an issue with `@babel/eslint-parser`.
For questions and support please visit the [`#discussion`](https://babeljs.slack.com/messages/discussion/) Babel Slack channel (sign up [here](https://github.com/babel/notes/issues/38)) or the ESLint [Gitter](https://gitter.im/eslint/eslint).

View File

@ -0,0 +1,37 @@
{
"name": "@babel/eslint-parser",
"version": "7.8.3-csx.2",
"description": "ESLint parser that allows for linting of experimental syntax transformed by Babel",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"license": "MIT",
"private": true,
"repository": {
"type": "git",
"url": "https://github.com/babel/babel.git",
"directory": "eslint/babel-eslint-parser"
},
"bugs": {
"url": "https://github.com/babel/babel/issues"
},
"homepage": "https://github.com/babel/babel/tree/master/eslint/babel-eslint-parser",
"engines": {
"node": ">=10.9"
},
"main": "lib/index.js",
"peerDependencies": {
"@babel/core": ">=7.2.0",
"eslint": ">=6.0.0"
},
"dependencies": {
"eslint-scope": "5.0.0",
"eslint-visitor-keys": "^1.1.0",
"semver": "^6.3.0"
},
"devDependencies": {
"@babel/core": "^7.2.0",
"@babel/eslint-shared-fixtures": "7.8.3-csx.2",
"dedent": "^0.7.0",
"eslint": "^6.0.1",
"espree": "^6.0.0"
}
}

View File

@ -0,0 +1,344 @@
import { types as t } from "@babel/core";
import escope from "eslint-scope";
import { Definition } from "eslint-scope/lib/definition";
import OriginalPatternVisitor from "eslint-scope/lib/pattern-visitor";
import OriginalReferencer from "eslint-scope/lib/referencer";
import { getKeys as fallback } from "eslint-visitor-keys";
import childVisitorKeys from "./visitor-keys";
const flowFlippedAliasKeys = t.FLIPPED_ALIAS_KEYS.Flow.concat([
"ArrayPattern",
"ClassDeclaration",
"ClassExpression",
"FunctionDeclaration",
"FunctionExpression",
"Identifier",
"ObjectPattern",
"RestElement",
]);
const visitorKeysMap = Object.entries(t.VISITOR_KEYS).reduce(
(acc, [key, value]) => {
if (!flowFlippedAliasKeys.includes(value)) {
acc[key] = value;
}
return acc;
},
{},
);
const propertyTypes = {
// loops
callProperties: { type: "loop", values: ["value"] },
indexers: { type: "loop", values: ["key", "value"] },
properties: { type: "loop", values: ["argument", "value"] },
types: { type: "loop" },
params: { type: "loop" },
// single property
argument: { type: "single" },
elementType: { type: "single" },
qualification: { type: "single" },
rest: { type: "single" },
returnType: { type: "single" },
// others
typeAnnotation: { type: "typeAnnotation" },
typeParameters: { type: "typeParameters" },
id: { type: "id" },
};
class PatternVisitor extends OriginalPatternVisitor {
ArrayPattern(node) {
node.elements.forEach(this.visit, this);
}
ObjectPattern(node) {
node.properties.forEach(this.visit, this);
}
}
class Referencer extends OriginalReferencer {
// inherits.
visitPattern(node, options, callback) {
if (!node) {
return;
}
// Visit type annotations.
this._checkIdentifierOrVisit(node.typeAnnotation);
if (t.isAssignmentPattern(node)) {
this._checkIdentifierOrVisit(node.left.typeAnnotation);
}
// Overwrite `super.visitPattern(node, options, callback)` in order to not visit `ArrayPattern#typeAnnotation` and `ObjectPattern#typeAnnotation`.
if (typeof options === "function") {
callback = options;
options = { processRightHandNodes: false };
}
const visitor = new PatternVisitor(this.options, node, callback);
visitor.visit(node);
// Process the right hand nodes recursively.
if (options.processRightHandNodes) {
visitor.rightHandNodes.forEach(this.visit, this);
}
}
// inherits.
visitClass(node) {
// Decorators.
this._visitArray(node.decorators);
// Flow type parameters.
const typeParamScope = this._nestTypeParamScope(node);
// Flow super types.
this._visitTypeAnnotation(node.implements);
this._visitTypeAnnotation(
node.superTypeParameters && node.superTypeParameters.params,
);
// Basic.
super.visitClass(node);
// Close the type parameter scope.
if (typeParamScope) {
this.close(node);
}
}
// inherits.
visitFunction(node) {
const typeParamScope = this._nestTypeParamScope(node);
// Flow return types.
this._checkIdentifierOrVisit(node.returnType);
// Basic.
super.visitFunction(node);
// Close the type parameter scope.
if (typeParamScope) {
this.close(node);
}
}
// inherits.
visitProperty(node) {
if (node.value?.type === "TypeCastExpression") {
this._visitTypeAnnotation(node.value);
}
this._visitArray(node.decorators);
super.visitProperty(node);
}
InterfaceDeclaration(node) {
this._createScopeVariable(node, node.id);
const typeParamScope = this._nestTypeParamScope(node);
// TODO: Handle mixins
this._visitArray(node.extends);
this.visit(node.body);
if (typeParamScope) {
this.close(node);
}
}
TypeAlias(node) {
this._createScopeVariable(node, node.id);
const typeParamScope = this._nestTypeParamScope(node);
this.visit(node.right);
if (typeParamScope) {
this.close(node);
}
}
ClassProperty(node) {
this._visitClassProperty(node);
}
ClassPrivateProperty(node) {
this._visitClassProperty(node);
}
// TODO: Update to visit type annotations when TypeScript/Flow support this syntax.
ClassPrivateMethod(node) {
super.MethodDefinition(node);
}
DeclareModule(node) {
this._visitDeclareX(node);
}
DeclareFunction(node) {
this._visitDeclareX(node);
}
DeclareVariable(node) {
this._visitDeclareX(node);
}
DeclareClass(node) {
this._visitDeclareX(node);
}
// visit OptionalMemberExpression as a MemberExpression.
OptionalMemberExpression(node) {
super.MemberExpression(node);
}
_visitClassProperty(node) {
this._visitTypeAnnotation(node.typeAnnotation);
this.visitProperty(node);
}
_visitDeclareX(node) {
if (node.id) {
this._createScopeVariable(node, node.id);
}
const typeParamScope = this._nestTypeParamScope(node);
if (typeParamScope) {
this.close(node);
}
}
_createScopeVariable(node, name) {
this.currentScope().variableScope.__define(
name,
new Definition("Variable", name, node, null, null, null),
);
}
_nestTypeParamScope(node) {
if (!node.typeParameters) {
return null;
}
const parentScope = this.scopeManager.__currentScope;
const scope = new escope.Scope(
this.scopeManager,
"type-parameters",
parentScope,
node,
false,
);
this.scopeManager.__nestScope(scope);
for (let j = 0; j < node.typeParameters.params.length; j++) {
const name = node.typeParameters.params[j];
scope.__define(name, new Definition("TypeParameter", name, name));
if (name.typeAnnotation) {
this._checkIdentifierOrVisit(name);
}
}
scope.__define = function() {
return parentScope.__define.apply(parentScope, arguments);
};
return scope;
}
_visitTypeAnnotation(node) {
if (!node) {
return;
}
if (Array.isArray(node)) {
node.forEach(this._visitTypeAnnotation, this);
return;
}
// get property to check (params, id, etc...)
const visitorValues = visitorKeysMap[node.type];
if (!visitorValues) {
return;
}
// can have multiple properties
for (let i = 0; i < visitorValues.length; i++) {
const visitorValue = visitorValues[i];
const propertyType = propertyTypes[visitorValue];
const nodeProperty = node[visitorValue];
// check if property or type is defined
if (propertyType == null || nodeProperty == null) {
continue;
}
if (propertyType.type === "loop") {
for (let j = 0; j < nodeProperty.length; j++) {
if (Array.isArray(propertyType.values)) {
for (let k = 0; k < propertyType.values.length; k++) {
const loopPropertyNode = nodeProperty[j][propertyType.values[k]];
if (loopPropertyNode) {
this._checkIdentifierOrVisit(loopPropertyNode);
}
}
} else {
this._checkIdentifierOrVisit(nodeProperty[j]);
}
}
} else if (propertyType.type === "single") {
this._checkIdentifierOrVisit(nodeProperty);
} else if (propertyType.type === "typeAnnotation") {
this._visitTypeAnnotation(node.typeAnnotation);
} else if (propertyType.type === "typeParameters") {
for (let l = 0; l < node.typeParameters.params.length; l++) {
this._checkIdentifierOrVisit(node.typeParameters.params[l]);
}
} else if (propertyType.type === "id") {
if (node.id.type === "Identifier") {
this._checkIdentifierOrVisit(node.id);
} else {
this._visitTypeAnnotation(node.id);
}
}
}
}
_checkIdentifierOrVisit(node) {
if (node?.typeAnnotation) {
this._visitTypeAnnotation(node.typeAnnotation);
} else if (node?.type === "Identifier") {
this.visit(node);
} else {
this._visitTypeAnnotation(node);
}
}
_visitArray(nodeList) {
if (nodeList) {
for (const node of nodeList) {
this.visit(node);
}
}
}
}
export default function(ast, parserOptions) {
const options = {
ignoreEval: true,
optimistic: false,
directive: false,
nodejsScope:
ast.sourceType === "script" &&
(parserOptions.ecmaFeatures &&
parserOptions.ecmaFeatures.globalReturn) === true,
impliedStrict: false,
sourceType: ast.sourceType,
ecmaVersion: parserOptions.ecmaVersion,
fallback,
};
options.childVisitorKeys = childVisitorKeys;
const scopeManager = new escope.ScopeManager(options);
const referencer = new Referencer(options, scopeManager);
referencer.visit(ast);
return scopeManager;
}

View File

@ -0,0 +1,96 @@
import { types as t, traverse } from "@babel/core";
import convertProgramNode from "./convertProgramNode";
const astTransformVisitor = {
noScope: true,
enter(path) {
const node = path.node;
// private var to track original node type
node._babelType = node.type;
if (node.innerComments) {
delete node.innerComments;
}
if (node.trailingComments) {
delete node.trailingComments;
}
if (node.leadingComments) {
delete node.leadingComments;
}
},
exit(path) {
const node = path.node;
if (path.isTypeParameter()) {
node.type = "Identifier";
node.typeAnnotation = node.bound;
delete node.bound;
}
// flow: prevent "no-undef"
// for "Component" in: "let x: React.Component"
if (path.isQualifiedTypeIdentifier()) {
delete node.id;
}
// for "b" in: "var a: { b: Foo }"
if (path.isObjectTypeProperty()) {
delete node.key;
}
// for "indexer" in: "var a: {[indexer: string]: number}"
if (path.isObjectTypeIndexer()) {
delete node.id;
}
// for "param" in: "var a: { func(param: Foo): Bar };"
if (path.isFunctionTypeParam()) {
delete node.name;
}
// modules
if (path.isImportDeclaration()) {
delete node.isType;
}
// template string range fixes
if (path.isTemplateLiteral()) {
for (let i = 0; i < node.quasis.length; i++) {
const q = node.quasis[i];
q.range[0] -= 1;
if (q.tail) {
q.range[1] += 1;
} else {
q.range[1] += 2;
}
q.loc.start.column -= 1;
if (q.tail) {
q.loc.end.column += 1;
} else {
q.loc.end.column += 2;
}
}
}
},
};
export default function(ast, code) {
const state = { source: code };
// Monkey patch visitor keys in order to be able to traverse the estree nodes
t.VISITOR_KEYS.Property = t.VISITOR_KEYS.ObjectProperty;
t.VISITOR_KEYS.MethodDefinition = [
"key",
"value",
"decorators",
"returnType",
"typeParameters",
];
traverse(ast, astTransformVisitor, null, state);
delete t.VISITOR_KEYS.Property;
delete t.VISITOR_KEYS.MethodDefinition;
convertProgramNode(ast);
}

View File

@ -0,0 +1,15 @@
export default function(comments) {
for (let i = 0; i < comments.length; i++) {
const comment = comments[i];
if (comment.type === "CommentBlock") {
comment.type = "Block";
} else if (comment.type === "CommentLine") {
comment.type = "Line";
}
// sometimes comments don't get ranges computed,
// even with options.ranges === true
if (!comment.range) {
comment.range = [comment.start, comment.end];
}
}
}

View File

@ -0,0 +1,38 @@
export default function(ast) {
ast.type = "Program";
ast.sourceType = ast.program.sourceType;
ast.directives = ast.program.directives;
ast.body = ast.program.body;
delete ast.program;
if (ast.comments.length) {
const lastComment = ast.comments[ast.comments.length - 1];
if (!ast.tokens.length) {
// if no tokens, the program starts at the end of the last comment
ast.start = lastComment.end;
ast.loc.start.line = lastComment.loc.end.line;
ast.loc.start.column = lastComment.loc.end.column;
} else {
const lastToken = ast.tokens[ast.tokens.length - 1];
if (lastComment.end > lastToken.end) {
// If there is a comment after the last token, the program ends at the
// last token and not the comment
ast.range[1] = lastToken.end;
ast.loc.end.line = lastToken.loc.end.line;
ast.loc.end.column = lastToken.loc.end.column;
}
}
} else {
if (!ast.tokens.length) {
ast.loc.start.line = 1;
ast.loc.end.line = 1;
}
}
if (ast.body && ast.body.length > 0) {
ast.loc.start.line = ast.body[0].loc.start.line;
ast.range[0] = ast.body[0].start;
}
}

View File

@ -0,0 +1,92 @@
import { tokTypes as tt } from "@babel/core";
export default function(tokens) {
let curlyBrace = null;
let templateTokens = [];
const result = [];
function addTemplateType() {
const start = templateTokens[0];
const end = templateTokens[templateTokens.length - 1];
const value = templateTokens.reduce((result, token) => {
if (token.value) {
result += token.value;
} else if (token.type !== tt.template) {
result += token.type.label;
}
return result;
}, "");
result.push({
type: "Template",
value: value,
start: start.start,
end: end.end,
loc: {
start: start.loc.start,
end: end.loc.end,
},
});
templateTokens = [];
}
tokens.forEach(token => {
switch (token.type) {
case tt.backQuote:
if (curlyBrace) {
result.push(curlyBrace);
curlyBrace = null;
}
templateTokens.push(token);
if (templateTokens.length > 1) {
addTemplateType();
}
break;
case tt.dollarBraceL:
templateTokens.push(token);
addTemplateType();
break;
case tt.braceR:
if (curlyBrace) {
result.push(curlyBrace);
}
curlyBrace = token;
break;
case tt.template:
if (curlyBrace) {
templateTokens.push(curlyBrace);
curlyBrace = null;
}
templateTokens.push(token);
break;
case tt.eof:
if (curlyBrace) {
result.push(curlyBrace);
}
break;
default:
if (curlyBrace) {
result.push(curlyBrace);
curlyBrace = null;
}
result.push(token);
}
});
return result;
}

View File

@ -0,0 +1,88 @@
import { tokTypes as tt } from "@babel/core";
export default function(token, source) {
const type = token.type;
token.range = [token.start, token.end];
if (type === tt.name) {
token.type = "Identifier";
} else if (
type === tt.semi ||
type === tt.comma ||
type === tt.parenL ||
type === tt.parenR ||
type === tt.braceL ||
type === tt.braceR ||
type === tt.slash ||
type === tt.dot ||
type === tt.bracketL ||
type === tt.bracketR ||
type === tt.ellipsis ||
type === tt.arrow ||
type === tt.pipeline ||
type === tt.star ||
type === tt.incDec ||
type === tt.colon ||
type === tt.question ||
type === tt.questionDot ||
type === tt.template ||
type === tt.backQuote ||
type === tt.dollarBraceL ||
type === tt.at ||
type === tt.logicalOR ||
type === tt.logicalAND ||
type === tt.nullishCoalescing ||
type === tt.bitwiseOR ||
type === tt.bitwiseXOR ||
type === tt.bitwiseAND ||
type === tt.equality ||
type === tt.relational ||
type === tt.bitShift ||
type === tt.plusMin ||
type === tt.modulo ||
type === tt.exponent ||
type === tt.bang ||
type === tt.tilde ||
type === tt.doubleColon ||
type === tt.hash ||
type.isAssign
) {
token.type = "Punctuator";
if (!token.value) token.value = type.label;
} else if (type === tt.jsxTagStart) {
token.type = "Punctuator";
token.value = "<";
} else if (type === tt.jsxTagEnd) {
token.type = "Punctuator";
token.value = ">";
} else if (type === tt.jsxName) {
token.type = "JSXIdentifier";
} else if (type === tt.jsxText) {
token.type = "JSXText";
} else if (type.keyword === "null") {
token.type = "Null";
} else if (type.keyword === "false" || type.keyword === "true") {
token.type = "Boolean";
} else if (type.keyword) {
token.type = "Keyword";
} else if (type === tt.num) {
token.type = "Numeric";
token.value = source.slice(token.start, token.end);
} else if (type === tt.string) {
token.type = "String";
token.value = source.slice(token.start, token.end);
} else if (type === tt.regexp) {
token.type = "RegularExpression";
const value = token.value;
token.regex = {
pattern: value.pattern,
flags: value.flags,
};
token.value = `/${value.pattern}/${value.flags}`;
} else if (type === tt.bigint) {
token.type = "Numeric";
token.value = `${token.value}n`;
}
return token;
}

View File

@ -0,0 +1,8 @@
import convertTemplateType from "./convertTemplateType";
import convertToken from "./convertToken";
export default function(tokens, code) {
return convertTemplateType(tokens)
.filter(t => t.type !== "CommentLine" && t.type !== "CommentBlock")
.map(t => convertToken(t, code));
}

View File

@ -0,0 +1,9 @@
import convertTokens from "./convertTokens";
import convertComments from "./convertComments";
import convertAST from "./convertAST";
export default function(ast, code) {
ast.tokens = convertTokens(ast.tokens, code);
convertComments(ast.comments);
convertAST(ast, code);
}

View File

@ -0,0 +1,61 @@
import { loadPartialConfig } from "@babel/core";
export function normalizeESLintConfig(options) {
const defaultOptions = {
babelOptions: {},
ecmaVersion: 2020,
sourceType: "module",
allowImportExportEverywhere: false,
};
return Object.assign(defaultOptions, options);
}
export function normalizeBabelParseConfig(options) {
const parseOptions = {
sourceType: options.sourceType,
filename: options.filePath,
cwd: options.babelOptions.cwd,
root: options.babelOptions.root,
rootMode: options.babelOptions.rootMode,
envName: options.babelOptions.envName,
configFile: options.babelOptions.configFile,
babelrc: options.babelOptions.babelrc,
babelrcRoots: options.babelOptions.babelrcRoots,
extends: options.babelOptions.extends,
env: options.babelOptions.env,
overrides: options.babelOptions.overrides,
test: options.babelOptions.test,
include: options.babelOptions.include,
exclude: options.babelOptions.exclude,
ignore: options.babelOptions.ignore,
only: options.babelOptions.only,
parserOpts: {
allowImportExportEverywhere: options.allowImportExportEverywhere,
allowReturnOutsideFunction: true,
allowSuperOutsideMethod: true,
ranges: true,
tokens: true,
plugins: ["estree"],
},
caller: {
name: "@babel/eslint-parser",
},
};
if (options.requireConfigFile !== false) {
const config = loadPartialConfig(parseOptions);
if (config !== null) {
if (!config.hasFilesystemConfig()) {
throw new Error(
`No Babel config file detected for ${config.options.filename}. Either disable config file checking with requireConfigFile: false, or configure Babel so that it can find the config files.`,
);
}
return config.options;
}
}
return parseOptions;
}

View File

@ -0,0 +1,26 @@
import semver from "semver";
import { version as CURRENT_BABEL_VERSION } from "@babel/core";
import parseWithScope from "./parse-with-scope";
import { normalizeESLintConfig } from "./configuration";
import packageJson from "../package.json";
const SUPPORTED_BABEL_VERSION_RANGE =
packageJson.peerDependencies["@babel/core"];
const IS_RUNNING_SUPPORTED_VERSION = semver.satisfies(
semver.coerce(CURRENT_BABEL_VERSION).raw,
SUPPORTED_BABEL_VERSION_RANGE,
);
export function parse(code, options) {
return parseForESLint(code, options).ast;
}
export function parseForESLint(code, options = {}) {
if (!IS_RUNNING_SUPPORTED_VERSION) {
throw new Error(
`babel-eslint@${packageJson.version} does not support @babel/core@${CURRENT_BABEL_VERSION}. Please downgrade to babel-eslint@^10 or upgrade to @babel/core@${SUPPORTED_BABEL_VERSION_RANGE}`,
);
}
return parseWithScope(code, normalizeESLintConfig(options));
}

View File

@ -0,0 +1,10 @@
import visitorKeys from "./visitor-keys";
import analyzeScope from "./analyze-scope";
import parse from "./parse";
export default function(code, options) {
const ast = parse(code, options);
const scopeManager = analyzeScope(ast, options);
return { ast, scopeManager, visitorKeys };
}

View File

@ -0,0 +1,23 @@
import { parseSync as babelParse } from "@babel/core";
import babylonToEspree from "./babylon-to-espree";
import { normalizeBabelParseConfig } from "./configuration";
export default function parse(code, options) {
const parseOptions = normalizeBabelParseConfig(options);
let ast;
try {
ast = babelParse(code, parseOptions);
} catch (err) {
if (err instanceof SyntaxError) {
err.lineNumber = err.loc.line;
err.column = err.loc.column;
}
throw err;
}
babylonToEspree(ast, code);
return ast;
}

View File

@ -0,0 +1,15 @@
import { types as t } from "@babel/core";
import { KEYS as ESLINT_VISITOR_KEYS } from "eslint-visitor-keys";
const { VISITOR_KEYS: BABEL_VISITOR_KEYS } = t;
export default Object.assign(
{
Literal: ESLINT_VISITOR_KEYS.Literal,
MethodDefinition: ["decorators"].concat(
ESLINT_VISITOR_KEYS.MethodDefinition,
),
Property: ["decorators"].concat(ESLINT_VISITOR_KEYS.Property),
},
BABEL_VISITOR_KEYS,
);

View File

@ -0,0 +1,535 @@
import assert from "assert";
import espree from "espree";
import escope from "eslint-scope";
import unpad from "dedent";
import { parseForESLint } from "../src";
import assertImplementsAST from "./helpers/assert-implements-ast";
const babelOptions = {
configFile: require.resolve(
"@babel/eslint-shared-fixtures/config/babel.config.js",
),
};
function parseAndAssertSame(code) {
code = unpad(code);
const esAST = espree.parse(code, {
ecmaFeatures: {
// enable JSX parsing
jsx: true,
// enable return in global scope
globalReturn: true,
// enable implied strict mode (if ecmaVersion >= 5)
impliedStrict: true,
// allow experimental object rest/spread
experimentalObjectRestSpread: true,
},
tokens: true,
loc: true,
range: true,
comment: true,
ecmaVersion: 2020,
sourceType: "module",
});
const babylonAST = parseForESLint(code, {
eslintVisitorKeys: true,
eslintScopeManager: true,
babelOptions,
}).ast;
assertImplementsAST(esAST, babylonAST);
}
describe("babylon-to-espree", () => {
describe("compatibility", () => {
it("should allow ast.analyze to be called without options", function() {
const esAST = parseForESLint("`test`", {
eslintScopeManager: true,
eslintVisitorKeys: true,
babelOptions,
}).ast;
expect(() => {
escope.analyze(esAST);
}).not.toThrow(new TypeError("Should allow no options argument."));
});
});
describe("templates", () => {
it("empty template string", () => {
parseAndAssertSame("``");
});
it("template string", () => {
parseAndAssertSame("`test`");
});
it("template string using $", () => {
parseAndAssertSame("`$`");
});
it("template string with expression", () => {
parseAndAssertSame("`${a}`");
});
it("template string with multiple expressions", () => {
parseAndAssertSame("`${a}${b}${c}`");
});
it("template string with expression and strings", () => {
parseAndAssertSame("`a${a}a`");
});
it("template string with binary expression", () => {
parseAndAssertSame("`a${a + b}a`");
});
it("tagged template", () => {
parseAndAssertSame("jsx`<Button>Click</Button>`");
});
it("tagged template with expression", () => {
parseAndAssertSame("jsx`<Button>Hi ${name}</Button>`");
});
it("tagged template with new operator", () => {
parseAndAssertSame("new raw`42`");
});
it("template with nested function/object", () => {
parseAndAssertSame(
"`outer${{x: {y: 10}}}bar${`nested${function(){return 1;}}endnest`}end`",
);
});
it("template with braces inside and outside of template string #96", () => {
parseAndAssertSame(
"if (a) { var target = `{}a:${webpackPort}{}}}}`; } else { app.use(); }",
);
});
it("template also with braces #96", () => {
parseAndAssertSame(`
export default function f1() {
function f2(foo) {
const bar = 3;
return \`\${foo} \${bar}\`;
}
return f2;
}
`);
});
it("template with destructuring #31", () => {
parseAndAssertSame(`
module.exports = {
render() {
var {name} = this.props;
return Math.max(null, \`Name: \${name}, Name: \${name}\`);
}
};
`);
});
it("template with arrow returning template #603", () => {
parseAndAssertSame(`
var a = \`\${() => {
\`\${''}\`
}}\`;
`);
});
it("template string with object with template string inside", () => {
parseAndAssertSame("`${ { a:`${2}` } }`");
});
});
it("simple expression", () => {
parseAndAssertSame("a = 1");
});
it("logical NOT", () => {
parseAndAssertSame("!0");
});
it("bitwise NOT", () => {
parseAndAssertSame("~0");
});
it("class declaration", () => {
parseAndAssertSame("class Foo {}");
});
it("class expression", () => {
parseAndAssertSame("var a = class Foo {}");
});
it("jsx expression", () => {
parseAndAssertSame("<App />");
});
it("jsx expression with 'this' as identifier", () => {
parseAndAssertSame("<this />");
});
it("jsx expression with a dynamic attribute", () => {
parseAndAssertSame("<App foo={bar} />");
});
it("jsx expression with a member expression as identifier", () => {
parseAndAssertSame("<foo.bar />");
});
it("jsx expression with spread", () => {
parseAndAssertSame("var myDivElement = <div {...this.props} />;");
});
it("empty jsx text", () => {
parseAndAssertSame("<a></a>");
});
it("jsx text with content", () => {
parseAndAssertSame("<a>Hello, world!</a>");
});
it("nested jsx", () => {
parseAndAssertSame("<div>\n<h1>Wat</h1>\n</div>");
});
it("default import", () => {
parseAndAssertSame('import foo from "foo";');
});
it("import specifier", () => {
parseAndAssertSame('import { foo } from "foo";');
});
it("import specifier with name", () => {
parseAndAssertSame('import { foo as bar } from "foo";');
});
it("import bare", () => {
parseAndAssertSame('import "foo";');
});
it("export default class declaration", () => {
parseAndAssertSame("export default class Foo {}");
});
it("export default class expression", () => {
parseAndAssertSame("export default class {}");
});
it("export default function declaration", () => {
parseAndAssertSame("export default function Foo() {}");
});
it("export default function expression", () => {
parseAndAssertSame("export default function () {}");
});
it("export all", () => {
parseAndAssertSame('export * from "foo";');
});
it("export named", () => {
parseAndAssertSame("var foo = 1;export { foo };");
});
it("export named alias", () => {
parseAndAssertSame("var foo = 1;export { foo as bar };");
});
// Espree doesn't support the optional chaining operator yet
it("optional chaining operator (token)", () => {
const code = "foo?.bar";
const babylonAST = parseForESLint(code, {
eslintVisitorKeys: true,
eslintScopeManager: true,
babelOptions,
}).ast;
assert.strictEqual(babylonAST.tokens[1].type, "Punctuator");
});
// Espree doesn't support the nullish coalescing operator yet
it("nullish coalescing operator (token)", () => {
const code = "foo ?? bar";
const babylonAST = parseForESLint(code, {
eslintVisitorKeys: true,
eslintScopeManager: true,
babelOptions,
}).ast;
assert.strictEqual(babylonAST.tokens[1].type, "Punctuator");
});
// Espree doesn't support the pipeline operator yet
it("pipeline operator (token)", () => {
const code = "foo |> bar";
const babylonAST = parseForESLint(code, {
eslintVisitorKeys: true,
eslintScopeManager: true,
babelOptions,
}).ast;
assert.strictEqual(babylonAST.tokens[1].type, "Punctuator");
});
// Espree doesn't support private fields yet
it("hash (token)", () => {
const code = "class A { #x }";
const babylonAST = parseForESLint(code, {
eslintVisitorKeys: true,
eslintScopeManager: true,
babelOptions,
}).ast;
assert.strictEqual(babylonAST.tokens[3].type, "Punctuator");
assert.strictEqual(babylonAST.tokens[3].value, "#");
});
it.skip("empty program with line comment", () => {
parseAndAssertSame("// single comment");
});
it.skip("empty program with block comment", () => {
parseAndAssertSame(" /* multiline\n * comment\n*/");
});
it("line comments", () => {
parseAndAssertSame(`
// single comment
var foo = 15; // comment next to statement
// second comment after statement
`);
});
it("block comments", () => {
parseAndAssertSame(`
/* single comment */
var foo = 15; /* comment next to statement */
/*
* multiline
* comment
*/
`);
});
it("block comments #124", () => {
parseAndAssertSame(`
React.createClass({
render() {
// return (
// <div />
// ); // <-- this is the line that is reported
}
});
`);
});
it("null", () => {
parseAndAssertSame("null");
});
it("boolean", () => {
parseAndAssertSame("if (true) {} else if (false) {}");
});
it("regexp", () => {
parseAndAssertSame("/affix-top|affix-bottom|affix|[a-z]/");
});
it("regexp", () => {
parseAndAssertSame("const foo = /foo/;");
});
it("regexp y flag", () => {
parseAndAssertSame("const foo = /foo/y;");
});
it("regexp u flag", () => {
parseAndAssertSame("const foo = /foo/u;");
});
it("regexp in a template string", () => {
parseAndAssertSame('`${/\\d/.exec("1")[0]}`');
});
it("first line is empty", () => {
parseAndAssertSame('\nimport Immutable from "immutable";');
});
it("empty", () => {
parseAndAssertSame("");
});
it("jsdoc", () => {
parseAndAssertSame(`
/**
* @param {object} options
* @return {number}
*/
const test = function({ a, b, c }) {
return a + b + c;
};
module.exports = test;
`);
});
it("empty block with comment", () => {
parseAndAssertSame(`
function a () {
try {
b();
} catch (e) {
// asdf
}
}
`);
});
describe("babel tests", () => {
it("MethodDefinition", () => {
parseAndAssertSame(`
export default class A {
a() {}
}
`);
});
it("MethodDefinition 2", () => {
parseAndAssertSame(
"export default class Bar { get bar() { return 42; }}",
);
});
it("ClassMethod", () => {
parseAndAssertSame(`
class A {
constructor() {
}
}
`);
});
it("ClassMethod multiple params", () => {
parseAndAssertSame(`
class A {
constructor(a, b, c) {
}
}
`);
});
it("ClassMethod multiline", () => {
parseAndAssertSame(`
class A {
constructor (
a,
b,
c
)
{
}
}
`);
});
it("ClassMethod oneline", () => {
parseAndAssertSame("class A { constructor(a, b, c) {} }");
});
it("ObjectMethod", () => {
parseAndAssertSame(`
var a = {
b(c) {
}
}
`);
});
it("do not allow import export everywhere", () => {
assert.throws(() => {
parseAndAssertSame('function F() { import a from "a"; }');
}, /SyntaxError: 'import' and 'export' may only appear at the top level/);
});
it("return outside function", () => {
parseAndAssertSame("return;");
});
it("super outside method", () => {
assert.throws(() => {
parseAndAssertSame("function F() { super(); }");
}, /SyntaxError: 'super' keyword outside a method/);
});
it("StringLiteral", () => {
parseAndAssertSame("");
parseAndAssertSame("");
parseAndAssertSame("a");
});
it("getters and setters", () => {
parseAndAssertSame("class A { get x ( ) { ; } }");
parseAndAssertSame(`
class A {
get x(
)
{
;
}
}
`);
parseAndAssertSame("class A { set x (a) { ; } }");
parseAndAssertSame(`
class A {
set x(a
)
{
;
}
}
`);
parseAndAssertSame(`
var B = {
get x () {
return this.ecks;
},
set x (ecks) {
this.ecks = ecks;
}
};
`);
});
it("RestOperator", () => {
parseAndAssertSame("var { a, ...b } = c");
parseAndAssertSame("var [ a, ...b ] = c");
parseAndAssertSame("var a = function (...b) {}");
});
it("SpreadOperator", () => {
parseAndAssertSame("var a = { b, ...c }");
parseAndAssertSame("var a = [ a, ...b ]");
parseAndAssertSame("var a = sum(...b)");
});
it("Async/Await", () => {
parseAndAssertSame(`
async function a() {
await 1;
}
`);
});
it("BigInt", () => {
parseAndAssertSame(`
const a = 1n;
`);
});
it("Dynamic Import", () => {
parseAndAssertSame(`
const a = import('a');
`);
});
});
});

View File

@ -0,0 +1,11 @@
root: true
# babel-eslint
parser: ../../../lib/index.js
# use eslint-plugin-import
plugins:
- import
rules:
import/no-named-as-default: error
no-unused-vars: error

View File

@ -0,0 +1 @@
export default function foo() { }

View File

@ -0,0 +1 @@
import foo from './a.js';

View File

@ -0,0 +1,4 @@
// @flow
type Foo = {};
const FlowTypeButton = ({ }: Foo) => { };

View File

@ -0,0 +1,3 @@
function x () {
"use strict";
}

View File

@ -0,0 +1 @@
function x () {}

View File

@ -0,0 +1,5 @@
"use strict";
function x () {
"use strict";
}

View File

@ -0,0 +1,3 @@
"use strict";
function x () {}

View File

@ -0,0 +1,6 @@
"use strict";
/*
The empty statement is intentional. As of now, ESLint won't enforce
string: [2, "global"] on a program with an empty body. A test for that without
massaging the AST to ESlint's input format should fail.
*/

View File

@ -0,0 +1 @@
"no use strict anywhere";

View File

@ -0,0 +1,6 @@
class ClassName {
constructor() {
},
aMethod() {}
}

View File

@ -0,0 +1,40 @@
// Checks if the source ast implements the target ast. Ignores extra keys on source ast
export default function assertImplementsAST(target, source, path) {
if (!path) {
path = [];
}
function error(text) {
const err = new Error(`At ${path.join(".")}: ${text}:`);
err.depth = path.length + 1;
throw err;
}
const typeA = target === null ? "null" : typeof target;
const typeB = source === null ? "null" : typeof source;
if (typeA !== typeB) {
error(
`have different types (${typeA} !== ${typeB}) (${target} !== ${source})`,
);
} else if (
typeA === "object" &&
["RegExp"].indexOf(target.constructor.name) !== -1 &&
target.constructor.name !== source.constructor.name
) {
error(
`object have different constructors (${target.constructor.name} !== ${source.constructor.name}`,
);
} else if (typeA === "object") {
const keysTarget = Object.keys(target);
for (const i in keysTarget) {
const key = keysTarget[i];
path.push(key);
assertImplementsAST(target[key], source[key], path);
path.pop();
}
} else if (target !== source) {
error(
`are different (${JSON.stringify(target)} !== ${JSON.stringify(source)})`,
);
}
}

View File

@ -0,0 +1,237 @@
import eslint from "eslint";
import fs from "fs";
import path from "path";
import * as parser from "../src";
eslint.linter.defineParser("current-babel-eslint", parser);
const paths = {
fixtures: path.join(__dirname, "fixtures", "rules"),
};
const encoding = "utf8";
const errorLevel = 2;
const baseEslintOpts = {
parser: "current-babel-eslint",
parserOptions: {
sourceType: "script",
requireConfigFile: false,
babelOptions: { configFile: false }
},
};
/**
* Load a fixture and run eslint.linter.verify() on it.
* Pass the return value to done().
* @param object opts
* @param function done
*/
function lint(opts, done) {
readFixture(opts.fixture, (err, src) => {
if (err) return done(err);
done(null, eslint.linter.verify(src, opts.eslint));
});
}
/**
* Read a fixture file, passing the content to done().
* @param string|array id
* @param function done
*/
function readFixture(id, done) {
if (Array.isArray(id)) id = path.join.apply(path, id);
if (!path.extname(id)) id += ".js";
fs.readFile(path.join(paths.fixtures, id), encoding, done);
}
// readFixture
describe("Rules:", () => {
describe("`strict`", strictSuite);
});
// describe
function strictSuite() {
const ruleId = "strict";
describe("when set to 'never'", () => {
const eslintOpts = Object.assign({}, baseEslintOpts, {
rules: {},
});
eslintOpts.rules[ruleId] = [errorLevel, "never"];
["global-with", "function-with"].forEach(fixture => {
it(`should error on ${fixture.match(/^[^-]+/)[0]} directive`, done => {
lint(
{
fixture: ["strict", fixture],
eslint: eslintOpts,
},
(err, report) => {
if (err) return done(err);
expect(report[0].ruleId).toBe(ruleId);
done();
},
);
});
// it
});
});
// describe
describe("when set to 'global'", () => {
const eslintOpts = Object.assign({}, baseEslintOpts, {
rules: {},
});
eslintOpts.rules[ruleId] = [errorLevel, "global"];
it("shouldn't error on single global directive", done => {
lint(
{
fixture: ["strict", "global-with"],
eslint: eslintOpts,
},
(err, report) => {
if (err) return done(err);
expect(report.length).toBe(0);
done();
},
);
});
// it
it("should error twice on global directive: no and function directive: yes", done => {
lint(
{
fixture: ["strict", "function-with"],
eslint: eslintOpts,
},
(err, report) => {
if (err) return done(err);
[0, 1].forEach(i => {
expect(report[0].ruleId).toBe(ruleId);
});
done();
},
);
});
// it
it("should error on function directive", done => {
lint(
{
fixture: ["strict", "global-with-function-with"],
eslint: eslintOpts,
},
(err, report) => {
if (err) return done(err);
expect(report[0].ruleId).toBe(ruleId);
// This is to make sure the test fails prior to adapting Babel AST
// directive representation to ESLint format. Otherwise it reports an
// error for missing global directive that masquerades as the expected
// result of the previous assertion.
expect(report[0].nodeType).not.toBe("Program");
done();
},
);
});
// it
it("should error on no directive", done => {
lint(
{
fixture: ["strict", "none"],
eslint: eslintOpts,
},
(err, report) => {
if (err) return done(err);
expect(report[0].ruleId).toBe(ruleId);
done();
},
);
});
// it
});
// describe
describe("when set to 'function'", () => {
const eslintOpts = Object.assign({}, baseEslintOpts, {
rules: {},
});
eslintOpts.rules[ruleId] = [errorLevel, "function"];
it("shouldn't error on single function directive", done => {
lint(
{
fixture: ["strict", "function-with"],
eslint: eslintOpts,
},
(err, report) => {
if (err) return done(err);
expect(report.length).toBe(0);
done();
},
);
});
// it
it("should error twice on function directive: no and global directive: yes", done => {
lint(
{
fixture: ["strict", "global-with-function-without"],
eslint: eslintOpts,
},
(err, report) => {
if (err) return done(err);
[0, 1].forEach(i => {
expect(report[i].ruleId).toBe(ruleId);
});
done();
},
);
});
// it
it("should error on only global directive", done => {
lint(
{
fixture: ["strict", "global-with"],
eslint: eslintOpts,
},
(err, report) => {
if (err) return done(err);
expect(report[0].ruleId).toBe(ruleId);
done();
},
);
});
// it
it("should error on extraneous global directive", done => {
lint(
{
fixture: ["strict", "global-with-function-with"],
eslint: eslintOpts,
},
(err, report) => {
if (err) return done(err);
expect(report[0].ruleId).toBe(ruleId);
expect(report[0].nodeType.indexOf("Function")).toBe(-1);
done();
},
);
});
// it
});
}
describe("https://github.com/babel/babel-eslint/issues/558", () => {
it("doesn't crash with eslint-plugin-import", () => {
const engine = new eslint.CLIEngine({ ignore: false });
const files = ["a.js", "b.js", "c.js"];
let fileWithPath = files.map(file =>
path.resolve(__dirname, `./fixtures/eslint-plugin-import/${file}`),
);
engine.executeOnFiles(fileWithPath);
});
});

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,4 @@
src
test
.*
*.log

View File

@ -0,0 +1,38 @@
# @babel/eslint-plugin-development
A set of eslint rules to enforce best practices in the development of Babel plugins.
## Installation
You'll first need to install [ESLint](http://eslint.org):
```
$ npm install --save-dev eslint
```
Next, install `@babel/eslint-plugin-development`:
```
$ npm install --save-dev @babel/eslint-plugin-development
```
Then, load the plugin in your `.eslintrc` configuration file. You can omit the `eslint-plugin-` prefix:
```json
{
"plugins": ["@babel/development"]
}
```
## Supported Rules
> Note: Rules marked with :wrench: are autofixable.
* `@babel/development/no-deprecated-clone` (:wrench:): Disallows using the deprecated
`t.clone(node)` and `t.cloneDeep(node)` methods from `@babel/types`. Those
calls are replaced with `t.cloneNode(node)` when using `eslint --fix`.
* `@babel/development/no-undefined-identifier`: Disallows using
`t.identifier("undefined")` to create a node which represents an `undefined`
value, since it might cause problem if `undefined` is redeclared.
* `@babel/development/plugin-name`: Requires plugins to have a `name` property, which
can be useful for debugging purposes.

View File

@ -0,0 +1,36 @@
{
"name": "@babel/eslint-plugin-development",
"version": "7.8.3-csx.2",
"description": "ESLint rules that enforce best practices in the development of Babel plugins.",
"private": true,
"keywords": [
"eslint",
"eslintplugin",
"eslint-plugin"
],
"author": {
"name": "Nicolò Ribaudo",
"email": "nicolo.ribaudo@gmail.com",
"url": "https://github.com/nicolo-ribaudo"
},
"main": "lib/index.js",
"devDependencies": {
"eslint": "^5.9.0"
},
"engines": {
"node": ">=10.9"
},
"publishConfig": {
"access": "public"
},
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/babel/babel.git",
"directory": "eslint/babel-eslint-plugin-development"
},
"bugs": {
"url": "https://github.com/babel/babel/issues"
},
"homepage": "https://github.com/babel/babel/tree/master/eslint/babel-eslint-plugin-development"
}

View File

@ -0,0 +1,11 @@
import noDeprecatedClone from "./rules/no-deprecated-clone";
import noUndefinedIdentifier from "./rules/no-undefined-identifier";
import pluginName from "./rules/plugin-name";
export default {
rules: {
"no-deprecated-clone": noDeprecatedClone,
"no-undefined-identifier": noUndefinedIdentifier,
"plugin-name": pluginName,
},
};

View File

@ -0,0 +1,39 @@
import getReferenceOrigin from "../utils/get-reference-origin";
import isFromBabelTypes from "../utils/is-from-babel-types";
export default {
meta: {
schema: [],
fixable: "code",
},
create(context) {
return {
CallExpression(node) {
const { callee } = node;
const scope = context.getScope();
const origin = getReferenceOrigin(callee, scope);
if (!origin) return;
const { name } = origin;
if (
(name === "clone" || name === "cloneDeep") &&
isFromBabelTypes(origin, scope)
) {
const isMemberExpression = callee.type === "MemberExpression";
const id = isMemberExpression ? callee.property : callee;
context.report({
node: id,
message: `t.${name}() is deprecated. Use t.cloneNode() instead.`,
fix(fixer) {
if (isMemberExpression) {
return fixer.replaceText(id, "cloneNode");
}
},
});
}
},
};
},
};

View File

@ -0,0 +1,39 @@
import getReferenceOrigin from "../utils/get-reference-origin";
import isFromBabelTypes from "../utils/is-from-babel-types";
function firstArgumentIsUndefinedString(argumentsArray) {
return (
argumentsArray.length > 0 &&
argumentsArray[0].type === "Literal" &&
argumentsArray[0].value === "undefined"
);
}
export default {
meta: {
schema: [],
},
create(context) {
return {
CallExpression(node) {
const { callee } = node;
const scope = context.getScope();
const origin = getReferenceOrigin(callee, scope);
if (!origin) return;
const { name } = origin;
if (
(name === "identifier" || name === "Identifier") &&
firstArgumentIsUndefinedString(node.arguments) &&
isFromBabelTypes(origin, scope)
) {
context.report(
node,
"Use path.scope.buildUndefinedNode() to create an undefined identifier directly.",
);
}
},
};
},
};

View File

@ -0,0 +1,50 @@
import isBabelPluginFactory from "../utils/is-babel-plugin-factory";
function getReturnValue(node) {
const { body } = node;
if (body.type === "BlockStatement") {
const returnNode = body.body.find(n => n.type === "ReturnStatement");
return returnNode && returnNode.argument;
}
// Arrow functions with implicit return
return body;
}
export default {
meta: {
schema: [],
},
create(context /*: Context */) {
let pluginFound = false;
return {
FunctionDeclaration: functionVisitor,
FunctionExpression: functionVisitor,
ArrowFunctionExpression: functionVisitor,
"Program:exit"(node) {
if (!pluginFound) {
context.report(node, "This file does not export a Babel plugin.");
}
},
};
function functionVisitor(node) {
if (!isBabelPluginFactory(node, context.getScope())) return;
const returnValue = getReturnValue(node);
if (!returnValue || returnValue.type !== "ObjectExpression") return;
pluginFound = true;
if (!returnValue.properties.some(p => p.key.name === "name")) {
context.report(
returnValue,
"This Babel plugin doesn't have a 'name' property.",
);
}
}
},
};

View File

@ -0,0 +1,22 @@
export default function getExportName(node) {
const { parent } = node;
if (parent.type === "ExportDefaultDeclaration") {
return "default";
}
if (parent.type === "ExportNamedDeclaration") {
return node.id.name;
}
if (
parent.type === "AssignmentExpression" &&
parent.left.type === "MemberExpression" &&
parent.left.object.type === "Identifier" &&
parent.left.object.name === "module" &&
parent.left.property.type === "Identifier" &&
parent.left.property.name === "exports"
) {
return "module.exports";
}
}

View File

@ -0,0 +1,141 @@
/*::
type ReferenceOriginImport = { kind: "import", source: string, name: string };
type ReferenceOriginParam = {
kind: "param",
index: number,
functionNode: Node,
};
type ReferenceOrigin =
| ReferenceOriginImport
| ReferenceOriginParam
| { kind: "import *", source: string }
| {
kind: "property",
base: ReferenceOriginImport | ReferenceOriginParam,
path: string,
name: string,
};
*/
// Given a node and a context, returns a description of where its value comes
// from.
// It resolves imports, parameters of exported functions and property accesses.
// See the ReferenceOrigin type for more informations.
export default function getReferenceOrigin(
node,
scope,
) /*: ?ReferenceOrigin */ {
if (node.type === "Identifier") {
const variable = getVariableDefinition(node.name, scope);
if (!variable) return null;
const definition = variable.definition;
const defNode = definition.node;
if (definition.type === "ImportBinding") {
if (defNode.type === "ImportSpecifier") {
return {
kind: "import",
source: definition.parent.source.value,
name: defNode.imported.name,
};
}
if (defNode.type === "ImportNamespaceSpecifier") {
return {
kind: "import *",
source: definition.parent.source.value,
};
}
}
if (definition.type === "Variable" && defNode.init) {
const origin = getReferenceOrigin(defNode.init, variable.scope);
return origin && patternToProperty(definition.name, origin);
}
if (definition.type === "Parameter") {
return patternToProperty(definition.name, {
kind: "param",
index: definition.index,
functionNode: definition.node,
});
}
}
if (node.type === "MemberExpression" && !node.computed) {
const origin = getReferenceOrigin(node.object, scope);
return origin && addProperty(origin, node.property.name);
}
return null;
}
function getVariableDefinition(name, scope) {
let currentScope = scope;
do {
const variable = currentScope.set.get(name);
if (variable && variable.defs[0]) {
return { scope: currentScope, definition: variable.defs[0] };
}
} while ((currentScope = currentScope.upper));
}
function patternToProperty(id, base) {
const path = getPatternPath(id);
return path && path.reduce(addProperty, base);
}
// Adds a property to a given origin. If it was a namespace import it becomes
// a named import, so that `import * as x from "foo"; x.bar` and
// `import { bar } from "foo"` have the same origin.
function addProperty(origin, name) {
if (origin.kind === "import *") {
return {
kind: "import",
source: origin.source,
name,
};
}
if (origin.kind === "property") {
return {
kind: "property",
base: origin.base,
path: origin.path + "." + name,
name,
};
}
return {
kind: "property",
base: origin,
path: name,
name,
};
}
// if "node" is c of { a: { b: c } }, the result is ["a","b"]
function getPatternPath(node) {
let current = node;
const path = [];
// Unshift keys to path while going up
do {
const property = current.parent;
if (
property.type === "ArrayPattern" ||
property.type === "AssignmentPattern" ||
property.computed
) {
// These nodes are not supported.
return null;
}
if (property.type === "Property") {
path.unshift(property.key.name);
} else {
// The destructuring pattern is finished
break;
}
} while ((current = current.parent.parent));
return path;
}

View File

@ -0,0 +1,24 @@
import getReferenceOrigin from "./get-reference-origin";
import getExportName from "./get-export-name";
export default function isBabelPluginFactory(node, scope) {
const { parent } = node;
if (parent.type === "CallExpression") {
const calleeOrigin = getReferenceOrigin(parent.callee, scope);
// Using "declare" from "@babel/helper-plugin-utils"
return !!(
calleeOrigin &&
calleeOrigin.kind === "import" &&
calleeOrigin.name === "declare" &&
calleeOrigin.source === "@babel/helper-plugin-utils"
);
}
const exportName = getExportName(node);
// export default function ({ types: t }) {}
// module.exports = function ({ types: t }) {}
return exportName === "default" || exportName === "module.exports";
}

View File

@ -0,0 +1,33 @@
import isBabelPluginFactory from "./is-babel-plugin-factory";
// Check if a ReferenceOrigin (returned by ./get-reference-origin.js)
// is a reference to a @babel/types export.
export default function isFromBabelTypes(
origin /*: ReferenceOrigin */,
scope /*: Scope */,
) {
if (origin.kind === "import" && origin.source === "@babel/types") {
// imported from @babel/types
return true;
}
if (
origin.kind === "property" &&
origin.base.kind === "import" &&
origin.base.name === "types" &&
origin.base.source === "@babel/core"
) {
// imported from @babel/core
return true;
}
if (
origin.kind === "property" &&
origin.base.kind === "param" &&
origin.base.index === 0
) {
return isBabelPluginFactory(origin.base.functionNode, scope);
}
return false;
}

View File

@ -0,0 +1,136 @@
import rule from "../../src/rules/no-deprecated-clone";
import { RuleTester } from "eslint";
const cloneError = "t.clone() is deprecated. Use t.cloneNode() instead.";
const cloneDeepError =
"t.cloneDeep() is deprecated. Use t.cloneNode() instead.";
const ruleTester = new RuleTester({
parserOptions: { sourceType: "module" },
});
ruleTester.run("no-deprecated-clone", rule, {
valid: [
`_.clone(obj)`,
`_.cloneDeep(obj)`,
`import * as t from "lib"; t.clone();`,
`import * as t from "lib"; t.cloneDeep();`,
`function f(_) { _.types.clone(); }`,
`function f(_) { _.types.cloneDeep(); }`,
`import * as t from "@babel/types"; t.cloneNode();`,
],
invalid: [
{
code: `import { clone } from "@babel/types"; clone();`,
errors: [cloneError],
},
{
code: `import { cloneDeep } from "@babel/types"; cloneDeep();`,
errors: [cloneDeepError],
},
{
code: `import { clone } from "@babel/types"; var clone2 = clone; clone2();`,
errors: [cloneError],
},
{
code: `import { cloneDeep } from "@babel/types"; var cloneDeep2 = cloneDeep; cloneDeep2();`,
errors: [cloneDeepError],
},
{
code: `import * as t from "@babel/types"; t.clone();`,
errors: [cloneError],
},
{
code: `import * as t from "@babel/types"; t.cloneDeep();`,
errors: [cloneDeepError],
},
{
code: `import * as t from "@babel/types"; var { clone } = t; clone();`,
errors: [cloneError],
},
{
code: `import * as t from "@babel/types"; var { cloneDeep } = t; cloneDeep();`,
errors: [cloneDeepError],
},
{
code: `import { clone as c } from "@babel/types"; c();`,
errors: [cloneError],
},
{
code: `import { cloneDeep as cD } from "@babel/types"; cD();`,
errors: [cloneDeepError],
},
{
code: `import * as babel from "@babel/core"; babel.types.clone();`,
errors: [cloneError],
},
{
code: `import * as babel from "@babel/core"; babel.types.cloneDeep();`,
errors: [cloneDeepError],
},
{
code: `import { types } from "@babel/core"; types.clone();`,
errors: [cloneError],
},
{
code: `import { types } from "@babel/core"; types.cloneDeep();`,
errors: [cloneDeepError],
},
{
code: `import { types as t } from "@babel/core"; t.clone();`,
errors: [cloneError],
},
{
code: `import { types as t } from "@babel/core"; t.cloneDeep();`,
errors: [cloneDeepError],
},
{
code: `export default function plugin(babel) { babel.types.clone() }`,
errors: [cloneError],
},
{
code: `export default function plugin(babel) { babel.types.cloneDeep() }`,
errors: [cloneDeepError],
},
{
code: `export default function plugin({ types }) { types.clone() }`,
errors: [cloneError],
},
{
code: `export default function plugin({ types }) { types.cloneDeep() }`,
errors: [cloneDeepError],
},
{
code: `export default function plugin({ types: t }) { t.clone() }`,
errors: [cloneError],
},
{
code: `export default function plugin({ types: t }) { t.cloneDeep() }`,
errors: [cloneDeepError],
},
{
code: `export default ({ types }) => { types.clone() }`,
errors: [cloneError],
},
{
code: `export default ({ types }) => { types.cloneDeep() }`,
errors: [cloneDeepError],
},
{
code: `module.exports = function plugin({ types }) { types.clone() }`,
errors: [cloneError],
},
{
code: `module.exports = function plugin({ types }) { types.cloneDeep() }`,
errors: [cloneDeepError],
},
{
code: `import { declare } from "@babel/helper-plugin-utils"; declare(({ types }) => { types.clone() });`,
errors: [cloneError],
},
{
code: `import { declare } from "@babel/helper-plugin-utils"; declare(({ types }) => { types.cloneDeep() });`,
errors: [cloneDeepError],
},
],
});

View File

@ -0,0 +1,78 @@
import rule from "../../src/rules/no-undefined-identifier";
import { RuleTester } from "eslint";
const error =
"Use path.scope.buildUndefinedNode() to create an undefined identifier directly.";
const ruleTester = new RuleTester({
parserOptions: { sourceType: "module" },
});
ruleTester.run("no-undefined-identifier", rule, {
valid: [
`_.identifier("undefined")`,
`_.Identifier("undefined")`,
`import * as t from "lib"; t.identifier("undefined");`,
`function f(_) { _.types.identifier("undefined"); }`,
`import * as t from "@babel/types"; t.identifier("not_undefined");`,
`path.scope.buildUndefinedNode();`,
],
invalid: [
{
code: `import { identifier } from "@babel/types"; identifier("undefined");`,
errors: [error],
},
{
code: `import { Identifier } from "@babel/types"; Identifier("undefined");`,
errors: [error],
},
{
code: `import * as t from "@babel/types"; t.identifier("undefined");`,
errors: [error],
},
{
code: `import * as t from "@babel/types"; var { identifier } = t; identifier("undefined");`,
errors: [error],
},
{
code: `import { identifier as id } from "@babel/types"; id("undefined");`,
errors: [error],
},
{
code: `import * as babel from "@babel/core"; babel.types.identifier("undefined");`,
errors: [error],
},
{
code: `import { types } from "@babel/core"; types.identifier("undefined");`,
errors: [error],
},
{
code: `import { types as t } from "@babel/core"; t.identifier("undefined");`,
errors: [error],
},
{
code: `export default function plugin(babel) { babel.types.identifier("undefined") }`,
errors: [error],
},
{
code: `export default function plugin({ types }) { types.identifier("undefined") }`,
errors: [error],
},
{
code: `export default function plugin({ types: t }) { t.identifier("undefined") }`,
errors: [error],
},
{
code: `export default ({ types }) => { types.identifier("undefined") }`,
errors: [error],
},
{
code: `module.exports = function plugin({ types }) { types.identifier("undefined") }`,
errors: [error],
},
{
code: `import { declare } from "@babel/helper-plugin-utils"; declare(({ types }) => { types.identifier("undefined") });`,
errors: [error],
},
],
});

View File

@ -0,0 +1,52 @@
import rule from "../../src/rules/plugin-name";
import { RuleTester } from "eslint";
const missingPluginError = "This file does not export a Babel plugin.";
const missingNameError = "This Babel plugin doesn't have a 'name' property.";
const ruleTester = new RuleTester({
parserOptions: { sourceType: "module" },
});
ruleTester.run("plugin-name", rule, {
valid: [
`export default function () { return { name: "test-plugin" } }`,
`import { declare } from "@babel/helper-plugin-utils"; declare(() => { return { name: "test-plugin" } })`,
`import { declare } from "@babel/helper-plugin-utils"; declare(() => ({ name: "test-plugin" }))`,
`module.exports = function () { return { name: "foo" }; }`,
],
invalid: [
{
code: `function fn() { return { name: "foo" } }`,
errors: [missingPluginError],
},
{
code: `export function fn() { return { name: "foo" } }`,
errors: [missingPluginError],
},
{
code: `(function fn() { return { name: "foo" } })`,
errors: [missingPluginError],
},
{
code: `() => { return { name: "foo" } }`,
errors: [missingPluginError],
},
{
code: `export default function fn() {}`,
errors: [missingPluginError],
},
{
code: `export default function fn() { return {} }`,
errors: [missingNameError],
},
{
code: `import { declare } from "@babel/helper-plugin-utils"; declare(() => ({}))`,
errors: [missingNameError],
},
{
code: `module.exports = function () { return {} }`,
errors: [missingNameError],
},
],
});

View File

@ -0,0 +1,4 @@
src
test
.*
*.log

View File

@ -0,0 +1,23 @@
Copyright (c) 2014-2015 Jason Quense <jason@quense.me>
Original work by respective rule authors; copywrites noted in files.
MIT License
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -0,0 +1,47 @@
# @babel/eslint-plugin
Companion rules for `@babel/eslint-parser`. `@babel/eslint-parser` does a great job at adapting `eslint`
for use with Babel, but it can't change the built-in rules to support experimental features.
`@babel/eslint-plugin` re-implements problematic rules so they do not give false positives or negatives.
> Requires Node 10.9 or greater
### Install
```sh
npm install @babel/eslint-plugin --save-dev
```
Load the plugin in your `.eslintrc.json` file:
```json
{
"plugins": ["@babel/eslint-plugin"]
}
```
Finally enable all the rules you would like to use (remember to disable the
original ones as well!).
```json
{
"rules": {
"babel/new-cap": "error",
"babel/no-invalid-this": "error",
"babel/no-unused-expressions": "error",
"babel/object-curly-spacing": "error",
"babel/semi": "error",
}
}
```
### Rules
Each rule corresponds to a core `eslint` rule and has the same options.
🛠: means it's autofixable with `--fix`.
- `babel/new-cap`: handles decorators (`@Decorator`)
- `babel/no-invalid-this`: handles class fields and private class methods (`class A { a = this.b; }`)
- `babel/no-unused-expressions`: handles `do` expressions
- `babel/object-curly-spacing`: handles `export * as x from "mod";` (🛠)
- `babel/semi`: Handles class properties (🛠)

View File

@ -0,0 +1,41 @@
{
"name": "@babel/eslint-plugin",
"version": "7.8.3-csx.2",
"description": "Companion rules for @babel/eslint-parser",
"main": "lib/index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/babel/babel.git",
"directory": "eslint/babel-eslint-plugin"
},
"keywords": [
"babel",
"eslint",
"eslintplugin",
"eslint-plugin",
"babel-eslint"
],
"author": "Jason Quense @monasticpanic",
"license": "MIT",
"private": true,
"engines": {
"node": ">=10.9"
},
"bugs": {
"url": "https://github.com/babel/babel/issues"
},
"homepage": "https://github.com/babel/babel/tree/master/eslint/babel-eslint-plugin",
"peerDependencies": {
"@babel/eslint-parser": "0.0.0",
"eslint": ">=6.0.0"
},
"dependencies": {
"eslint-rule-composer": "^0.3.0"
},
"devDependencies": {
"@babel/eslint-parser": "7.8.3-csx.2",
"@babel/eslint-shared-fixtures": "7.8.3-csx.2",
"eslint": "^6.0.0",
"lodash.clonedeep": "^4.5.0"
}
}

View File

@ -0,0 +1,22 @@
import newCap from "./rules/new-cap";
import noInvalidThis from "./rules/no-invalid-this";
import noUnusedExpressions from "./rules/no-unused-expressions";
import objectCurlySpacing from "./rules/object-curly-spacing";
import semi from "./rules/semi";
module.exports = {
rules: {
"new-cap": newCap,
"no-invalid-this": noInvalidThis,
"no-unused-expressions": noUnusedExpressions,
"object-curly-spacing": objectCurlySpacing,
semi,
},
rulesConfig: {
"new-cap": "off",
"no-invalid-this": "off",
"no-unused-expressions": "off",
"object-curly-spacing": "off",
semi: "off",
},
};

View File

@ -0,0 +1,18 @@
import ruleComposer from "eslint-rule-composer";
import eslint from "eslint";
const rule = new eslint.Linter().getRules().get("new-cap");
/**
* Returns whether a node is under a decorator or not.
* @param {ASTNode} node CallExpression node
* @returns {Boolean} Returns true if the node is under a decorator.
*/
function isDecorator(node) {
return node.parent.type === "Decorator";
}
export default ruleComposer.filterReports(
rule,
problem => !isDecorator(problem.node),
);

View File

@ -0,0 +1,20 @@
import ruleComposer from "eslint-rule-composer";
import eslint from "eslint";
const noInvalidThisRule = new eslint.Linter().getRules().get("no-invalid-this");
export default ruleComposer.filterReports(noInvalidThisRule, problem => {
let inClassProperty = false;
let node = problem.node;
while (node) {
if (node.type === "ClassProperty" || node.type === "ClassPrivateProperty") {
inClassProperty = true;
return;
}
node = node.parent;
}
return !inClassProperty;
});

View File

@ -0,0 +1,64 @@
import ruleComposer from "eslint-rule-composer";
import eslint from "eslint";
const rule = new eslint.Linter().getRules().get("no-unused-expressions");
/**
* @param {ASTNode} node - any node
* @returns {boolean} whether the given node is either an IfStatement or an
* ExpressionStatement and is the last node in the body of a BlockStatement
*/
function isFinalStatementInBlockStatement(node) {
const parent = node.parent;
return (
/^(?:If|Expression)Statement$/.test(node.type) &&
parent.type === "BlockStatement" &&
parent.body[parent.body.length - 1] === node
);
}
/**
* @param {ASTNode} node - any node
* @returns {boolean} whether the given node represents an unbroken chain of
* tail ExpressionStatements and IfStatements within a DoExpression
* https://github.com/tc39/proposal-do-expressions
*/
function isInDoStatement(node) {
if (!node) return false;
if (node.type === "DoExpression") return true;
// this is an `else if`
if (
node.type === "IfStatement" &&
node.parent &&
node.parent.type === "IfStatement"
) {
return isInDoStatement(node.parent);
}
if (isFinalStatementInBlockStatement(node)) {
return isInDoStatement(node.parent.parent);
}
return false;
}
/**
* @param {ASTNode} node - any node
* @returns {boolean} whether the given node is an optional call expression,
* https://github.com/tc39/proposal-optional-chaining
*/
function isOptionalCallExpression(node) {
return (
!!node &&
node.type === "ExpressionStatement" &&
node.expression.type === "OptionalCallExpression"
);
}
export default ruleComposer.filterReports(
rule,
problem =>
!isInDoStatement(problem.node) && !isOptionalCallExpression(problem.node),
);

View File

@ -0,0 +1,20 @@
import ruleComposer from "eslint-rule-composer";
import eslint from "eslint";
const rule = new eslint.Linter().getRules().get("object-curly-spacing");
export default ruleComposer.filterReports(rule, problem => {
const node = problem.node;
// Allow exportDefaultFrom syntax:
// export x from '...';
if (
node.type === "ExportNamedDeclaration" &&
node.specifiers.length === 1 &&
node.specifiers[0].type === "ExportDefaultSpecifier"
) {
return false;
}
return true;
});

View File

@ -0,0 +1,105 @@
import ruleComposer from "eslint-rule-composer";
import eslint from "eslint";
const OPT_OUT_PATTERN = /^[-[(/+`]/; // One of [(/+-`
const rule = new eslint.Linter().getRules().get("semi");
function isSemicolon(token) {
return token.type === "Punctuator" && token.value === ";";
}
function isUnnecessarySemicolon(context, lastToken) {
if (!isSemicolon(lastToken)) {
return false;
}
const nextToken = context.getSourceCode().getTokenAfter(lastToken);
if (!nextToken) {
return true;
}
const lastTokenLine = lastToken.loc.end.line;
const nextTokenLine = nextToken.loc.start.line;
const isOptOutToken =
OPT_OUT_PATTERN.test(nextToken.value) &&
nextToken.value !== "++" &&
nextToken.value !== "--";
const isDivider = nextToken.value === "}" || nextToken.value === ";";
return (lastTokenLine !== nextTokenLine && !isOptOutToken) || isDivider;
}
function isOneLinerBlock(context, node) {
const nextToken = context.getSourceCode().getTokenAfter(node);
if (!nextToken || nextToken.value !== "}") {
return false;
}
const parent = node.parent;
return (
parent &&
parent.type === "BlockStatement" &&
parent.loc.start.line === parent.loc.end.line
);
}
function report(context, node, missing) {
const lastToken = context.getSourceCode().getLastToken(node);
let message,
fix,
loc = lastToken.loc;
if (!missing) {
message = "Missing semicolon.";
loc = loc.end;
fix = function(fixer) {
return fixer.insertTextAfter(lastToken, ";");
};
} else {
message = "Extra semicolon.";
loc = loc.start;
fix = function(fixer) {
return fixer.remove(lastToken);
};
}
context.report({
node,
loc,
message,
fix,
});
}
export default ruleComposer.joinReports([
rule,
context => ({
ClassProperty(node) {
const options = context.options[1];
const exceptOneLine = options && options.omitLastInOneLineBlock === true;
const sourceCode = context.getSourceCode();
const lastToken = sourceCode.getLastToken(node);
if (context.options[0] === "never") {
if (isUnnecessarySemicolon(context, lastToken)) {
report(context, node, true);
}
} else {
if (!isSemicolon(lastToken)) {
if (!exceptOneLine || !isOneLinerBlock(context, node)) {
report(context, node);
}
} else {
if (exceptOneLine && isOneLinerBlock(context, node)) {
report(context, node, true);
}
}
}
},
}),
]);

View File

@ -0,0 +1,14 @@
import { RuleTester } from "eslint";
RuleTester.setDefaultConfig({
parser: require.resolve("@babel/eslint-parser"),
parserOptions: {
babelOptions: {
configFile: require.resolve(
"@babel/eslint-shared-fixtures/config/babel.config.js",
),
},
},
});
export default RuleTester;

View File

@ -0,0 +1,12 @@
import rule from "../../src/rules/new-cap";
import RuleTester from "../helpers/RuleTester";
const ruleTester = new RuleTester();
ruleTester.run("@babel/new-cap", rule, {
valid: [
{
code: "@MyDecorator(123) class MyClass{}",
},
],
invalid: [],
});

View File

@ -0,0 +1,121 @@
import cloneDeep from "lodash.clonedeep";
import rule from "../../src/rules/no-invalid-this";
import RuleTester from "../helpers/RuleTester";
/**
* A constant value for non strict mode environment.
* @returns {void}
*/
function NORMAL(pattern) {
pattern.parserOptions.sourceType = "script";
}
/**
* A constant value for strict mode environment.
* This modifies pattern object to make strict mode.
* @param {Object} pattern - A pattern object to modify.
* @returns {void}
*/
function USE_STRICT(pattern) {
pattern.code = '"use strict"; ' + pattern.code;
}
/**
* A constant value for implied strict mode.
* This modifies pattern object to impose strict mode.
* @param {Object} pattern - A pattern object to modify.
* @returns {void}
*/
function IMPLIED_STRICT(pattern) {
pattern.code = "/* implied strict mode */ " + pattern.code;
pattern.parserOptions.ecmaFeatures = pattern.parserOptions.ecmaFeatures || {};
pattern.parserOptions.ecmaFeatures.impliedStrict = true;
}
/**
* A constant value for modules environment.
* This modifies pattern object to make modules.
* @param {Object} pattern - A pattern object to modify.
* @returns {void}
*/
function MODULES(pattern) {
pattern.code = "/* modules */ " + pattern.code;
}
/**
* Extracts patterns each condition for a specified type. The type is `valid` or `invalid`.
* @param {Object[]} patterns - Original patterns.
* @param {string} type - One of `"valid"` or `"invalid"`.
* @returns {Object[]} Test patterns.
*/
function extractPatterns(patterns, type) {
// Clone and apply the pattern environment.
const patternsList = patterns.map(function(pattern) {
return pattern[type].map(function(applyCondition) {
const thisPattern = cloneDeep(pattern);
applyCondition(thisPattern);
if (type === "valid") {
thisPattern.errors = [];
} else {
thisPattern.code += " /* should error */";
}
delete thisPattern.invalid;
delete thisPattern.valid;
return thisPattern;
});
});
// Flatten.
return Array.prototype.concat.apply([], patternsList);
}
//------------------------------------------------------------------------------
// Tests
//------------------------------------------------------------------------------
const errors = [
{ message: "Unexpected 'this'.", type: "ThisExpression" },
{ message: "Unexpected 'this'.", type: "ThisExpression" },
];
const patterns = [
// Class private fields
{
code: "class A {a = this.b;};",
parserOptions: { ecmaVersion: 6 },
valid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES],
invalid: [],
},
{
code: "class A {a = () => {return this.b;};};",
parserOptions: { ecmaVersion: 6 },
valid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES],
invalid: [],
},
// Class Private methods
{
code: "class A {#a = this.b;};",
parserOptions: { ecmaVersion: 6 },
valid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES],
invalid: [],
},
{
code: "class A {#a = () => {return this.b;};};",
parserOptions: { ecmaVersion: 6 },
valid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES],
invalid: [],
},
];
const ruleTester = new RuleTester();
ruleTester.run("@babel/no-invalid-this", rule, {
valid: extractPatterns(patterns, "valid"),
invalid: extractPatterns(patterns, "invalid"),
});

View File

@ -0,0 +1,37 @@
import rule from "../../src/rules/no-unused-expressions";
import RuleTester from "../helpers/RuleTester";
const ruleTester = new RuleTester();
ruleTester.run("@babel/no-unused-expressions", rule, {
valid: [
"let a = do { if (foo) { foo.bar; } }",
"let a = do { foo; }",
"let a = do { let b = 2; foo; }",
"let a = do { (foo + 1); }",
"let a = do { if (foo) { if (foo.bar) { foo.bar; } } }",
"let a = do { if (foo) { if (foo.bar) { foo.bar; } else if (foo.baz) { foo.baz; } } }",
"foo.bar?.();",
],
invalid: [
{
code: "let a = do { foo; let b = 2; }",
errors: [
{
message:
"Expected an assignment or function call and instead saw an expression.",
type: "ExpressionStatement",
},
],
},
{
code: "let a = do { if (foo) { foo.bar } else { a; bar.foo } }",
errors: [
{
message:
"Expected an assignment or function call and instead saw an expression.",
type: "ExpressionStatement",
},
],
},
],
});

View File

@ -0,0 +1,13 @@
import rule from "../../src/rules/object-curly-spacing";
import RuleTester from "../helpers/RuleTester";
const ruleTester = new RuleTester();
ruleTester.run("@babel/object-curly-spacing", rule, {
valid: [
{
code: 'export x from "mod";',
},
],
invalid: [],
});

View File

@ -0,0 +1,52 @@
import rule from "../../src/rules/semi";
import RuleTester from "../helpers/RuleTester";
const ruleTester = new RuleTester();
ruleTester.run("semi", rule, {
valid: [
"class Foo { bar = 'example'; }",
"class Foo { static bar = 'example'; }",
{
code: "class Foo { bar = () => {}; }",
options: ["always", { omitLastInOneLineBlock: true }],
},
// never
{ code: "class Foo { bar = 'example' }", options: ["never"] },
{ code: "class Foo { static bar = 'example' }", options: ["never"] },
{ code: "class Foo { bar = () => {} }", options: ["never"] },
],
invalid: [
{
code: "class Foo { bar = 'example' }",
errors: [{ message: "Missing semicolon." }],
},
{
code: "class Foo { static bar = 'example' }",
errors: [{ message: "Missing semicolon." }],
},
{
code: "class Foo { bar = () => {} }",
options: ["always", { omitLastInOneLineBlock: true }],
errors: [{ message: "Missing semicolon." }],
},
// "never"
{
code: "class Foo { bar = 'example'; }",
options: ["never"],
errors: [{ message: "Extra semicolon." }],
},
{
code: "class Foo { static bar = 'example'; }",
options: ["never"],
errors: [{ message: "Extra semicolon." }],
},
{
code: "class Foo { bar = () => {}; }",
options: ["never"],
errors: [{ message: "Extra semicolon." }],
},
],
});

View File

@ -0,0 +1,6 @@
"use strict";
module.exports = {
presets: [["@babel/preset-env", { forceAllTransforms: true }]],
plugins: [["@babel/plugin-proposal-decorators", { legacy: true }]],
};

View File

@ -0,0 +1,24 @@
"use strict";
module.exports = {
presets: [
["@babel/preset-env", { forceAllTransforms: true }],
["@babel/preset-flow", { all: true }],
"@babel/preset-react",
],
plugins: [
"@babel/plugin-syntax-dynamic-import",
"@babel/plugin-syntax-import-meta",
"@babel/plugin-syntax-export-default-from",
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-nullish-coalescing-operator",
"@babel/plugin-proposal-optional-chaining",
"@babel/plugin-syntax-numeric-separator",
"@babel/plugin-syntax-export-namespace-from",
["@babel/plugin-proposal-decorators", { decoratorsBeforeExport: false }],
["@babel/plugin-proposal-pipeline-operator", { proposal: "minimal" }],
"@babel/plugin-syntax-bigint",
"@babel/plugin-proposal-private-methods",
"@babel/plugin-proposal-do-expressions",
],
};

View File

@ -0,0 +1,25 @@
{
"name": "@babel/eslint-shared-fixtures",
"version": "7.8.3-csx.2",
"description": "Shared fixtures for testing @babel/eslint-* packages",
"license": "MIT",
"private": true,
"dependencies": {
"@babel/plugin-proposal-class-properties": "^7.1.0",
"@babel/plugin-proposal-decorators": "^7.1.2",
"@babel/plugin-proposal-do-expressions": "^7.7.4",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.0.0",
"@babel/plugin-proposal-optional-chaining": "^7.0.0",
"@babel/plugin-proposal-pipeline-operator": "^7.0.0",
"@babel/plugin-proposal-private-methods": "^7.7.4",
"@babel/plugin-syntax-bigint": "^7.7.4",
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
"@babel/plugin-syntax-export-default-from": "^7.0.0",
"@babel/plugin-syntax-export-namespace-from": "^7.0.0",
"@babel/plugin-syntax-import-meta": "^7.0.0",
"@babel/plugin-syntax-numeric-separator": "^7.0.0",
"@babel/preset-env": "^7.1.5",
"@babel/preset-flow": "^7.0.0",
"@babel/preset-react": "^7.0.0"
}
}

68
jest.config.js Normal file
View File

@ -0,0 +1,68 @@
// These packages undet the @babel namespace aren't in this monorepo.
const externalBabelPackages = [
"plugin-syntax-async-generators",
"plugin-syntax-bigint",
"plugin-syntax-dynamic-import",
"plugin-syntax-json-strings",
"plugin-syntax-nullish-coalescing-operator",
"plugin-syntax-object-rest-spread",
"plugin-syntax-optional-catch-binding",
"plugin-syntax-optional-chaining",
];
// prettier-ignore
const monorepoPackagePattern =
`^@babel/(?!eslint-)(?!${externalBabelPackages.join("|")})([a-zA-Z0-9_-]+)$`;
module.exports = {
collectCoverageFrom: [
"packages/*/src/**/*.mjs",
"packages/*/src/**/*.js",
"codemods/*/src/**/*.mjs",
"codemods/*/src/**/*.js",
"eslint/*/src/**/*.mjs",
"eslint/*/src/**/*.js",
],
// The eslint/* packages use ESLint v6, which has dropped support for Node v6.
// TODO: Remove this process.version check in Babel 8.
testRegex: `./(packages|codemods${
/^v6./u.test(process.version) ? "" : "|eslint"
})/[^/]+/test/.+\\.m?js$`,
testPathIgnorePatterns: [
"/node_modules/",
"/test/fixtures/",
"/test/debug-fixtures/",
"/babel-parser/test/expressions/",
"/test/tmp/",
"/test/__data__/",
"/test/helpers/",
"<rootDir>/test/warning\\.js",
"<rootDir>/build/",
"_browser\\.js",
],
testEnvironment: "node",
setupFilesAfterEnv: ["<rootDir>/test/testSetupFile.js"],
transformIgnorePatterns: [
"/node_modules/",
"<rootDir>/packages/babel-standalone/babel(\\.min)?\\.js",
"<rootDir>/packages/babel-preset-env-standalone/babel-preset-env(\\.min)?\\.js",
"/test/(fixtures|tmp|__data__)/",
"<rootDir>/(packages|codemods|eslint)/[^/]+/lib/",
],
coveragePathIgnorePatterns: [
"/node_modules/",
"<rootDir>/packages/babel-standalone/babel(\\.min)?\\.js",
"<rootDir>/packages/babel-preset-env-standalone/babel-preset-env(\\.min)?\\.js",
"/test/(fixtures|tmp|__data__)/",
],
modulePathIgnorePatterns: [
"/test/fixtures/",
"/test/tmp/",
"/test/__data__/",
"<rootDir>/build/",
],
moduleNameMapper: {
[monorepoPackagePattern]: "<rootDir>/packages/babel-$1/",
"^@babel/eslint-([a-zA-Z0-9_-]+)$": "<rootDir>/eslint/babel-eslint-$1/",
},
};

View File

@ -1,5 +1,5 @@
{ {
"version": "7.7.3", "version": "7.8.3-csx.2",
"changelog": { "changelog": {
"repo": "babel/babel", "repo": "babel/babel",
"cacheDir": ".changelog", "cacheDir": ".changelog",
@ -11,7 +11,8 @@
"PR: Polish :nail_care:": ":nail_care: Polish", "PR: Polish :nail_care:": ":nail_care: Polish",
"PR: Docs :memo:": ":memo: Documentation", "PR: Docs :memo:": ":memo: Documentation",
"PR: Internal :house:": ":house: Internal", "PR: Internal :house:": ":house: Internal",
"PR: Performance :running_woman:": ":running_woman: Performance" "PR: Performance :running_woman:": ":running_woman: Performance",
"PR: Revert :leftwards_arrow_with_hook:": ":leftwards_arrow_with_hook: Revert"
} }
}, },
"command": { "command": {
@ -20,21 +21,22 @@
"*.md", "*.md",
"*.txt", "*.txt",
"test/**", "test/**",
"**/test/**",
"codemods/**", "codemods/**",
"# We ignore every JSON file, except for built-in-modules, built-ins and plugins defined in babel-preset-env/data.", "# We ignore every JSON file, except for built-in-modules, built-ins and plugins defined in babel-preset-env/data.",
"@(!(built-in-modules|built-ins|plugins|package)).json" "@(!(built-in-modules|built-ins|plugins|package)).json",
"# Until the ESLint packages version are aligned with Babel's, we ignore them",
"eslint/**"
] ]
} }
}, },
"packages": [ "packages": [
"codemods/*", "codemods/*",
"eslint/*",
"packages/*" "packages/*"
], ],
"npmClient": "yarn", "npmClient": "yarn",
"npmClientArgs": [ "npmClientArgs": [
"--no-lockfile" "--no-lockfile"
], ]
"publishConfig": {
"registry": "https://npm.cerxes.net"
}
} }

View File

@ -4,6 +4,7 @@
declare module "resolve" { declare module "resolve" {
declare export default { declare export default {
(string, {| basedir: string |}, (err: ?Error, res: string) => void): void;
sync: (string, {| basedir: string |}) => string; sync: (string, {| basedir: string |}) => string;
}; };
} }
@ -178,7 +179,7 @@ declare module "convert-source-map" {
SourceMap: SourceMap, SourceMap: SourceMap,
Converter: Converter, Converter: Converter,
fromObject(obj: SourceMap | SourceMapGenerator): Converter, fromObject(obj: SourceMap | SourceMapGenerator): Converter,
fromJSON(str: string): Converter, fromJSON(str: string | Buffer): Converter,
fromBase64(str: string): Converter, fromBase64(str: string): Converter,
fromComment(str: string): Converter, fromComment(str: string): Converter,
fromMapFileComment(str: string, dir: string): Converter, fromMapFileComment(str: string, dir: string): Converter,
@ -190,12 +191,6 @@ declare module "convert-source-map" {
}; };
} }
declare module "js-levenshtein" {
declare module.exports: {
(string, string): number,
};
}
declare module "core-js-compat/data" { declare module "core-js-compat/data" {
declare type Target = "node" | "chrome" | "opera" | "edge" | "firefox" | "safari" | "ie" | "ios" | "android" | "electron" | "samsung"; declare type Target = "node" | "chrome" | "opera" | "edge" | "firefox" | "safari" | "ie" | "ios" | "android" | "electron" | "samsung";

View File

@ -3,39 +3,44 @@
"private": true, "private": true,
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"bootstrap": "make bootstrap",
"build": "make build", "build": "make build",
"fix": "make fix", "fix": "make fix",
"lint": "make lint", "lint": "make lint",
"test": "make test" "test": "make test"
}, },
"devDependencies": { "devDependencies": {
"@babel/cli": "^7.6.0", "@babel/cli": "^7.7.0",
"@babel/core": "^7.6.0", "@babel/core": "^7.7.2",
"@babel/eslint-plugin-development": "^1.0.1", "@babel/eslint-plugin-development": "^1.0.1",
"@babel/plugin-proposal-class-properties": "^7.5.5", "@babel/plugin-proposal-class-properties": "^7.7.0",
"@babel/plugin-proposal-export-namespace-from": "^7.5.2", "@babel/plugin-proposal-export-namespace-from": "^7.5.2",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.4.4", "@babel/plugin-proposal-nullish-coalescing-operator": "^7.4.4",
"@babel/plugin-proposal-numeric-separator": "^7.2.0", "@babel/plugin-proposal-numeric-separator": "^7.2.0",
"@babel/plugin-proposal-object-rest-spread": "^7.7.4",
"@babel/plugin-proposal-optional-chaining": "^7.6.0", "@babel/plugin-proposal-optional-chaining": "^7.6.0",
"@babel/plugin-transform-modules-commonjs": "^7.6.0", "@babel/plugin-transform-flow-strip-types": "^7.7.4",
"@babel/plugin-transform-runtime": "^7.6.0", "@babel/plugin-transform-for-of": "^7.7.4",
"@babel/preset-env": "^7.6.0", "@babel/plugin-transform-modules-commonjs": "^7.7.0",
"@babel/plugin-transform-runtime": "^7.6.2",
"@babel/preset-env": "^7.7.1",
"@babel/preset-flow": "^7.0.0", "@babel/preset-flow": "^7.0.0",
"@babel/register": "^7.6.0", "@babel/register": "^7.7.0",
"@babel/runtime": "^7.6.0", "@babel/runtime": "^7.7.2",
"babel-eslint": "^11.0.0-beta.0", "@rollup/plugin-alias": "^2.2.0",
"@rollup/plugin-json": "^4.0.0",
"babel-eslint": "^11.0.0-beta.2",
"babel-jest": "^24.9.0", "babel-jest": "^24.9.0",
"babel-loader": "^8.0.6",
"babel-plugin-transform-charcodes": "^0.2.0", "babel-plugin-transform-charcodes": "^0.2.0",
"browserify": "^16.2.3", "browserify": "^16.2.3",
"bundle-collapser": "^1.2.1", "bundle-collapser": "^1.2.1",
"chalk": "^2.4.2", "chalk": "^2.4.2",
"charcodes": "^0.2.0", "charcodes": "^0.2.0",
"derequire": "^2.0.2", "derequire": "^2.0.2",
"duplicate-package-checker-webpack-plugin": "^2.1.0",
"enhanced-resolve": "^3.0.0", "enhanced-resolve": "^3.0.0",
"eslint": "^6.0.1", "eslint": "^6.0.1",
"eslint-config-babel": "^9.0.0", "eslint-config-babel": "^9.0.0",
"eslint-import-resolver-node": "^0.3.2",
"eslint-plugin-flowtype": "^3.8.2", "eslint-plugin-flowtype": "^3.8.2",
"eslint-plugin-import": "^2.17.2", "eslint-plugin-import": "^2.17.2",
"eslint-plugin-prettier": "^3.1.0", "eslint-plugin-prettier": "^3.1.0",
@ -48,32 +53,32 @@
"gulp-newer": "^1.0.0", "gulp-newer": "^1.0.0",
"gulp-plumber": "^1.2.1", "gulp-plumber": "^1.2.1",
"gulp-rename": "^1.4.0", "gulp-rename": "^1.4.0",
"gulp-uglify": "^3.0.2",
"gulp-watch": "^5.0.1", "gulp-watch": "^5.0.1",
"husky": "^3.0.0", "husky": "^3.0.0",
"jest": "^24.9.0", "jest": "^24.9.0",
"lerna": "^3.16.0", "lerna": "^3.19.0",
"lerna-changelog": "^0.5.0", "lerna-changelog": "^0.5.0",
"lint-staged": "^9.2.0", "lint-staged": "^9.2.0",
"lodash": "^4.17.13", "lodash": "^4.17.13",
"mergeiterator": "^1.2.5",
"output-file-sync": "^2.0.0", "output-file-sync": "^2.0.0",
"prettier": "^1.17.1", "prettier": "^1.19.1",
"pump": "^3.0.0", "pump": "^3.0.0",
"rimraf": "^2.6.3", "rimraf": "^2.6.3",
"rollup": "^1.12.0", "rollup": "^1.27.5",
"rollup-plugin-babel": "^4.0.0", "rollup-plugin-babel": "^4.0.0",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-node-builtins": "^2.1.2",
"rollup-plugin-node-globals": "^1.4.0",
"rollup-plugin-node-resolve": "^5.0.0", "rollup-plugin-node-resolve": "^5.0.0",
"rollup-plugin-replace": "^2.2.0", "rollup-plugin-replace": "^2.2.0",
"rollup-plugin-terser": "^5.1.2",
"test262-stream": "^1.3.0", "test262-stream": "^1.3.0",
"through2": "^2.0.0", "through2": "^2.0.0",
"typescript": "^3.6.3", "typescript": "^3.6.3"
"warnings-to-errors-webpack-plugin": "^2.0.0",
"webpack": "^3.4.1",
"webpack-dependency-suite": "^2.4.4",
"webpack-stream": "^4.0.0"
}, },
"resolutions": { "resolutions": {
"@lerna/**/@lerna/collect-updates": "https://github.com/babel/lerna.git#babel-collect-updates" "@lerna/collect-updates": "https://github.com/babel/lerna.git#babel-collect-updates"
}, },
"engines": { "engines": {
"node": ">= 6.9.0 < 14.0.0", "node": ">= 6.9.0 < 14.0.0",
@ -89,53 +94,5 @@
"hooks": { "hooks": {
"pre-commit": "lint-staged" "pre-commit": "lint-staged"
} }
},
"jest": {
"collectCoverageFrom": [
"packages/*/src/**/*.mjs",
"packages/*/src/**/*.js",
"codemods/*/src/**/*.mjs",
"codemods/*/src/**/*.js"
],
"testRegex": "./(packages|codemods)/[^/]+/test/.+\\.m?js$",
"testPathIgnorePatterns": [
"/node_modules/",
"/test/fixtures/",
"/test/debug-fixtures/",
"/babel-parser/test/expressions/",
"/test/tmp/",
"/test/__data__/",
"/test/helpers/",
"<rootDir>/test/warning\\.js",
"<rootDir>/build/",
"_browser\\.js"
],
"testEnvironment": "node",
"setupFilesAfterEnv": [
"<rootDir>/test/testSetupFile.js"
],
"transformIgnorePatterns": [
"/node_modules/",
"/packages/babel-standalone/babel.js",
"<rootDir>/packages/babel-standalone/babel(\\.min)?\\.js",
"<rootDir>/packages/babel-preset-env-standalone/babel-preset-env(\\.min)?\\.js",
"/test/(fixtures|tmp|__data__)/",
"<rootDir>/(packages|codemods)/[^/]+/lib/"
],
"coveragePathIgnorePatterns": [
"/node_modules/",
"<rootDir>/packages/babel-standalone/babel(\\.min)?\\.js",
"<rootDir>/packages/babel-preset-env-standalone/babel-preset-env(\\.min)?\\.js",
"/test/(fixtures|tmp|__data__)/"
],
"modulePathIgnorePatterns": [
"/test/fixtures/",
"/test/tmp/",
"/test/__data__/",
"<rootDir>/build/"
],
"moduleNameMapper": {
"^@babel/([a-zA-Z0-9_-]+)$": "<rootDir>/packages/babel-$1/"
}
} }
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "@babel/cli", "name": "@babel/cli",
"version": "7.7.0", "version": "7.8.3-csx.2",
"description": "Babel command line.", "description": "Babel command line.",
"author": "Sebastian McKenzie <sebmck@gmail.com>", "author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://babeljs.io/", "homepage": "https://babeljs.io/",
@ -19,7 +19,7 @@
"compiler" "compiler"
], ],
"dependencies": { "dependencies": {
"commander": "^2.8.1", "commander": "^4.0.1",
"convert-source-map": "^1.1.0", "convert-source-map": "^1.1.0",
"fs-readdir-recursive": "^1.1.0", "fs-readdir-recursive": "^1.1.0",
"glob": "^7.0.0", "glob": "^7.0.0",
@ -35,8 +35,9 @@
"@babel/core": "^7.0.0-0 || csx" "@babel/core": "^7.0.0-0 || csx"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.7.0", "@babel/core": "7.8.3-csx.2",
"@babel/helper-fixtures": "^7.6.3" "@babel/helper-fixtures": "7.8.3-csx.2",
"rimraf": "^3.0.0"
}, },
"bin": { "bin": {
"babel": "./bin/babel.js", "babel": "./bin/babel.js",

View File

@ -9,6 +9,13 @@ import fs from "fs";
import * as util from "./util"; import * as util from "./util";
import { type CmdOptions } from "./options"; import { type CmdOptions } from "./options";
const FILE_TYPE = Object.freeze({
NON_COMPILABLE: "NON_COMPILABLE",
COMPILED: "COMPILED",
IGNORED: "IGNORED",
ERR_COMPILATION: "ERR_COMPILATION",
});
function outputFileSync(filePath: string, data: string | Buffer): void { function outputFileSync(filePath: string, data: string | Buffer): void {
makeDirSync(path.dirname(filePath)); makeDirSync(path.dirname(filePath));
fs.writeFileSync(filePath, data); fs.writeFileSync(filePath, data);
@ -20,15 +27,22 @@ export default async function({
}: CmdOptions): Promise<void> { }: CmdOptions): Promise<void> {
const filenames = cliOptions.filenames; const filenames = cliOptions.filenames;
async function write(src: string, base: string): Promise<boolean> { async function write(
src: string,
base: string,
): Promise<$Keys<typeof FILE_TYPE>> {
let relative = path.relative(base, src); let relative = path.relative(base, src);
if (!util.isCompilableExtension(relative, cliOptions.extensions)) { if (!util.isCompilableExtension(relative, cliOptions.extensions)) {
return false; return FILE_TYPE.NON_COMPILABLE;
} }
// remove extension and then append back on .js relative = util.withExtension(
relative = util.adjustRelative(relative, cliOptions.keepFileExtension); relative,
cliOptions.keepFileExtension
? path.extname(relative)
: cliOptions.outFileExtension,
);
const dest = getDest(relative, base); const dest = getDest(relative, base);
@ -43,7 +57,7 @@ export default async function({
), ),
); );
if (!res) return false; if (!res) return FILE_TYPE.IGNORED;
// we've requested explicit sourcemaps to be written to disk // we've requested explicit sourcemaps to be written to disk
if ( if (
@ -64,11 +78,11 @@ export default async function({
console.log(src + " -> " + dest); console.log(src + " -> " + dest);
} }
return true; return FILE_TYPE.COMPILED;
} catch (err) { } catch (err) {
if (cliOptions.watch) { if (cliOptions.watch) {
console.error(err); console.error(err);
return false; return FILE_TYPE.ERR_COMPILATION;
} }
throw err; throw err;
@ -85,13 +99,16 @@ export default async function({
async function handleFile(src: string, base: string): Promise<boolean> { async function handleFile(src: string, base: string): Promise<boolean> {
const written = await write(src, base); const written = await write(src, base);
if (!written && cliOptions.copyFiles) { if (
(cliOptions.copyFiles && written === FILE_TYPE.NON_COMPILABLE) ||
(cliOptions.copyIgnored && written === FILE_TYPE.IGNORED)
) {
const filename = path.relative(base, src); const filename = path.relative(base, src);
const dest = getDest(filename, base); const dest = getDest(filename, base);
outputFileSync(dest, fs.readFileSync(src)); outputFileSync(dest, fs.readFileSync(src));
util.chmod(src, dest); util.chmod(src, dest);
} }
return written; return written === FILE_TYPE.COMPILED;
} }
async function handle(filenameOrDir: string): Promise<number> { async function handle(filenameOrDir: string): Promise<number> {
@ -145,7 +162,7 @@ export default async function({
if (cliOptions.watch) { if (cliOptions.watch) {
const chokidar = util.requireChokidar(); const chokidar = util.requireChokidar();
filenames.forEach(function(filenameOrDir) { filenames.forEach(function(filenameOrDir: string): void {
const watcher = chokidar.watch(filenameOrDir, { const watcher = chokidar.watch(filenameOrDir, {
persistent: true, persistent: true,
ignoreInitial: true, ignoreInitial: true,
@ -155,8 +172,8 @@ export default async function({
}, },
}); });
["add", "change"].forEach(function(type) { ["add", "change"].forEach(function(type: string): void {
watcher.on(type, function(filename) { watcher.on(type, function(filename: string): void {
handleFile( handleFile(
filename, filename,
filename === filenameOrDir filename === filenameOrDir

View File

@ -216,6 +216,7 @@ export default async function({
const chokidar = util.requireChokidar(); const chokidar = util.requireChokidar();
chokidar chokidar
.watch(filenames, { .watch(filenames, {
disableGlobbing: true,
persistent: true, persistent: true,
ignoreInitial: true, ignoreInitial: true,
awaitWriteFinish: { awaitWriteFinish: {
@ -223,8 +224,11 @@ export default async function({
pollInterval: 10, pollInterval: 10,
}, },
}) })
.on("all", function(type: string, filename: string) { .on("all", function(type: string, filename: string): void {
if (!util.isCompilableExtension(filename, cliOptions.extensions)) { if (
!util.isCompilableExtension(filename, cliOptions.extensions) &&
!filenames.includes(filename)
) {
return; return;
} }

View File

@ -74,8 +74,8 @@ commander.option(
booleanify, booleanify,
); );
commander.option( commander.option(
"--minified [true|false]", "--minified",
"Save as many bytes when printing.", "Save as many bytes when printing. (false by default)",
); );
commander.option( commander.option(
"--auxiliary-comment-before [string]", "--auxiliary-comment-before [string]",
@ -160,9 +160,22 @@ commander.option(
"--delete-dir-on-start", "--delete-dir-on-start",
"Delete the out directory before compilation.", "Delete the out directory before compilation.",
); );
commander.option(
"--out-file-extension [string]",
"Use a specific extension for the output files",
);
commander.option(
"--copy-ignored",
"Include ignored files when copying non-compilable files.",
);
commander.version(pkg.version + " (@babel/core " + version + ")"); commander.version(pkg.version + " (@babel/core " + version + ")");
commander.usage("[options] <files ...>"); commander.usage("[options] <files ...>");
// register an empty action handler so that commander.js can throw on
// unknown options _after_ args
// see https://github.com/tj/commander.js/issues/561#issuecomment-522209408
commander.action(() => {});
export type CmdOptions = { export type CmdOptions = {
babelOptions: Object, babelOptions: Object,
@ -233,6 +246,12 @@ export default function parseArgv(args: Array<string>): CmdOptions | null {
); );
} }
if (commander.keepFileExtension && commander.outFileExtension) {
errors.push(
"--out-file-extension cannot be used with --keep-file-extension",
);
}
if (errors.length) { if (errors.length) {
console.error("babel:"); console.error("babel:");
errors.forEach(function(e) { errors.forEach(function(e) {
@ -289,6 +308,7 @@ export default function parseArgv(args: Array<string>): CmdOptions | null {
filenames, filenames,
extensions: opts.extensions, extensions: opts.extensions,
keepFileExtension: opts.keepFileExtension, keepFileExtension: opts.keepFileExtension,
outFileExtension: opts.outFileExtension,
watch: opts.watch, watch: opts.watch,
skipInitialBuild: opts.skipInitialBuild, skipInitialBuild: opts.skipInitialBuild,
outFile: opts.outFile, outFile: opts.outFile,
@ -300,6 +320,7 @@ export default function parseArgv(args: Array<string>): CmdOptions | null {
quiet: opts.quiet, quiet: opts.quiet,
deleteDirOnStart: opts.deleteDirOnStart, deleteDirOnStart: opts.deleteDirOnStart,
sourceMapTarget: opts.sourceMapTarget, sourceMapTarget: opts.sourceMapTarget,
copyIgnored: opts.copyIgnored,
}, },
}; };
} }
@ -316,7 +337,10 @@ function booleanify(val: any): boolean | any {
return val; return val;
} }
function collect(value, previousValue): Array<string> { function collect(
value: string | any,
previousValue: Array<string>,
): Array<string> {
// If the user passed the option with no value, like "babel file.js --presets", do nothing. // If the user passed the option with no value, like "babel file.js --presets", do nothing.
if (typeof value !== "string") return previousValue; if (typeof value !== "string") return previousValue;

View File

@ -127,12 +127,7 @@ export function requireChokidar(): Object {
} }
} }
export function adjustRelative( export function withExtension(filename: string, ext: string = ".js") {
relative: string, const newBasename = path.basename(filename, path.extname(filename)) + ext;
keepFileExtension: boolean, return path.join(path.dirname(filename), newBasename);
): string {
if (keepFileExtension) {
return relative;
}
return relative.replace(/\.(\w*?)$/, "") + ".js";
} }

Some files were not shown because too many files have changed in this diff Show More