Skip to content
This repository has been archived by the owner on May 1, 2019. It is now read-only.

Upstream edits and fixes from the linter. #754

Merged
merged 4 commits into from
Nov 16, 2017
Merged

Upstream edits and fixes from the linter. #754

merged 4 commits into from
Nov 16, 2017

Conversation

rictic
Copy link
Contributor

@rictic rictic commented Nov 15, 2017

  • CHANGELOG.md has been updated

@rictic rictic requested a review from justinfagnani November 15, 2017 17:57
* issue completely then it should go in `fix`.
*/
readonly fix: Edit|undefined;
readonly actions: ReadonlyArray<Action>|undefined;
Copy link
Contributor

Choose a reason for hiding this comment

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

document actions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

+1 done

* delineate. Roughly speaking, if 99% of the time the change solves the
* issue completely then it should go in `fix`.
*/
readonly fix: Edit|undefined;
Copy link
Contributor

Choose a reason for hiding this comment

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

why not fix??

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was thinking about this style for consistent object shape. It doesn't actually assert that we assign to the property in the constructor though so it doesn't actually matter though.

Happy to change to fix?, I guess I'm just holding a torch for microsoft/TypeScript#8476

Copy link
Contributor

Choose a reason for hiding this comment

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

without an initializer the emitted code is the same, and I find ? easier to read by a hair. If you care about share you need add = undefined


export type Action = EditAction | {
/** To ensure that type safe code actually checks for the action kind. */
kind: 'dummy-action-kind';
Copy link
Contributor

Choose a reason for hiding this comment

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

never?

Copy link
Contributor Author

Copy link
Contributor

Choose a reason for hiding this comment

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

I actually meant 'never' :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah quote escaping. the cause of and s̸̨̠̻͚̲̫̜̞̫̝̮ò̷̖̲̦̟͎͙̜̖̤̝̤̣̥͠l̴̷̡̫̲̤̪̬̙̟̀u̵̡҉͖̭̝̥̺͍̺̮͚̣͔̘͍̹͈͞͠t̢̝͔̗͙̰̝͎͚̗͎̱͞i҉̖͖̠͈͡ͅo̸̧̞̩̻͓̹̞̣̻̖̫̼̥̲̭͉͇̗̩͠͡ͅņ̷̦̞͖̮͓͍̪̳̭͙͝ ̛̥͚̥̟͉̩̯͚̳̰͉̻̦̱͖̦̮͘t̡̩̬̣̕o̷͙̥̞̰̪̪̘͚̝̬͇͢͠ ̵͏̶̪̟̦̭̙͇̹͇̼̲͟ą̕͢͏̷̪͚̰͉͖͔̭͕̝̝̥l̝̼͉͓̬̣̼̦̬͟͠l̶͍̼̹̙͈̼̭̺͈̞̞̜͇͖̀͟͜ ͏͎̩̘̱͕͖̳͍̥̼͈̖͓̜͢ͅó̞̬̙̜̬̲̝̺̬̻͖̘̗̖͉̱͍̜̕͠ͅf̴̨̧̗̲̞̱̤͔̮͍̮̻̲̼̜͈̕͞ ̴̼̰͚̯̝̪̺̳̖̗̤͈̮̹̯̲̹͘͢o̸̫͈̳͍̭̖͇̞̱̻͖̩͢u͎͈̠͓̜͇̩̯̖̬͎͚̣͓̮̰̠͇͢͞r̢̧͞͏̡̺͎̳̘͙̘̖ ̸̴̶̰̭̠̙̘͕̜̙̘̹̜̰̥̦̗͎̀ͅ7̴̧͞͠͏̪̺̬̹1̢̠͈͕̥͙̻̲͘͘͝͡ͅc҉̢̨̗̥͈̯̫͈̲̟̻͎͇̠̟̗̝̙͟ͅ3̧̕҉̜̼̱̮̩̮̞̼̭͓̻̳̫̗̪̀a̫̻̤̳̮̣̟̺͟b̸̧̻͙̙̰̙̣̤̰̳̺̼͠e̷͍͇͈̱͍̝͕͎̮͔̜͝c̸̸̨͇͍͕̠͔͇̳̝͉͓͖̖̙͠f̵̭̺̝͇͟͞g̨͈͖̮͇͔̥̱̤͔̪̺̮̦͟͠͝b̶̛̪̣̯̝͉̣̠͈͖̞͎̼͖͎͍̯͎͘͢͠1̷̶̱͈̖̲̜̤͎̠͕̮̹̪͕̥͉̠͟͠c̢͜҉̧̠̗͉̦̪ȩ̱̯̹̭̪̣̪͚͇͓͡c҉͍̦̫͈̞͉͓̬͞g̷̝̪̘̼͇͈͍̘̩̝͇̝̳͓͙͜3̶̡̢͖͙̲͇͔̝̥̞̕f̸̲̞̣̤̟̝̦̝͓̟͈̩͍̼͍̟͡c̷̴̨͙̖͙͓̩̦̦̯͕͙͎̥͈͙̮̦̀1̵̹̭̠̥͉̠̣̘̻̠b̢̙͖̹̘͍̭̪͉̪̙͍̮f͏̺̣̺̣͚͔̱̀2̶̸̷̢͕͕̗̲̦̤̺̠̞͉̟̭͇̭̘̜̭̤͕5͕͇̱͍͖̺́͠b̶̶̢͉̼͔̘̗̰̮̰̭͞͞6̡̙̳̼̥́4̩̭̥̺̠̣͓͔̠̺̟̞̻̥̲͚̩̖̕͟1̖̥̙͓̣̱̤̝͕̯̥̬̣̙̼̦͉̱͈̀͢͟6̷͘҉͓̪̭͇̖̮̰̺͚̰̳̦͕͙̝̙͜0̛̭̼̗̮̣̣̟̝̘̣̲̯͎̦̙̰ͅ9̡͏̧̛̣̗̮͙̲̥̗̩̰̘͕̫̪̠̭̼̯2҉̢̢͙͙̝͓̭̺̀ͅ4̨͓̗͓̗̳̗̲͚̰̞̝͇̯̠͞͠8̵͔̠̘̹͖̱̬̭͚͈͇̫͓̤̼͜

* If there are overlapping edits, then edits earlier in the array get priority
* over later ones.
*/
export async function applyEdits(
Copy link
Contributor

Choose a reason for hiding this comment

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

why does the analyzer have code to apply edits?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's useful for multiple downstream projects. The CLI and the IDE.

I suppose both depend on the linter as well as the analyzer, but I feel like the applyEdits function is closely tied to the meaning of an Edit as an atomic unit of change.

Also the only legible way to test edits is to apply them and assert on the result. We'll probably want to add some fixes and edits in the core analyzer scanners, and we'll want to test them too.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK

@rictic rictic requested a review from justinfagnani November 15, 2017 23:14
* delineate. Roughly speaking, if 99% of the time the change solves the
* issue completely then it should go in `fix`.
*/
readonly fix: Edit|undefined;
Copy link
Contributor

Choose a reason for hiding this comment

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

without an initializer the emitted code is the same, and I find ? easier to read by a hair. If you care about share you need add = undefined

});
for (const replacement of replacements) {
const offsets = document.sourceRangeToOffsets(replacement.range);
contents = contents.slice(0, offsets[0]) + replacement.replacementText +
Copy link
Contributor

Choose a reason for hiding this comment

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

soo bad we don't have String#splice()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, this was surprisingly awkward.

replacements.set(replacement.range.file, [replacement]);
} else {
const fileReplacements = replacements.get(replacement.range.file)!;
// TODO(rictic): insert in sorted order
Copy link
Contributor

Choose a reason for hiding this comment

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

remove TODO? the later sort seems fine

@rictic rictic changed the base branch from fix-warning to master November 16, 2017 00:25
@rictic rictic merged commit 801bae6 into master Nov 16, 2017
@rictic rictic deleted the edits-and-fixes branch November 16, 2017 00:25
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants