File tree Expand file tree Collapse file tree 1 file changed +24
-21
lines changed Expand file tree Collapse file tree 1 file changed +24
-21
lines changed Original file line number Diff line number Diff line change 11'use strict' ;
22
3- module . exports = function ( context ) {
4- return {
5- VariableDeclaration : function ( node ) {
6- if ( node . kind !== 'const' ) {
7- return ;
8- }
3+ module . exports = {
4+ meta : { fixable : 'code' , schema : [ ] } ,
5+ create ( context ) {
6+ return {
7+ VariableDeclaration : function ( node ) {
8+ if ( node . kind !== 'const' ) {
9+ return ;
10+ }
911
10- if ( node . parent && node . parent . type === 'Program' ) {
11- // Declaration is in root of module.
12- return ;
13- }
12+ if ( node . parent && node . parent . type === 'Program' ) {
13+ // Declaration is in root of module.
14+ return ;
15+ }
1416
15- if ( node . parent && node . parent . type === 'ExportNamedDeclaration' &&
16- node . parent . parent && node . parent . parent . type === 'Program' ) {
17- // Declaration is a `export const foo = 'asdf'` in root of the module.
18- return ;
19- }
17+ if ( node . parent && node . parent . type === 'ExportNamedDeclaration' &&
18+ node . parent . parent && node . parent . parent . type === 'Program' ) {
19+ // Declaration is a `export const foo = 'asdf'` in root of the module.
20+ return ;
21+ }
2022
21- context . report ( {
22- node : node ,
23- message : '`const` should only be used in module scope (not inside functions/blocks).'
24- } ) ;
25- }
26- } ;
23+ context . report ( {
24+ node : node ,
25+ message : '`const` should only be used in module scope (not inside functions/blocks).'
26+ } ) ;
27+ }
28+ } ;
29+ }
2730} ;
2831
2932module . exports . schema = [ ] ; // no options
You can’t perform that action at this time.
0 commit comments