简体   繁体   中英

How can i improve code formatting using prettier configuration

I am using prettier with vs code with the option "editor.formatOnSave": true

Here is my .prettierrc config:

module.exports = {
    semi: false,
    overrides: [
        {
            files: ['*.js', '*.json', '*.css'],
            options: {
                trailingComma: 'es5',
                tabWidth: 4,
                semi: true,
                singleQuote: true,
            },
        },
        {
            files: ['*.html'],
            options: {},
        },
    ],
};

is there a better way of doing that? and what should I put in the HTML option for a cleaner HTML code without having something like this:

<tr
                    ng-repeat="student in displayVars.studentsToShow track by student.id"
                >

my HTML files should be in the one line something like that and I am not sure what's going on

<tr ng-repeat="student in displayVars.studentsToShow track by student.id">

by the way, I am using angulars 1 it's an old project to maintain.

we should add printWidth option to 1000

module.exports = {
    semi: false,
    overrides: [
        {
            files: ['*.js', '*.json', '*.css'],
            options: {
                trailingComma: 'es5',
                tabWidth: 4,
                semi: true,
                singleQuote: true,
            },
        },

        {
            files: ['*.html'],
            options: {
                printWidth: 1000,
                tabWidth: 4,
                htmlWhitespaceSensitivity: 'ignore',
                proseWrap: 'never',
            },
        },
    ],
};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM