-
-
Notifications
You must be signed in to change notification settings - Fork 199
Add support for eslint #232
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
Comments
Hi there! Interesting! So basically, this would output build warnings if eslint fails, right? I think it’s interesting; after all, it would be opt-in. But mostly, I like it including this in your Webpack build is considered a fairly common “best practice” (versus something that’s “possible”, but few people do it). Do you have an impression about that? |
At the company I work every webpack/gulp/grunt build task includes eslint. This to avoid having the developer to miss linting errors and only see it on post-commit instead of during his work. Especially given the fact it adds very little overhead and allows you to see eslint errors "live" in the console running the encore. How far this is a "best practice" in the world I don't really know. The eslint-loader we use has about 40k downloads a day: https://www.npmjs.com/package/eslint-loader . Most blogs even include it in the "default webpack/react setup" and I'm used to it. Haven't spoken about it to other people on conferences however. And yes, it should be opt-in. Especially given the Symfony flex philosophy. |
Hi, That'd be a great addition, we'll also have to think about doing the same for About the Encore.enableEslint(options => {
options.extends = 'airbnb';
}); It makes it a bit harder to use it but allows you to change a single options (other than Another possibility would be to mix both approaches: // Use default preset
Encore.enableEslint();
// Only change `extends`
Encore.enableEslint('airbnb');
// Change the `extends` and other options
Encore.enableEslint('airbnb', options => {
options.emitWarning = false;
}); |
I don't like the very last example. It makes the 'extends' property a little bit too special. I like the idea of the callback however, But what about the approach of supporting whatever the user gives us (in true jQuery style)? // Use default preset
Encore.enableEslint();
// Only change `extends`
Encore.enableEslint('airbnb');
// other options using a simple object
// Uses Object.assign({}, encoreDefaultOptions, options); internally
Encore.enableEslint({
extends: 'airbnb',
emitWarning: false;
});
// other options using callback that returns the options to use.
// this because of https://eslint.org/docs/rules/no-param-reassign
Encore.enableEslint(options => ({
...options,
emitWarning: false;
})); |
Great info! I like it! And I agree with the “interface”, though we probably will also need an optional callback arg of some sort. Would you be willing to open a PR for this? |
@weaverryan The callback is supported by @pinoniq's latest proposal, the idea being to have a different behavior based on the type of the first (and only) parameter. The only thing that worries me a bit there is the Encore
.enableVueLoader(options => ({
// Won't work
...options,
preLoaders: { ... }
}))
.enableEslint(options => ({
// Will work
...options,
emitWarning: false
}))
; |
Don't forget about loading settings from the |
@weaverryan I'll look into opening my first PR to the symfony community somewhere tomorrow or friday. @Lyrkan True about the confusing part. Maybe have a follow up ticket to work on a "single interface to rule them all" ? And thus for now, I go for the same as for Vue? @vkryukov76 that can be done using: Encore
.enableEslint({
configFile: './.eslintrc',
})
; |
I apologize for the delay. I finally managed to open a pr for this. Later than expected |
I like the idea of
Some code editors are able to import eslint settings from |
@wujekbogdan In my opinion not allowing to set the eslint-loader options would be a mistake:
|
You're right. If we still could use the config file then it's fine. I thought that the idea is to configure eslint only through the webpack config.
With |
I don't think Some other options are also specific to the |
What's the status on this PR ? |
This PR was merged into the master branch. Discussion ---------- #232 Added support for the eslint-loader I wasn't sure about whether to include the eslint-loader in the devDependencies or dependencies. Commits ------- 95af361 Remove eslint-plugin-import from required dependencies for enableEslintLoader() d06a0b3 Fix eslint-loader test cases 27b641e Removed the default import/resolver config 22fcb14 Fix misplaced cache option for the eslint-loader 0738691 Use the apply-options-callback method for the eslint-loader 87e1a02 Added the cache configuration for the eslint-loader 03bc596 Added a small functional test for eslint output a19414e Removed a default eslint rule Corrected spelling mistakes Reverted unrelated changes ce8c66d #232 Added support for the eslint-loader
Can this issue be closed since 2a1a18a was merged ? |
Webpack encore adds built in support for a coupld of "wide spread" front end libraries. Being ReactJs, jQuery and SASS.
There is however one that is even more widespread: eslint. Having an .enableEslint() (or even enabling it by default in non production mode) would be a plus.
However, if we go along the "default should be good enough" path. This means taking a side in the many different code-styles that exist in the JavaScript world.
A small list:
Instead of choosing a side, symfony could use the default eslint, with the possibility to change the "extends" property.
Combining this with
.autoProvidejQuery()
and.enableReactPreset()
would basically resort to something likeIs this something webpack encore is willing to add? If so, what path do we take?
The text was updated successfully, but these errors were encountered: