Closed janpanschab closed 8 years ago
+1
I suggest to create our own eslint-config-actum
module and store all the rules there.
Why:
.eslintrc
is good, but this way you need to drag this file wherever development stack goes. When the same may be done like this:
{ "eslintConfig": { "extends": "actum" } }
package.json
, and they will overwrite the options imported from eslint-config-actum
just for this very project.dev.js
extends production config with making some rules less strict for us, developers.package.json
and, for example, removing AirBnB styleguide (in case we want to use something different).How:
Taking eslint-config-airbnb
as an example, I have written a simple npm module and put it on GitHub. Being tested within our latest gulp-dev-stack, it works fine, and it is easy to say Gulp tasks to use development rules when required. It still needs polishing, of course.
What's next: Regardless of the outcome of my suggestion, it would still be tremendously helpful for us to configure our production and development rules. I believe this is up to you, guys - @janpanschab @vbulant.
Let me know what you think about this suggestion.
Nice summary. I will check it ASAP. Thx
Update: I would really recommend to implement this logic toward the linting:
Basically, this is from my experience, when there are some multiple lines occasionally left over, and right now linting does not warn you about it, unless you run build (which is time consuming sometimes). So I would recommend to always lint the rules, but make a different level warnings on development and production.
Agreed. We have something similar currently in gulp/tasks/lint.js
. It takes production rules from package.json and then softens them in case you’re in DEV environment.
@kettanaito Could you test the linter on some our current project code? ETL or Zindulka and extract the problematic rules? Then we can establish a commission and vote for rules settings :-)
@janpanschab okay. I will keep this message updated with the differentiable rules for development/production.
These rules should be strict (prevent from build) on production and warnings on development. If we set proper strictness level on these rules, I think it makes sense to set failOnError
(or its equivalent) to true
, because errors should prevent from build.
no-multiple-empty-lines
May happen by accident, and should not prevent from development, but rather be present in the terminal as a warning to look out for.no-console
Essential for debugging, and often left out.no-alert
Essential for debugging, and often left out.quotes
To not bother when, for example, trying some external solution, which does not share our lint rules. These occasions do happen, and the point during them is to find out the best solution, without spending time on correcting somebody else's coding style. If solution works - you see the warning in the terminal, and then you may clean it up.Overrides from este:
// Soft some rules.
"new-cap": [2, {"capIsNew": false, "newIsCap": true}], // For Record() etc.
"no-class-assign": 0, // Class assign is used for higher order components.
"no-nested-ternary": 0, // It's nice for JSX.
"no-param-reassign": 0, // We love param reassignment. Naming is hard.
"no-shadow": 0, // Shadowing is a nice language feature. Naming is hard.
"no-underscore-dangle": 0, // It's classic pattern to denote private props.
"react/prefer-stateless-function": 0, // We are not there yet.
"import/imports-first": 0, // Este sorts by atom/sort-lines natural order.
"react/jsx-filename-extension": 0, // No, JSX belongs to .js files
"jsx-a11y/html-has-lang": 0, // Can't recognize the Helmet.
"no-confusing-arrow": 0, // This rule is super confusing.
// Extension of rules.
"import/extensions": 2, // Ensure consistent use of file extension.
@vbulant Thank you. Do you think these are all production rules?
@kettanaito Yes, I do. We use them in production on FirstScreen/Remy.
Consider implementing Airbnb JS styleguide. It’s great - https://github.com/airbnb/javascript. https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb