-
-
Notifications
You must be signed in to change notification settings - Fork 381
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
Add unopinionated
preset
#896
Comments
I'm open to adding an
This is not about being opinionated though. We are not going to leave out rules just because they don't work with Prettier. This is already handled by https://github.com/prettier/eslint-config-prettier/blob/07380e2235cea405822b7c0de20bbecbf2dc6da0/unicorn.js#L5.
We already handle some React cases and we're happy to handle more, but yes, this one is quite opinionated.
You can select classes and IDs with query selector too. I remember reading something about engines just using the fast-path internally for simple selectors.
I can buy the React argument as there are many places you have to use the |
I would highly appreciate a separate |
@sindresorhus Is there anything I could help with to advance the state of this proposal? |
@fisker Are you ok with this? |
Yes, I think it's good. |
recommended
configunopinionated
preset
Isn't every rule potentially "opinionated"? I think you're looking at a airbnb-specific unicorn configuration, like a Or, if worth having in this package, perhaps it should explicitly mention airbnb: |
No. Some rules are about correctness or preventing bugs. I don't consider that opinionated. I also wouldn't consider rules that enforce using more modern APIs opinionated. For example,
I don't see why it should have the name of a random ESLint config. |
Would also be nice if there were some preset that disables the rules that conflict with |
Ah I was on an old version, thanks for this!
Omar
…On Thu, May 27, 2021 at 9:58 AM, fisker Cheung ***@***.***> wrote:
@osdiab <https://github.com/osdiab> https://github.com/prettier/
eslint-config-prettier/blob/83c4f374f06d0cb1c0e55bc3f3b1ab75a1a34a89/
index.js#L142-L144
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#896 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAONU3XEAUVQPYLM5UWPMVTTPWKLTANCNFSM4TEMYEDA>
.
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Evidence to the contrary, showing a significant performance advantage for https://blog.wesleyac.com/posts/getelementbyid-vs-queryselector Also, correctly selecting a computed ID or class name with |
If someon wants to switch off the rules from OP, here is a snippet to copy and paste: {
'unicorn/prevent-abbreviations': 'off',
'unicorn/filename-case': 'off',
'unicorn/no-nested-ternary': 'off',
'unicorn/no-null': 'off',
'unicorn/no-useless-undefined': 'off',
'unicorn/prefer-query-selector': 'off',
} |
Hello, wondering if there were any updates on an unopinionated config setting? |
We will add this when we have fully switched to flat config. I don't want to expose more configs until then. |
I propose turning off the following rules by default, so that the
recommended
config could act as a baseline which may be extended explicitly:unicorn/filename-case
– This goes against the principle set by one of the most popular linting packages,eslint-config-airbnb
. See this excerpt from their style guide:unicorn/no-nested-ternary
– Doesn't work properly when used along with Prettier, as formatting removes parentheses used in ternary expressions.unicorn/no-null
– This is very opinionated and external libraries like React and Prisma depend onnull
. Also,something == null
checks for bothnull
andundefined
at once, so it's less prone to errors in comparison tosomething === undefined || something === null
.unicorn/no-useless-undefined
– Conflicts with ESLint's built-inconsistent-return
rule, which is enforced by Airbnb's config. Causes all of the following code to be invalid:unicorn/prefer-query-selector
– The alternatives, namelygetElementById
andgetElementsByClassName
, offer better performance. Selector-based queries should be avoided in general, even in CSS, as they get complex pretty fast. Using IDs and class names for locating elements is a well-tested practice, while complex selectors are questionable.unicorn/prevent-abbreviations
– While the intent is great, way too many false positives may occur. For instance, React uses the termprops
to identify attributes passed to a JSX element. They aren't widely calledproperties
in the documentation and tutorials. Same goes for thereq
andres
parameters of an API handler function, as popularized by Express.As an alternative, a
recommended-loose
orrecommended-unopinionated
config may also be added to avoid the issues outline above. My goal is to set up ESLint with a strict set of rules as simple as below:The text was updated successfully, but these errors were encountered: