Comments (12)
Looks good but I think I might be able to add something. Please leave it open and I'll get back to you ASAP.
from maintenance-book.
How many rules does Prettier implement over CSS? Some are exposed via options, I guess there are others.
It doesn‘t implement any rules, it formats code, so you’ll need to remove any code style rules from Stylelint config. Same as with ESLint.
Will Prettier support plugins, as Stylelint does (such as Order)? This strikes me as a very useful plugin which makes Stylelint worth using right away.
I’m 99.9% sure it won’t. The whole point of Prettier is no config and no arguments on code style in teams ;-) But you can continue use Stylelint with this plugin.
Can Stylelint --fix all the rules that Stylefmt used to be able to do (thus rendering the latter definitely redundant)?
That’s why we removed Stylefmt from the book ;-)
Are there things that Prettier fixes in terms of formatting that Stylelint does not, thus making it worth using?
Stylelint doesn’t reformat code, it just enforces some code style rules. I think I’m answering this question here.
Should we all these to the book? ;-)
from maintenance-book.
Bottom line: what's the best workflow with these tools to take maximum advantage of linting and fixing, without redundancy?
The one we explain in the book ;-)
from maintenance-book.
What I meant by Prettier implementing "rules" was its internal rules for formatting which might match ESLint's. Sorry if I didn't make that clear.
I agree it looks very unlikely that Prettier will implement plugins - I appreciate it is deliberately minimal in config.
That’s why we removed Stylefmt from the book ;-)
I'll take that as a "Yes" that Stylelint can now fix all the rules that Stylefmt could - thanks!
Stylelint doesn’t reformat code
Couldn't we say Stylelint does some reformatting in the sense of using --fix
to change spacing etc.?
Thanks - I will have another look at your article, although I think it relates only to JS. I was just wondering if there is formatting of CSS that Prettier performs that stylelint --fix
cannot.
Yes, as you say in the book, perhaps ESLint and Prettier are both worth running. Feel free to close this if you think you already have these points sufficiently covered.
from maintenance-book.
What I meant by Prettier implementing "rules" was its internal rules for formatting which might match ESLint's. Sorry if I didn't make that clear.
I don’t think such comparison makes much sense because Prettier completely reformats the code from AST and only very basic rules like quotes or semicolons may match ESLint.
Couldn't we say Stylelint does some reformatting in the sense of using --fix to change spacing etc.?
We have some terminology issues here ;-) ESLint / Stylelint do change formatting a bit: add or remove whitespace, change type of quotes, etc. But they don’t reprint code from AST like Prettier does. So ESLint / Stylelint try to fix already formatted code and Prettier completely (not 100% but very close) ignores original code formatting. I don’t think we should use the same word to describe both processes. @bebraw what do you think? ;-)
Thanks - I will have another look at your article, although I think it relates only to JS. I was just wondering if there is formatting of CSS that Prettier performs that stylelint --fix cannot.
It describes the difference between two different processes: Stylelint can‘t do the thing we don’t know how to call that Prettier does ;-)
Yes, as you say in the book, perhaps ESLint and Prettier are both worth running. Feel free to close this if you think you already have these points sufficiently covered.
I think it can be improved, so let’s keep it open 🍕
from maintenance-book.
I would certainly say that ESLint and Stylelint format code when they fix those kinds of rules. By contrast, Prettier reprints all of the code, as you say, also formatting. It's just more of a "nuclear option"!
Just to be perfectly clear, is there anything that Prettier can format that stylelint --fix
cannot?
I'll get back to this tomorrow and mention if there is anything else I'm still not clear on. Thanks again :)
from maintenance-book.
A new article on this topic with an interesting post by the main developer of stylelint. Seems to me the main thing Prettier fixes (reprints) that Stylelint doesn't is line length. Main benefit of using stylelint in tandem with Prettier seems to be ability to use plugins like Order, as I mentioned (though it lints many other things too). Stylelint cannot yet fix all the rules that stylefmt can (see for example declaration-colon-space-after
), but they're adding them all the time. :)
from maintenance-book.
Probably we need to add a short section on liters v. formatters to clarify why you need to use both.
from maintenance-book.
This should make it more clear: #62
from maintenance-book.
@gavinorland What do you think? Time to close?
from maintenance-book.
Right, I was just reviewing what exactly are the differences between the tools again. Of course, Prettier actually reformats, but I wanted to check on what it does that ESLint cannot. If you wanted to be a bit more explicit for the curious reader (like me!) maybe this would be of use:
A common misconception is that if you use a code formatter like Prettier then you don’t need a linter anymore. However, Prettier will not touch any code quality issues, such as unused variables or implicit globals. And while both ESLint and Prettier can auto-fix semi-colon, indent, quote, comma dangling and spacing preferences, Prettier can operate on more file types (including JSON and CSS) and, as it reprints, it can also for example auto-fix line lengths where possible and remove unnecessary space between code blocks. Therefore at present it's worth using both of these tools together.
Up to you guys!
from maintenance-book.
@gavinorland Take a look at #63, is it better now?
from maintenance-book.
Related Issues (20)
- Chapter idea: TODO comments monitoring
- Cover changesets
- Cover GitHub Actions
- Infrastructure / automation / bots
- Cover remark-lint
- Packaging misses HOT 4
- Cover CODEOWNERS
- Infrastructure refactor & new section HOT 4
- Spanish translation
- Split testing chapter HOT 1
- Cover npm ci
- Cover Travis CI stages
- Feedback from Marc HOT 3
- Consider different viewpoints HOT 4
- Cover microbundle
- eslintrc do not support json5 HOT 1
- Cover sideEffects flag in package.json
- linting typescript using eslint HOT 2
- nsp has been deprecated HOT 1
- cover security HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from maintenance-book.