File tree Expand file tree Collapse file tree 1 file changed +5
-7
lines changed Expand file tree Collapse file tree 1 file changed +5
-7
lines changed 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