-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Run Lint from the command line? #1217
Comments
What is your use case for running lint separately? |
We are running it in coordination with Husky(https://github.com/typicode/husky) to run ESLint in our pre-push.
|
+1, could be useful to lint in CI if someone has no tests. |
even if one has tests, this would be useful. In our projects we usually first check if linting is correct before we actually run the tests in another ci step. Is this currently possible with create react app? e.g. sth like:
|
Yes, I erronously thought linting was checked inside the testing. A workaround is possible (npm >= 3), by directly executing (I'm currently linking that path to |
@caesarsol Interesting, an all-purpose solution would be great |
Why not build the project too? It could uncover other critical issues that ESLint might miss. |
My use case: because my component interacts with the server, and because I need the real server, I end up having to run npm build (which slowly builds an optimized package) when it would be very nice to just say "run eslint" and find out quickly whether I have syntax errors. I have tried the proxy web server but because my application requires an https connection and because the interaction between the server and client is complex I have never found a way to have that work successfullly. This is an Oauth2 oriented project. |
+1 |
+1, basicly want to integrate a https://github.com/observing/pre-commit hook to lint my app. |
@caesarsol Is your solution works with new version CRA? Tried executing:
but I can't see any output. What I'm doing wrong? |
maybe App.js does not have any errors? Try inserting and 'x' some place where it will cause an error ... |
@talkingtab: I tried with incorrect code in App.js file, which shows errors in browser box while running CRA. |
@talkingtab @caesarsol - Everything works okay now. I've... typed wrong path to file. App.js instead src/App.js |
Sometimes it's handy to do a quick test before pushing code upstream. Atom often misses some eslint errors if you didn't open the file. I don't remember if I had to install any additional packages other than what UPDATE: Specifying |
I'm open to adding support for Who wants to send a PR? |
If you use a |
I dunno if this is helpful to anyone but I wanted a simple sort of setup where I can run eslint from the command line also (e.g. If I am perhaps missing something with this setup (e.g. there is an easier way) feel free to let me know |
Is anyone working on this? I've built this functionality for a forked project. It would be fairly quick to contribute the work back |
It seems really weird that this isn't included. I assumed it would be done as part of the test phase as eslint config is already included. I fixed it by doing the following:
This requires adding |
I've just come across this and I'm having to install countless eslint plugins and parsers. Anyone else having this issue? Currently doing: npm run lint, get missing plugin from error message, npm install, npm lint, repeat. |
My solution was to use Prettier integrated with Vim. I have been a big fan of CRA but I have to say, this issue is one of the things that moved me to use Parcel - I felt like my tool (CRA) was picking a fight with me. The Parclejs system does not solve this problem either, but at least we're not fighting. And Prettier is a pretty good solution. |
@tomhicks, the solution posted by @SleepWalker works just fine in my case with the latest CRA version (3.4.1).
And it's linting every file in the |
I used @pedro-mass 's
|
My use case here is to get fast feedback from CI builds. Tests can sometimes be slow - especially if you have lots of them. |
Just a workaround, but executing the linting is pretty straightforward with VS Code. The following will use the same ESLint config as VS Code uses to show problems/errors at the editor:
Not as good as CLI, but at least this will show you all the problems for all files. |
i'm trying out yarn 2 with zero-install config, and i'm finding that just using |
Anyone still facing the problem, follow the above comment . Quoting to keep it visible -
I can't believe this simple thing has still not been merged. |
Thanks @bendtherules! You should also be able to use The official templates will also include our ESLint config in I think we can close this issue off now, unless anyone has any objections? |
@mrmckeb The main problem for me was - this is not documented in the cra website. It is not obvious at all (specially considering eslint is not visible as dependency). Currently, people will eventually land here and have a bad experience going through so much discussion. |
I think that's a great idea @bendtherules, and would definitely support adding this to the docs. Would you like to open a PR for that and ping me to review? |
What would be great is for the generated package.json to already have this,
so people can just run eslint without having to set anything up manually.
It seems like quite a simple change to avoid this whole discussion in the
first place.
…On Mon, 28 Sep 2020, 12:40 Brody McKee, ***@***.***> wrote:
I think that's a great idea @bendtherules
<https://github.com/bendtherules>, and would definitely support adding
this to the docs. Would you like to open a PR for that and ping me to
review?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1217 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAQEGBA43MKXAO6GDR5EWTSIBY3XANCNFSM4CZEZM2Q>
.
|
I second @sazzer. Can the team explain why that wouldn't be a good idea? |
I don't disagree personally, but it's also very easy to add manually. @ianschmitz and @iansu, what do you think about adding a |
Hey @danielstern . i'm here from googling "create react app lint script" (it's first result on google) and i found the solution on here after reading the whole discussion (~10 min). |
I'm trying to use yarn 2 so cannot just |
For Typescript projects works well even without specifying extensions as simple as:
|
I seriously don't understand what is the problem about adding this to the base template. People is used to have a lint script almost on every FE project. Is it easy to add manually? Yes, it is, after you have googled it, find this issue, read it entirely and you don't use |
is there any solution to this issue for yarn 2 besides adding eslint as a dependency to the root package? |
I created #11556 if anyone is interested. |
WorkaroundHere is how I got ESLint working from the command line under Yarn Berry (with PnP). Install deps (note: this list is most likely out-of-date. to find the correct version, hunt them down in your
package.json
.eslintrc.yml
.eslintignore
|
Any news? |
It would be great to be able to type
eslint
into bash and have it run ESLint just like it was building. As it is, it can't find the config file unless I eject. Is ejection really necessary here?The text was updated successfully, but these errors were encountered: