Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

babel-code-frame: add options for linesBefore, linesAfter #4561

Merged
merged 4 commits into from Sep 26, 2016
Merged

Conversation

hzoo
Copy link
Member

@hzoo hzoo commented Sep 24, 2016

Q A
Bug fix? no
Breaking change? no
New feature? yes
Deprecations? no
Spec compliancy? no
Tests added/pass? yes
Fixed tickets comma-separated list of tickets fixed by the PR, if any
License MIT
Doc PR reference to the documentation PR, if any

@hzoo hzoo added the PR: New Feature 🚀 A type of pull request used for our changelog categories label Sep 24, 2016
@hzoo
Copy link
Member Author

hzoo commented Sep 24, 2016

@lydell is if (token.type === "name" && esutils.keyword.isReservedWordES6(token.value)) { needed anymore if js-tokens supports es6 in 2.0.0? Then we can remove esutils

@codecov-io
Copy link

codecov-io commented Sep 24, 2016

Current coverage is 88.47% (diff: 100%)

Merging #4561 into master will increase coverage by <.01%

@@             master      #4561   diff @@
==========================================
  Files           192        192          
  Lines         13491      13493     +2   
  Methods        1412       1412          
  Messages          0          0          
  Branches       3126       3128     +2   
==========================================
+ Hits          11936      11938     +2   
  Misses         1555       1555          
  Partials          0          0          

Powered by Codecov. Last update a832620...823f4b9

@lydell
Copy link
Contributor

lydell commented Sep 24, 2016

From js-tokens’ readme:

Names are ECMAScript IdentifierNames, that is, including both identifiers and
keywords. You may use is-keyword-js to tell them apart.

In the initial PR where js-tokens was introduced (back in the Babel 5 days), is-keyword-js actually was used, but was quickly removed since esutils already was a dependency of Babel 5.

@lydell
Copy link
Contributor

lydell commented Sep 24, 2016

Also, don’t forget to add the new options to the table in babel-code-frame’s readme :)

@hzoo
Copy link
Member Author

hzoo commented Sep 24, 2016

Oh ok so we need it - weird I did add the readme but it wasn't pushed😃

@hzoo
Copy link
Member Author

hzoo commented Sep 24, 2016

@lydell ok just going to use a list of keywords - also it was because I was modifying node_modules/readme for some reason haha

@@ -38,3 +38,5 @@ If the column number is not known, you may pass `null` instead.
name | type | default | description
-----------------------|----------|-----------------|------------------------------------------------------
highlightCode | boolean | `false` | Syntax highlight the code as JavaScript for terminals
linesAbove | number | 2 | The number of lines to show above the error
linesBelow | number | 3 | The number of lines to show below the error
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least in this github diff, the columns don’t seem to line up :)

];

function isKeyword(str) {
return KEYWORDS.indexOf(str) > -1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to let KEYWORDS be a Set and do KEYWORDS.has(str)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're not using transform-runtime or node 4 so just doing this or we can hasOwnProperty it

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok doing that

@hzoo hzoo force-pushed the code-frame-opts branch 2 times, most recently from cdec3b5 to e3b1ea4 Compare September 24, 2016 20:00
"while": true,
"with": true,
"yield": true
};
Copy link
Member

@danez danez Sep 25, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we also use esutils in in other places to check for keywords. If we now want to manage keywords ourself should we maybe but them in a central place, so all packages can use them?

Copy link
Member Author

@hzoo hzoo Sep 26, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was going to remove the deps for this package so other tools can use easily, what do you think? Or maybe it's not that big of a deal and we should leave it

"while": true,
"with": true,
"yield": true
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a strong opinion about using or not using esutils, but I think it would be nice to have a single source of truth for keywords throughout all the babel packages.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'l just leave esutils in for now and we can decide that later

@hzoo
Copy link
Member Author

hzoo commented Sep 26, 2016

Ok it just adds the option

@hzoo
Copy link
Member Author

hzoo commented Sep 26, 2016

@lydell good? going to merge this first

@lydell
Copy link
Contributor

lydell commented Sep 26, 2016

Yes! 👍

@hzoo hzoo merged commit afbe399 into master Sep 26, 2016
@hzoo hzoo deleted the code-frame-opts branch October 1, 2016 19:07
panagosg7 pushed a commit to panagosg7/babel that referenced this pull request Jan 17, 2017
* babel-code-frame: add options for linesBefore, linesAfter

* add example, use list of keywords

* a [skip ci]

* Update index.js
@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Oct 7, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: New Feature 🚀 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants