禁止使用不必要的括号。
规则配置
// code-linter.json5
{
"rules": {
"@typescript-eslint/no-extra-parens": "error"
}
} 正例
// 默认不允许在任何表达式中使用不必要的括号
(0).toString();
const result = (() => {
console.info('arrow function');
}) ? '1' : '2';
(/^a$/).test(result); 反例
// 默认不允许在任何表达式中使用不必要的括号
const b = 10;
const c = 20;
export const a = (b * c);
export const d = (a * b) + c;
export const myType = typeof (a);