Export a kibana restricted type definition#1239
Merged
Conversation
mshustov
reviewed
Jun 30, 2020
2 tasks
mshustov
reviewed
Jul 6, 2020
| let oldTypeDefString = readFileSync(typeDefFile, 'utf8') | ||
| let start = oldTypeDefString.indexOf('/* GENERATED */') | ||
| let end = oldTypeDefString.indexOf('/* /GENERATED */') | ||
| let newTypeDefString = oldTypeDefString.slice(0, start + 15) + '\n' + types + '\n ' + oldTypeDefString.slice(end) |
Contributor
There was a problem hiding this comment.
nit: it's easy to forget to update length if we change start token. Do you think you could you refer it explicitly?
const startToken = '/* GENERATED */';
let startPosition = oldTypeDefString.indexOf(startToken)
let newTypeDefString = oldTypeDefString.slice(0, start + startToken.length) + ...
Member
Author
There was a problem hiding this comment.
I don't expect it to change, also, we could still forget to update it here :D
There was a problem hiding this comment.
@delvedor Jumping in on @restrry comment. The recommended change is not only to cover the case where "start token" would change, but also to avoid "magic" number as per our styleguide (https://github.com/elastic/kibana/blob/master/STYLEGUIDE.md#magic-numbersstrings).
When I read 15 it does not mean anything, when I read startToken.length it is explicit what it is. Just my 2 cents 😊
mshustov
approved these changes
Jul 6, 2020
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
While working on #1243 and elastic/kibana#69905 we have decided that we should start shipping a restricted type definition file for Kibana, which hides the snake_cased and callbacks style APIs.
The type can be used as follows: