简体   繁体   中英

how to set eslint rules globally?

I am new in Eslint, and I was trying to set theses rules globally, so i don't have to write them in all projects everytimes. So, in my .eslintrc.json file i wrote:

"rules": {
    
    "no-unused-vars":"warn",
    "prefer-const":"warn",
    "quotes":"off",
    "space-before-blocks":"warn",
    "space-in-parens":"warn",
    "space-before-function-paren":"warn"
    
}

How can I achieve that?

From the manual :

The first way to use configuration files is via .eslintrc.* and package.json files. ESLint will automatically look for them in the directory of the file to be linted, and in successive parent directories all the way up to the root directory of the filesystem (/), the home directory of the current user (~/), or when root: true is specified.

So just put the file in your home directory.

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