File tree 2 files changed +28
-2
lines changed
eslint-config-airbnb-base 2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,18 @@ const { CLIEngine } = require('eslint');
4
4
5
5
const baseConfig = require ( '.' ) ;
6
6
7
+ const severities = [ 'off' , 'warn' , 'error' ] ;
8
+
9
+ function getSeverity ( ruleConfig ) {
10
+ if ( Array . isArray ( ruleConfig ) ) {
11
+ return getSeverity ( ruleConfig [ 0 ] ) ;
12
+ }
13
+ if ( typeof ruleConfig === 'number' ) {
14
+ return severities [ ruleConfig ] ;
15
+ }
16
+ return ruleConfig ;
17
+ }
18
+
7
19
function onlyErrorOnRules ( rulesToError , config ) {
8
20
const errorsOnly = assign ( { } , config ) ;
9
21
const cli = new CLIEngine ( { baseConfig : config , useEslintrc : false } ) ;
@@ -12,8 +24,9 @@ function onlyErrorOnRules(rulesToError, config) {
12
24
entries ( baseRules ) . forEach ( ( rule ) => {
13
25
const ruleName = rule [ 0 ] ;
14
26
const ruleConfig = rule [ 1 ] ;
27
+ const severity = getSeverity ( ruleConfig ) ;
15
28
16
- if ( rulesToError . indexOf ( ruleName ) === - 1 ) {
29
+ if ( rulesToError . indexOf ( ruleName ) === - 1 && severity === 'error' ) {
17
30
if ( Array . isArray ( ruleConfig ) ) {
18
31
errorsOnly . rules [ ruleName ] = [ 'warn' ] . concat ( ruleConfig . slice ( 1 ) ) ;
19
32
} else if ( typeof ruleConfig === 'number' ) {
Original file line number Diff line number Diff line change @@ -4,6 +4,18 @@ const { CLIEngine } = require('eslint');
4
4
5
5
const baseConfig = require ( '.' ) ;
6
6
7
+ const severities = [ 'off' , 'warn' , 'error' ] ;
8
+
9
+ function getSeverity ( ruleConfig ) {
10
+ if ( Array . isArray ( ruleConfig ) ) {
11
+ return getSeverity ( ruleConfig [ 0 ] ) ;
12
+ }
13
+ if ( typeof ruleConfig === 'number' ) {
14
+ return severities [ ruleConfig ] ;
15
+ }
16
+ return ruleConfig ;
17
+ }
18
+
7
19
function onlyErrorOnRules ( rulesToError , config ) {
8
20
const errorsOnly = assign ( { } , config ) ;
9
21
const cli = new CLIEngine ( { baseConfig : config , useEslintrc : false } ) ;
@@ -12,8 +24,9 @@ function onlyErrorOnRules(rulesToError, config) {
12
24
entries ( baseRules ) . forEach ( ( rule ) => {
13
25
const ruleName = rule [ 0 ] ;
14
26
const ruleConfig = rule [ 1 ] ;
27
+ const severity = getSeverity ( ruleConfig ) ;
15
28
16
- if ( rulesToError . indexOf ( ruleName ) === - 1 ) {
29
+ if ( rulesToError . indexOf ( ruleName ) === - 1 && severity === 'error' ) {
17
30
if ( Array . isArray ( ruleConfig ) ) {
18
31
errorsOnly . rules [ ruleName ] = [ 'warn' ] . concat ( ruleConfig . slice ( 1 ) ) ;
19
32
} else if ( typeof ruleConfig === 'number' ) {
You can’t perform that action at this time.
0 commit comments