@@ -15,28 +15,28 @@ function isUpperSnakeCase(text) {
1515}
1616
1717class Base {
18- constructor ( reporter , config , source , fileName ) {
19- this . ignoreDeprecated = true ;
20- this . deprecatedPrefix = '__DEPRECATED_' ;
21- this . underscorePrefix = '__' ;
22- this . reporter = reporter ;
23- this . ignored = this . constructor . global ;
24- this . ruleId = this . constructor . ruleId ;
18+ constructor ( reporter , _config , _source , _fileName ) {
19+ this . ignoreDeprecated = true
20+ this . deprecatedPrefix = '__DEPRECATED_'
21+ this . underscorePrefix = '__'
22+ this . reporter = reporter
23+ this . ignored = this . constructor . global
24+ this . ruleId = this . constructor . ruleId
2525 if ( this . ruleId === undefined ) {
26- throw Error ( 'missing ruleId static property' ) ;
26+ throw Error ( 'missing ruleId static property' )
2727 }
2828 }
2929
3030 error ( node , message , fix ) {
3131 if ( ! this . ignored ) {
32- this . reporter . error ( node , this . ruleId , message , fix ) ;
32+ this . reporter . error ( node , this . ruleId , message , fix )
3333 }
3434 }
3535}
3636
3737module . exports = [
3838 class extends Base {
39- static ruleId = 'leading-underscore' ;
39+ static ruleId = 'leading-underscore'
4040
4141 ContractDefinition ( node ) {
4242 if ( node . kind === 'library' ) {
@@ -65,7 +65,6 @@ module.exports = [
6565
6666 this . validateName ( node , 'variable' )
6767 }
68-
6968 }
7069
7170 FunctionDefinition ( node ) {
@@ -78,7 +77,6 @@ module.exports = [
7877 }
7978
8079 this . validateName ( node , 'function' )
81-
8280 }
8381 }
8482
@@ -104,7 +102,7 @@ module.exports = [
104102
105103 fixStatement ( node , shouldHaveLeadingUnderscore , type ) {
106104 let range
107-
105+
108106 if ( type === 'function' ) {
109107 range = node . range
110108 range [ 0 ] += 8
@@ -114,42 +112,42 @@ module.exports = [
114112 range = node . identifier . range
115113 range [ 0 ] -= 1
116114 }
117-
115+
118116 return ( fixer ) =>
119117 shouldHaveLeadingUnderscore
120118 ? fixer . insertTextBeforeRange ( range , ' _' )
121119 : fixer . removeRange ( [ range [ 0 ] + 1 , range [ 0 ] + 1 ] )
122120 }
123121
124- _error ( node , name , shouldHaveLeadingUnderscore , type ) {
122+ _error ( node , name , shouldHaveLeadingUnderscore , _type ) {
125123 this . error (
126124 node ,
127- `'${ name } ' ${ shouldHaveLeadingUnderscore ? 'should' : 'should not' } start with _` ,
125+ `'${ name } ' ${ shouldHaveLeadingUnderscore ? 'should' : 'should not' } start with _` ,
128126 // this.fixStatement(node, shouldHaveLeadingUnderscore, type)
129127 )
130128 }
131129 } ,
132130 class extends Base {
133- static ruleId = 'func-name-mixedcase' ;
131+ static ruleId = 'func-name-mixedcase'
134132
135133 FunctionDefinition ( node ) {
136134 // Allow __DEPRECATED_ prefixed functions and __ prefixed functions
137135 if ( node . name . startsWith ( this . deprecatedPrefix ) || node . name . startsWith ( this . underscorePrefix ) ) {
138136 return
139137 }
140138
141- if ( ! isMixedCase ( node . name ) && ! node . isConstructor ) {
139+ if ( ! isMixedCase ( node . name ) && ! node . isConstructor ) {
142140 // Allow external functions to be in UPPER_SNAKE_CASE - for immutable state getters
143141 if ( node . visibility === 'external' && isUpperSnakeCase ( node . name ) ) {
144142 return
145143 }
146- this . error ( node , 'Function name must be in mixedCase' , )
144+ this . error ( node , 'Function name must be in mixedCase' )
147145 }
148146 }
149147 } ,
150148 class extends Base {
151- static ruleId = 'var-name-mixedcase' ;
152-
149+ static ruleId = 'var-name-mixedcase'
150+
153151 VariableDeclaration ( node ) {
154152 if ( node . name . startsWith ( this . deprecatedPrefix ) ) {
155153 return
@@ -158,7 +156,7 @@ module.exports = [
158156 this . validateVariablesName ( node )
159157 }
160158 }
161-
159+
162160 validateVariablesName ( node ) {
163161 if ( node . name . startsWith ( this . deprecatedPrefix ) ) {
164162 return
@@ -167,6 +165,5 @@ module.exports = [
167165 this . error ( node , 'Variable name must be in mixedCase' )
168166 }
169167 }
170- }
171-
172- ] ;
168+ } ,
169+ ]
0 commit comments