Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

ES2017 Rewrite #113

Merged
merged 5 commits into from
Oct 5, 2016
Merged

ES2017 Rewrite #113

merged 5 commits into from
Oct 5, 2016

Conversation

Arcanemagus
Copy link
Member

@Arcanemagus Arcanemagus commented Oct 3, 2016

Major rewrite in ES2015, including:

  • Clicking a rule name will now open the documentation
  • Disable on the fly linting!
    • The file copying method used before wasn't complete enough to cover all edge cases and was just causing problems.
  • Fix a race condition where file contents are changed after the lint is triggered
  • Move configuration to configSchema in package.json

The new regex was validated here: https://regex101.com/r/EVwEiU/1

Fixes #30.
Fixes #16.
Closes #13.
Fixes #12.

Major rewrite in ES2015, including:

* Clicking a rule name will now open the documentation
* Disable on the fly linting!
  * The file copying method used before wasn't complete enough to cover
      all edge cases and was just causing problems.
* Fix a race condition where file contents are changed after the lint is triggered
* Move configuration to `configSchema` in `package.json`
@Arcanemagus
Copy link
Member Author

@jschroeder9000 If you're still active here I'd love to have this looked over and your thoughts on the changes it is making.

ignored_cops:
- Style/FinalNewline
- Style/TrailingBlankLines
- Style/EndOfLine
Copy link
Member Author

Choose a reason for hiding this comment

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

For some reason this rule was triggering on all of the files for me, causing issues for the "valid" one. Unfortunately even though the other two are defined in the defaults and shouldn't be necessary here, it doesn't work without them.

"license": "MIT",
"engines": {
"atom": ">=1.0.0 <2.0.0"
"atom": ">=1.4.0 <2.0.0"
Copy link
Member Author

Choose a reason for hiding this comment

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

Atom v1.4.0 was the first version to support the configSchema.

// Add the file to be linted
parameters.push(filePath);

return helpers.exec(executablePath, parameters, options).then((output) => {

Choose a reason for hiding this comment

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

Can you make it an async function and await it instead? It'll save you from deeper nesting for so many lines

'to update the results.',
dismissable: true,
};
atom.notifications.addWarning(warnMessage, warnOptions);

Choose a reason for hiding this comment

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

This should be a console warning because this is too loud (as discussed privately)

}

const messages = [];
let match = regex.exec(output);

Choose a reason for hiding this comment

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

Code is duplicated here and at at line 94. You could make it like while ((match = regex.exec(output)) !== null )

Copy link
Member Author

Choose a reason for hiding this comment

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

That means you are assigning in the conditional of the while, which is against the code style guide.

Choose a reason for hiding this comment

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

I personally don't think it's wrong. Besides the code style guide was not given to us by God so we are free to object and change it to something that helps us keep the codebase clean and unduplicated

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, I personally agree with the code style guide so I'm keeping it the way it is 😛.

"atom": ">=1.4.0 <2.0.0"
},
"configSchema": {
"hamlLintExecutablePath": {

Choose a reason for hiding this comment

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

Make it just executablePath

Copy link
Member Author

Choose a reason for hiding this comment

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

Since this will be a major release, that sounds like a good idea.

Rename the configuration option to match all the other linters.
As the Atom notification might be too intrusive for a non-critical issue,
move this to the console.
Technically this makes it ES2017, but Atom supports this via Babel.
Conflicts:
	README.md
@Arcanemagus Arcanemagus changed the title ES2015 Rewrite ES2017 Rewrite Oct 4, 2016
@Arcanemagus
Copy link
Member Author

Giving this another day before merging.

@jschroeder9000
Copy link
Member

Thanks for your work on this, @Arcanemagus. I think this is a great start, though I find the decision to remove support for on the fly linting very disappointing.

I see that the linter is no longer using or even looking for a rubocop config at all. That will severely cripple the usefulness of the linter by always linting with rubocop defaults instead of the what the user/project desires.

Haml-lint has added support for setting an environment variable to specify the path to the rubocop config file (HAML_LINT_RUBOCOP_CONF) and I believe that will solve our problems. I think the right thing to do is to search for .rubocop.yml the same way the search for .haml-lint.yml is done and add the appropriate environment variable to the options passed to exec if it is found. No file copying is necessary and I think this should also correctly solve #30.

With that implementation in place and since no file copying is being performed, I think on the fly linting should remain in place.

@jschroeder9000
Copy link
Member

Open mouth, insert foot...

Haml-lint will find the .rubocop.yml and use it by itself since the source file is no longer being copied to a temporary location, so ignore my comments about needing to find it and pass an environment variable. I guess the only reason we would need to pass an environment variable would be if we wanted to add an option for a global .rubocop.yml file like we do with .haml-lint.yml. In fact, I don't think we need to be searching for a .haml-lint.yml file anymore either since files aren't being moved; haml-lint will find it by itself and use it. We would only need to pass it in if the global config file is set.

Since there is no longer any file copying and that was the reasoning for disabling on the fly linting, I guess I'm confused as to why it is still being disabled. I think the whole thing with hackily copying config files to a temp directory was a just a relic left over from the original linter plugin always copying files to a temp directory.

@Arcanemagus
Copy link
Member Author

The searching for the file is left in to support the "global config file" option, otherwise we don't know if we need to specify our special one from the settings or not.

Since there is no longer any file copying and that was the reasoning for disabling on the fly linting, I guess I'm confused as to why it is still being disabled.

I assumed from the fact that it was being copied in the first place that haml-lint doesn't support getting the contents from stdin, if we can send the current editor contents to it via stdin then of course we can just enable on the fly linting. I guess I never verified that it didn't 😛.

@jschroeder9000
Copy link
Member

Ah, I had forgotten the issue with STDIN. It's all coming back to me now. Haml-lint does not support linting from STDIN and I agree simplifying things and disabling on the fly linting is the way to go.

I think this looks good and linking to the documentation is definitely a cool addition.

👍 from me.

@Arcanemagus Arcanemagus merged commit 69e45e8 into master Oct 5, 2016
@Arcanemagus Arcanemagus deleted the es2015-rewrite branch October 5, 2016 16:11
@Arcanemagus
Copy link
Member Author

Published as v2.0.0! 🎉

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants