I am trying to set up naming conventions for my project.
I have some variables in snake_case
that I would like ESLint to warn me about such as:
const { order_id } = req.params;
I removed typescript-eslint/camelcase
as it is deprecated and trying to set up naming-convention
and added a new error
rule for boolean.
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'variable',
types: ['boolean'],
format: ['PascalCase'],
prefix: ['is', 'should', 'has', 'can', 'did', 'will'],
},
],
How can I add a warning for snake_case
variables?
I tried to get a similar setup working with mixing warn
and error
level configurations (eg an error-level rule that class names are PascalCased and a warn-level rule that variable names are camelCase). I tried writing two rules in the eslint file, one at warn
and one at error
, but found that the second rule in the eslint file was the only one that was respected, whichever it was.
I ended up setting everything to warn
, which was not my ideal solution but is better than nothing.
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.