This repository was archived by the owner on Jan 19, 2019. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 75
Breaking: Implement parseForESLint() function #412
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
21 changes: 21 additions & 0 deletions
21
tests/integration/external-fixtures/declared-empty-body-functions.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
"use strict"; | ||
|
||
declare namespace FF { | ||
class Foo extends Bar.Baz { | ||
far(): any; | ||
} | ||
} | ||
|
||
declare module "FF" { | ||
class Foo extends Bar.Baz { | ||
far(): any; | ||
} | ||
} | ||
|
||
declare class Foo extends Bar.Baz { | ||
far(): any; | ||
} | ||
|
||
declare namespace d3 { | ||
export function select(selector: string): Selection<any>; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** | ||
* @a | ||
*/ | ||
foo; | ||
|
||
/** | ||
* @a | ||
*/ | ||
/** | ||
* a | ||
*/ | ||
foo; |
14 changes: 14 additions & 0 deletions
14
tests/integration/external-fixtures/no-redeclare-overloaded-functions.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
export async function readFile( | ||
filename: string, | ||
options?: { flag?: string } | ||
): Promise<Buffer> | ||
export async function readFile( | ||
filename: string, | ||
options?: { encoding: BufferEncoding; flag?: string } | ||
): Promise<string> | ||
export async function readFile( | ||
filename: string, | ||
options?: { encoding?: string; flag?: string } | ||
): Promise<Buffer | string> { | ||
// ... | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class a { | ||
/** @b {} c */ | ||
d = e => {} | ||
} |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be best to avoid mutating the options object provided by the user. (This was also a problem in eslint/js#329.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In which case I would be forced to change the signature of
parse()
to accept an optional third argument. There's no reason that would be an issue, right?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it would be an issue.
If you don't want the change to be visible to the public API, you could create a helper function, e.g.
parseMaybeForESlint(code, options, internalOptions)
, and haveparse
callparseMaybeForESLint(code, options, { isForESLint: false })
and haveparseForESLint
callparseMaybeForESLint(code, options, { isForESLint: true })
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about just defensively cloning the options so the user can't see the mutation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could also do
options = Object.assign({}, options, { parseForESLint: true })
. Or insertoptions = Object.create(options)
before this line.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems strange to have
parseForESLint
be mixed with the user-provided options object. For example, if the user addedparseForESLint: true
to their options object for some reason, they could cause strange behavior.