33 Commits

Author SHA1 Message Date
Tan Li Hau
eb3230f9db fix code-frame marker with highlighting (#10211) 2019-07-15 21:16:18 +02:00
Justin Ridgewell
2afe9404fe
Use Object Spread Syntax (#7777)
* Use Object Spread Syntax

* Nits
2018-04-23 21:44:27 -04:00
Daniel Tschinder
3e95830646
Migrate to jest (#7455) 2018-03-03 10:58:19 +01:00
Suchipi Izumi
534ee4734c Extract @babel/highlight package from @babel/code-frame
This creates a new package called @babel/highlight which syntax highlights
JavaScript code for terminal output. This functionality was already
present in @babel/code-frame, but exposing it as a separate package lets
other projects leverage it. @babel/code-frame has been refactored
slightly so that it uses @babel/highlight to do its syntax highlighting.
2018-02-09 09:31:37 +01:00
Steven Hargrove
a01007a3d3 Allow falsey, yet valid options for codeFrameColumns() (#7341)
Allow for overriding default linesAbove/linesBelow values.
2018-02-08 16:52:12 -05:00
Jamie Kyle
5759c33b4c
Add opts.message option to code frames (#7243)
* Add opts.message option to code frames

* Fix for missing loc.start in code-frame

* Add docs
2018-01-21 14:19:20 +11:00
Joe Haddad
ca86648726 bugfix: set color level when color is forced (#7216)
Color level 1 matches our usages, level 0 is no color
2018-01-14 12:43:20 -06:00
Simon Lydell
d2b3138bdd Make syntax highlighting for @ and # nicer (#6550) 2017-10-25 03:10:32 -04:00
Mateusz Burzyński
859ea4b175 Scoped: updated numerous docs with scoped packages change [skip ci] 2017-10-16 22:49:57 -04:00
Daniel Tschinder
44f6ff5e85 Update prettier, eslint + plugins, flow, husky and lint-staged (#6183) 2017-08-31 22:56:29 +02:00
Brian Ng
e4b35f680d
Run prettier 2017-06-27 12:15:00 -05:00
Simen Bekkhus
63b7137dac Add column range to babel-code-frame (#5646) 2017-05-31 15:22:46 -04:00
Brian Ng
8a82cc060a Run new lint rules (#5413) 2017-03-04 10:46:01 -05:00
Brian Ng
8c35b320d3 Bump eslint-config-babel and fix lint (#5129) 2017-01-17 10:51:16 +01:00
Henry Zhu
672adba9a1 enable prefer const (#5113) 2017-01-14 09:48:52 -05:00
Simon Lydell
d2113d4881 babel-code-frame: Upgrade to js-tokens@3 (#5094)
That version brings a big performance boost.
2017-01-13 12:11:44 -05:00
Joe Haddad
06820ca17d Add forceColor option to babel-code-frame (#4913) 2016-12-01 23:43:08 -05:00
Simon Lydell
bf0e256c3a babel-code-frame: Highlight strings with green (not red) (#4579)
- Red makes it look like something is wrong with the string.
- On Ubuntu-based systems, it looks kinda broken.
- The error markers (`>` and `^`) as well as invalid tokens are already
  marked with red. By not having strings red, the most important
  information -- the error location -- is more visible.

This is a continuation of commit fa1de5ce (PR #4572).
2016-09-27 15:35:17 -04:00
Simon Lydell
e40aad53a4 Improve syntax highlighting colors (#4572)
- Highlight the error location markers in bold red.
- Dim the line number gutter with grey.
- Don't highlight brackets. Few editor color schemes do.
- Add JSX tag highlighting.
- Don't highlight punctuators with bold. That looks bad on Ubuntu based
  systems. Instead, highlight them the same way as JSX tags, which
  results in really nice JSX highlighting.
- Highlight capitalized variable names.
- Make invalid tokens stand out with a red background.
2016-09-27 11:10:51 -04:00
Henry Zhu
afbe3997a8 babel-code-frame: add options for linesBefore, linesAfter (#4561)
* babel-code-frame: add options for linesBefore, linesAfter

* add example, use list of keywords

* a [skip ci]

* Update index.js
2016-09-26 16:12:35 -04:00
Bo Borgerson
8f790ceeed Satisfy the "space-infix-ops" eslint rule (#3696)
Future proofing against https://github.com/babel/eslint-config-babel/pull/1.

Only one violation, even without enforcement!
2016-09-02 18:50:03 -04:00
Simon Lydell
f80463120b babel-code-frame: Handle code with tabs
Previously, the `^` marker was misaligned if the line above contained tabs.

Fixes T7282.

Note: This commit handles a very subtle edge-case differently: When the passed
in column number is larger than the length of the line. Previously, the `^`
marker would be faithfully placed at that exact column number. Now, it is placed
at the end of the line instead (after the last character of the line to be
precise). Ideally, we should define what should happen in edge cases, but that's
out of scope for this PR.
2016-04-11 15:46:32 +02:00
Simon Lydell
dceb988bbb babel-code-frame: Fix indentation 2016-03-23 19:00:53 +01:00
Simon Lydell
aaaffd32e7 babel-code-frame: Get rid of the line-numbers dependency. 2016-03-23 18:59:39 +01:00
Simon Lydell
d6b8e4c608 babel-code-frame: Add tests 2016-03-23 18:38:07 +01:00
Simon Lydell
6af4ba1937 babel-code-frame: Update type annotation
The code allows omitting the column number, but the type annotation for that
parameter didn't.
2016-03-23 17:13:07 +01:00
Sebastian McKenzie
09287643c7 remove line-numbers from babel-code-frame 2016-03-22 22:08:25 +00:00
Amjad Masad
2fbe28cc88 Remove remaining @flow annotations 2016-03-03 15:10:59 -08:00
Amjad Masad
12ee11a0a4 Revert "Remove Flow annotations and pragmas"
This reverts commit 4252244d06b225ab26a02d52c04f9940a3e4d6a2.
2016-03-03 15:03:55 -08:00
Sam Goldman
4252244d06 Remove Flow annotations and pragmas 2016-02-28 13:18:57 -10:00
Sebastian McKenzie
5b89849f43 Switch to klint, fix some lint rules 2016-02-14 23:25:14 +00:00
Sebastian McKenzie
745f9fb5bd clean up babel-code-frame, var -> let etc - closes #2505 2015-10-08 01:19:27 +01:00
Sebastian McKenzie
3ef9bffcc2 split up babel core into multiple modules 2015-08-11 17:40:59 +01:00