@@ -14,51 +14,31 @@ const importExportSourceSelector = [
1414 'Literal.source' ,
1515] . join ( '' ) ;
1616
17- /** @param {import('eslint').Rule.RuleContext } context */
18- const create = context => {
19- const { checkRequire} = {
20- checkRequire : false ,
21- ...context . options [ 0 ] ,
22- } ;
23- const selectors = [ importExportSourceSelector ] ;
24- if ( checkRequire ) {
25- selectors . push ( STATIC_REQUIRE_SOURCE_SELECTOR ) ;
26- }
17+ const selector = matches ( [
18+ importExportSourceSelector ,
19+ STATIC_REQUIRE_SOURCE_SELECTOR ,
20+ ] ) ;
2721
28- return {
29- [ matches ( selectors ) ] ( node ) {
30- const { value} = node ;
31- if (
32- typeof value !== 'string'
33- || value . startsWith ( 'node:' )
34- || ! isBuiltinModule ( value )
35- ) {
36- return ;
37- }
22+ const create = ( ) => ( {
23+ [ selector ] ( node ) {
24+ const { value} = node ;
25+ if (
26+ typeof value !== 'string'
27+ || value . startsWith ( 'node:' )
28+ || ! isBuiltinModule ( value )
29+ ) {
30+ return ;
31+ }
3832
39- return {
40- node,
41- messageId : MESSAGE_ID ,
42- data : { moduleName : value } ,
43- /** @param {import('eslint').Rule.RuleFixer } fixer */
44- fix : fixer => replaceStringLiteral ( fixer , node , 'node:' , 0 , 0 ) ,
45- } ;
46- } ,
47- } ;
48- } ;
49-
50- const schema = [
51- {
52- type : 'object' ,
53- additionalProperties : false ,
54- properties : {
55- checkRequire : {
56- type : 'boolean' ,
57- default : false ,
58- } ,
59- } ,
33+ return {
34+ node,
35+ messageId : MESSAGE_ID ,
36+ data : { moduleName : value } ,
37+ /** @param {import('eslint').Rule.RuleFixer } fixer */
38+ fix : fixer => replaceStringLiteral ( fixer , node , 'node:' , 0 , 0 ) ,
39+ } ;
6040 } ,
61- ] ;
41+ } ) ;
6242
6343/** @type {import('eslint').Rule.RuleModule } */
6444module . exports = {
@@ -69,7 +49,6 @@ module.exports = {
6949 description : 'Prefer using the `node:` protocol when importing Node.js builtin modules.' ,
7050 } ,
7151 fixable : 'code' ,
72- schema,
7352 messages,
7453 } ,
7554} ;
0 commit comments