Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Different Prettier rules for different file types?

Does Prettier have a way to specify different rules for different file types?

For example, I want a greater maximum line length in our template files (.tsx) because it's more common for markup to be more deeply nested than application code. But for all other files I would like to enforce the standard 80 char width.

like image 321
doub1ejack Avatar asked Feb 04 '26 21:02

doub1ejack


1 Answers

You can add overrides like this:

{
    "printWidth": 80,
    "overrides": [
        {
            "files": "**/*.tsx",
            "options": {
                "printWidth": 120
            }
        }        
    ]
}

In that, printWidth option will be set to 80 for everything except files matching **/*.tsx, for which the printWidth will be 120.

like image 80
clai Avatar answered Feb 06 '26 19:02

clai



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!