Skip to content

WIP: Swap ember-cli-eslint for ESLint#8219

Closed
kellyselden wants to merge 2 commits intoember-cli:masterfrom
kellyselden:ember-cli-eslint
Closed

WIP: Swap ember-cli-eslint for ESLint#8219
kellyselden wants to merge 2 commits intoember-cli:masterfrom
kellyselden:ember-cli-eslint

Conversation

@kellyselden
Copy link
Copy Markdown
Member

Implementation of ember-cli/rfcs#121.

I already started doing this at work, so I want to get it upstream.


* `ember test`
* `ember test --server`
* `<% if (yarn) { %>yarn test<% } else { %>npm test<% } %>`
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We already have linting mentioned below, so it's a bit redundant to mention the command that runs linting as well. On the other hand, how are people going to learn that ember test no longer lints, and that you should be running npm test to get the old behavior?

Also, we now have a weird mix of npm-scripts wrapped commands and native ember-cli commands. We may need learning team help on resolving this confusion. cc @jenweber @NullVoxPopuli @kennethlarsen

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

maybe, just concat the commands together (at least for now?)

like,

yarn lint:js && yarn test

or, we split it out into different travis jobs?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

You mean yarn lint:js && ember test?

It is already split in travis (or should be).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You mean yarn lint:js && ember test?

idk, I prefix everything with yarn, so I know I'm using the local version

It is already split in travis (or should be).

#biwinning

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Perhaps the test output could indicate that linting is not included. For example, it could say afterwards "to run linting, use npm test." I will have to think about this some.

Beginners aside, this is a tough question because I imagine that many people just do ember test in their CI. I don't use Travis and I'm pretty sure that I just run ember test in CI.

@@ -15,7 +15,7 @@
"lint:hbs": "ember-template-lint .",
"lint:js": "eslint .",
"start": "ember serve",
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Should we include this in the start and build commands (and test:all) as well?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

for least suprise, I think it'd make sense to add it.
But, I think just mentioning it in the release notes would be ok if we were to stop running linting before everything.
idk 🤷‍♂️

"lint:js": "eslint .",
"start": "ember serve",
"test": "ember test"
"test": "<% if (yarn) { %>yarn lint:hbs<% } else { %>npm run lint:hbs<% } %> && ember test"
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We could also utilize "pretest" as well. I'm not sure of the advantages of each. This is essentially equivalent:

"pretest": "npm run lint:js",
"test": "ember test"

"lint:js": "eslint .",
"start": "ember serve",
"test": "ember test"
"test": "<% if (yarn) { %>yarn lint:js<% } else { %>npm run lint:js<% } %> && ember test"
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I left off npm run lint:hbs because there is currently no way that I know to take template linting out of ember test. Once that is possible, we can add it here. @rwjblue correct me if I'm wrong.

Copy link
Copy Markdown

@happycollision happycollision Jan 3, 2020

Choose a reason for hiding this comment

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

You can remove ember-cli-template-lint and replace with ember-template-lint directly. This will keep Test'em from linting the hbs files, but you can still yarn lint:hbs with no issues.

@kellyselden
Copy link
Copy Markdown
Member Author

cc @sangm

* `ember test`
* `ember test --server`
* `<% if (yarn) { %>yarn test<% } else { %>npm test<% } %>`
* `<% if (yarn) { %>yarn test --server<% } else { %>npm test -- --server<% } %>`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍 💯

@kellyselden kellyselden force-pushed the ember-cli-eslint branch 2 times, most recently from ff79c38 to 89a3a7a Compare November 28, 2018 21:48
* `ember test`
* `ember test --server`
* `<% if (yarn) { %>yarn test<% } else { %>npm test<% } %>`
* `<% if (yarn) { %>yarn test --server<% } else { %>npm test -- --server<% } %>`
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@john-kurkowski just pointed out to me that yarn test --server is misleading. One might assume the linting part is watching the build too. This might be a job for something like https://www.npmjs.com/package/eslint-watch? cc @Turbo87 I know you were talking about something like this at one point.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Right, I do like 1 SPOT to look for all errors in all files, continuously. Today, that's the launched Testem UI. It reminds me of things my editor doesn't, because I switched away from the file with errors.

Running another watch process is an option, sure.

Maybe a commit hook would cover my edge case.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I don't think a commit hook would solve your live updating needs, that's like a "final check once you're all done", right? not a "while you work" solution.

@kellyselden kellyselden changed the title WIP: swap ember-cli-eslint for eslint swap ember-cli-eslint for eslint Nov 28, 2018
@Turbo87 Turbo87 changed the title swap ember-cli-eslint for eslint WIP: Swap ember-cli-eslint for ESLint Nov 29, 2018
@onlymejosh
Copy link
Copy Markdown

From reading the RFC it looks like there was a discussion about adding the documentation for setting up testem.js with eslint.

As part of the implementation work we would like to clearly document how to setup testem.js to properly run linting (both eslint and template linting) during ember test --server and at least link to it from an inline comment in testem.js (possibly even include it automatically?). (@rwjblue)

This should be a requirement of this PR as without it, it will completely change the workflow of some developers. The testem ui is basically my one-stop-shop for errors, I could add another step but it feels like going backwards rather than forwards. I don't want to have to rely on CI to tell me about linting issues and precommit hooks are a drag.

@kellyselden
Copy link
Copy Markdown
Member Author

@onlymejosh I added the testem hook before_tests to run linting to keep the conversation going.

@rwjblue Was this what you were thinking?

@onlymejosh
Copy link
Copy Markdown

If there is a linting issue would this stop the rest of the tests running? If so this is still a backwards change in my eyes. It should be the same as it currently is, linting issues should appear in the list of failures.

@rwjblue
Copy link
Copy Markdown
Member

rwjblue commented Mar 8, 2019

If so this is still a backwards change in my eyes

I'm sorry you feel this way.

It should be the same as it currently is, linting issues should appear in the list of failures.

Simply put, thats not going to happen. The RFC (and comment thread) specifically explain the rational, and when implementation is completed a newly generated app will not have the setup you are talking about. However, it is absolutely still a thing you can choose to opt in to (by installing ember-cli-eslint in your particular application).

@onlymejosh
Copy link
Copy Markdown

Ah ok so the solution is to use ember-cli-eslint

As part of the implementation work we would like to clearly document how to setup testem.js to properly run linting (both eslint and template linting) during ember test --server and at least link to it from an inline comment in testem.js (possibly even include it automatically?).

Is this what you meant by documenting? I guess I was confused by that comment. As I took it as it would act the same / similarly but it looks like that is not the case?

@sangm
Copy link
Copy Markdown
Contributor

sangm commented Jun 4, 2019

Any update on this?

@rwjblue
Copy link
Copy Markdown
Member

rwjblue commented Feb 24, 2020

The basic parts of this were by #9009,

I'm going to close this specific PR as rebasing it would be a nightmare (removal of MU, landing of an alternate approach in #9009, etc), but I'd love to see the other conversations that were ongoing here in smaller PRs focused on each topic.

@rwjblue rwjblue closed this Feb 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants