File tree Expand file tree Collapse file tree 3 files changed +12
-9
lines changed Expand file tree Collapse file tree 3 files changed +12
-9
lines changed Original file line number Diff line number Diff line change 5
5
},
6
6
"extends": [
7
7
"htmlacademy/vanilla"
8
- ]
8
+ ],
9
+ "rules": {
10
+ "camelcase": [2, {
11
+ "ignoreDestructuring": true
12
+ }]
13
+ }
9
14
}
Original file line number Diff line number Diff line change 5
5
"main" : " index.js" ,
6
6
"scripts" : {
7
7
"eslint" : " eslint rules/**/*.js" ,
8
- "lint" : " eslint"
8
+ "lint" : " npm run eslint"
9
9
},
10
10
"keywords" : [],
11
11
"author" : " " ,
Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
- // eslint-disable-next-line camelcase
3
- const dom_utils = require ( '@linthtml/dom-utils' ) ;
2
+ const { has_non_empty_attribute, is_tag_node, attribute_has_value } = require ( '@linthtml/dom-utils' ) ;
4
3
5
4
module . exports = {
6
5
name : 'htmlacademy/req-charset-utf' ,
7
6
// eslint-disable-next-line camelcase
8
7
lint ( node , rule_config , { report } ) {
9
- // eslint-disable-next-line camelcase
10
- if ( dom_utils . is_tag_node ( node ) && node . name === 'meta' ) {
11
- const hasUtf = node . attributes . some ( ( attribute ) => attribute . value . chars . toLowerCase ( ) === 'utf-8' ) ;
12
- const hasCharset = node . attributes . some ( ( attribute ) => attribute . name . chars === 'charset' ) ;
8
+ if ( is_tag_node ( node ) && node . name === 'meta' ) {
9
+ const hasCharset = has_non_empty_attribute ( node , 'charset' , true ) ;
10
+ const hasUtf = attribute_has_value ( node , 'charset' , / ^ u t f - 8 $ / i) ;
13
11
14
12
if ( hasCharset === true && hasUtf === false ) {
15
13
report ( {
16
14
position : node . loc ,
17
- message : '" The attribute charset="" should have a value of \' utf-8\'." ' ,
15
+ message : 'The attribute charset should have a value of " utf-8". ' ,
18
16
} ) ;
19
17
}
20
18
}
You can’t perform that action at this time.
0 commit comments