@@ -10,10 +10,12 @@ module ESLint {
10
10
*/
11
11
abstract class Configuration extends Locatable {
12
12
/** Gets the folder in which this configuration file is located. */
13
- private Folder getEnclosingFolder ( ) { result = getFile ( ) .getParentContainer ( ) }
13
+ private Folder getEnclosingFolder ( ) { result = this . getFile ( ) .getParentContainer ( ) }
14
14
15
15
/** Holds if this configuration file applies to the code in `tl`. */
16
- predicate appliesTo ( TopLevel tl ) { tl .getFile ( ) .getParentContainer + ( ) = getEnclosingFolder ( ) }
16
+ predicate appliesTo ( TopLevel tl ) {
17
+ tl .getFile ( ) .getParentContainer + ( ) = this .getEnclosingFolder ( )
18
+ }
17
19
18
20
/** Gets the `globals` configuration object of this file, if any. */
19
21
abstract ConfigurationObject getGlobals ( ) ;
@@ -39,19 +41,19 @@ module ESLint {
39
41
/** An `.eslintrc.json` file. */
40
42
private class EslintrcJson extends JsonConfiguration {
41
43
EslintrcJson ( ) {
42
- isTopLevel ( ) and
43
- exists ( string n | n = getFile ( ) .getBaseName ( ) | n = ".eslintrc.json" or n = ".eslintrc" )
44
+ this . isTopLevel ( ) and
45
+ exists ( string n | n = this . getFile ( ) .getBaseName ( ) | n = ".eslintrc.json" or n = ".eslintrc" )
44
46
}
45
47
46
- override ConfigurationObject getGlobals ( ) { result = getPropValue ( "globals" ) }
48
+ override ConfigurationObject getGlobals ( ) { result = this . getPropValue ( "globals" ) }
47
49
}
48
50
49
51
/** An ESLint configuration object in JSON format. */
50
52
private class JsonConfigurationObject extends ConfigurationObject , JsonObject {
51
53
override Configuration getConfiguration ( ) { this = result .( JsonConfiguration ) .getPropValue ( _) }
52
54
53
55
override boolean getBooleanProperty ( string p ) {
54
- exists ( string v | v = getPropValue ( p ) .( JsonBoolean ) .getValue ( ) |
56
+ exists ( string v | v = this . getPropValue ( p ) .( JsonBoolean ) .getValue ( ) |
55
57
v = "true" and result = true
56
58
or
57
59
v = "false" and result = false
@@ -62,7 +64,7 @@ module ESLint {
62
64
/** An `.eslintrc.yaml` file. */
63
65
private class EslintrcYaml extends Configuration instanceof YamlMapping , YamlDocument {
64
66
EslintrcYaml ( ) {
65
- exists ( string n | n = getFile ( ) .getBaseName ( ) |
67
+ exists ( string n | n = this . ( Locatable ) . getFile ( ) .getBaseName ( ) |
66
68
n = ".eslintrc.yaml" or n = ".eslintrc.yml" or n = ".eslintrc"
67
69
)
68
70
}
@@ -91,18 +93,20 @@ module ESLint {
91
93
exists ( PackageJson pkg | this = pkg .getPropValue ( "eslintConfig" ) )
92
94
}
93
95
94
- override ConfigurationObject getGlobals ( ) { result = getPropValue ( "globals" ) }
96
+ override ConfigurationObject getGlobals ( ) { result = this . getPropValue ( "globals" ) }
95
97
}
96
98
97
99
/** An ESLint `globals` configuration object. */
98
100
class GlobalsConfigurationObject extends Linting:: GlobalDeclaration , ConfigurationObject {
99
101
GlobalsConfigurationObject ( ) { this = any ( Configuration cfg ) .getGlobals ( ) }
100
102
101
103
override predicate declaresGlobal ( string name , boolean writable ) {
102
- getBooleanProperty ( name ) = writable
104
+ this . getBooleanProperty ( name ) = writable
103
105
}
104
106
105
- override predicate appliesTo ( ExprOrStmt s ) { getConfiguration ( ) .appliesTo ( s .getTopLevel ( ) ) }
107
+ override predicate appliesTo ( ExprOrStmt s ) {
108
+ this .getConfiguration ( ) .appliesTo ( s .getTopLevel ( ) )
109
+ }
106
110
107
111
abstract override Configuration getConfiguration ( ) ;
108
112
0 commit comments