eslint-plugin-no-braces-for-one-line
v1.0.0
Published
Downloads
1
Readme
no-braces-for-one-line
install
npm install eslint-plugin-no-braces-for-one-line --save-dev
use
module.exports = {
plugins: ['no-braces-for-one-line'],
rules: {
// 添加您的自定义规则
'no-braces-for-one-line/if-statement': 'error',
'no-braces-for-one-line/for-statement': 'error',
'no-braces-for-one-line/while-statement': 'error',
'no-braces-for-one-line/do-while-statement': 'error',
}
};
no-braces-for-one-line/if-statement
// bad ❌
if (true) {
console.log('true');
}
// good ✅
if (true) console.log('true');
no-braces-for-one-line/for-statement
// bad ❌
for(;;) {
console.log('true');
}
// good ✅
for(;;) console.log('true');
no-braces-for-one-line/while-statement
// bad ❌
while (true) {
console.log('true');
}
// good ✅
while (true) console.log('true');
no-braces-for-one-line/do-while-statement
// bad ❌
do {
console.log('true');
} while(true);
// good ✅
do console.log('true');
while(true);