eslint default rules implementation #10066
brianpmccullough
started this conversation in
Ideas
Replies: 1 comment
-
I took a stab at what this might look like: https://github.com/brianpmccullough/spfx-eslint |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello, I am digging in recently on the ESLint configuration in SPFx projects. I am looking at SPFx 1.20, rather than earlier versions.
I am thinking about organizations who are accumulating lots of SPFx repositories and exposed to configuration "drift". That is, inconsistently applied eslint configurations between various projects. With all the rules copied into the eslintrc.js, it's difficult to tell, quickly, which rules are overridden from the SPFx defaults.
I notice that in my React based applications, I get, at a high level:
I am aware of another eslint discussion started by @andrewconnell a while back (see: #8290). Admittedly, at the time, this conversation was lost on me, but I think I understand ESLint configuration a bit more now.
If we have the ability to override the rules in our projects, why does SPFx not provide a base set of rules in their configuration, and instead copy/paste the rules into the eslintrc.js in EVERY project (possibly after @AJIXuMuK response to @andrewconnell here: #8290 (comment))? Or, perhaps, just add an additional item in extends like "@microsoft/eslint-config-spfx/lib/profiles/default-rules", which if you prefer to not have opinionated defaults (like Andrew), you could simply remove the "default-rules" from the "extends"? The latter might have the additional benefit of versioning the default rules with each SPFx release, allowing teams during upgrade to choose to delay moving to a new set of rules, if for example, it causes a bunch of new errors/warnings.
I notice in SPFx 1.20 now, there are two configurations in microsoft/eslint-config-spfx/lib/profiles/default, so it appears SPFx team are not opposed to embedding some default behaviors in the default eslint config.
In lieu of Microsoft NOT providing their default rule configurations centrally, what if a central package was created that maintained the SPFx defaults. Could perhaps be a Patterns and Practices (PnP) package?
This way, a project's eslintrc.js might look instead like so:
For reference, an SPFx 1.20 OOB React eslintrc.js:
Beta Was this translation helpful? Give feedback.
All reactions