@@ -4,6 +4,8 @@ import { join } from 'path';
4
4
// eslint-disable-next-line import/no-extraneous-dependencies, import/no-unresolved
5
5
import { remove } from 'fs-extra' ;
6
6
7
+ const { lint } = require ( '../lib/init.js' ) . provideLinter ( ) ;
8
+
7
9
const validPathElixirc = join ( __dirname , 'fixtures' , 'elixirc' , 'valid.ex' ) ;
8
10
const warningPathElixirc = join ( __dirname , 'fixtures' , 'elixirc' , 'warning.ex' ) ;
9
11
const errorMode1PathElixirc = join ( __dirname , 'fixtures' , 'elixirc' , 'error-mode1.ex' ) ;
@@ -19,18 +21,14 @@ remove(mixBuildDirectory);
19
21
describe ( 'The elixirc provider for Linter' , ( ) => {
20
22
describe ( 'when not working inside a Mix project' , ( ) => {
21
23
describe ( 'and using the standard configuration' , ( ) => {
22
- let lint ;
23
-
24
24
beforeEach ( ( ) => {
25
- lint = require ( '../lib/init.js' ) . provideLinter ( ) . lint ;
26
25
atom . workspace . destroyActivePaneItem ( ) ;
27
26
28
27
waitsForPromise ( ( ) =>
29
28
Promise . all ( [
30
29
atom . packages . activatePackage ( 'linter-elixirc' ) ,
31
30
atom . packages . activatePackage ( 'language-elixir' ) ,
32
- ] ) ,
33
- ) ;
31
+ ] ) ) ;
34
32
} ) ;
35
33
36
34
it ( 'works with mode 1 errors' , ( ) => {
@@ -43,8 +41,7 @@ describe('The elixirc provider for Linter', () => {
43
41
expect ( messages [ 0 ] . excerpt ) . toBe ( '(ArgumentError) Dangerous is not available' ) ;
44
42
expect ( messages [ 0 ] . location . file ) . toBe ( errorMode1PathElixirc ) ;
45
43
expect ( messages [ 0 ] . location . position ) . toEqual ( [ [ 1 , 0 ] , [ 1 , 32 ] ] ) ;
46
- } ) ,
47
- ) ;
44
+ } ) ) ;
48
45
} ) ;
49
46
50
47
it ( 'works with mode 2 errors' , ( ) => {
@@ -57,8 +54,7 @@ describe('The elixirc provider for Linter', () => {
57
54
expect ( messages [ 0 ] . excerpt ) . toBe ( '(CompileError) module Usefulness is not loaded and could not be found' ) ;
58
55
expect ( messages [ 0 ] . location . file ) . toBe ( errorMode2PathElixirc ) ;
59
56
expect ( messages [ 0 ] . location . position ) . toEqual ( [ [ 3 , 2 ] , [ 3 , 20 ] ] ) ;
60
- } ) ,
61
- ) ;
57
+ } ) ) ;
62
58
} ) ;
63
59
64
60
it ( 'works with warnings' , ( ) => {
@@ -70,8 +66,7 @@ describe('The elixirc provider for Linter', () => {
70
66
expect ( messages [ 0 ] . excerpt ) . toBe ( 'variable "prepare_for_call" does not exist and is being expanded to "prepare_for_call()", please use parentheses to remove the ambiguity or change the variable name' ) ;
71
67
expect ( messages [ 0 ] . location . file ) . toBe ( warningPathElixirc ) ;
72
68
expect ( messages [ 0 ] . location . position ) . toEqual ( [ [ 20 , 4 ] , [ 20 , 20 ] ] ) ;
73
- } ) ,
74
- ) ;
69
+ } ) ) ;
75
70
} ) ;
76
71
77
72
it ( 'works with .exs files' , ( ) => {
@@ -83,34 +78,28 @@ describe('The elixirc provider for Linter', () => {
83
78
expect ( messages [ 0 ] . excerpt ) . toBe ( 'function simple_function/0 is unused' ) ;
84
79
expect ( messages [ 0 ] . location . file ) . toBe ( exsFilePathElixirc ) ;
85
80
expect ( messages [ 0 ] . location . position ) . toEqual ( [ [ 1 , 2 ] , [ 1 , 25 ] ] ) ;
86
- } ) ,
87
- ) ;
81
+ } ) ) ;
88
82
} ) ;
89
83
90
84
it ( 'finds nothing wrong with a valid file' , ( ) => {
91
85
waitsForPromise ( ( ) =>
92
86
atom . workspace . open ( validPathElixirc ) . then ( editor => lint ( editor ) ) . then ( ( messages ) => {
93
87
expect ( messages . length ) . toBe ( 0 ) ;
94
- } ) ,
95
- ) ;
88
+ } ) ) ;
96
89
} ) ;
97
90
} ) ;
98
91
} ) ;
99
92
100
93
describe ( 'when working inside a Mix project' , ( ) => {
101
94
describe ( 'and using the standard configuration' , ( ) => {
102
- let lint ;
103
-
104
95
beforeEach ( ( ) => {
105
- lint = require ( '../lib/init.js' ) . provideLinter ( ) . lint ;
106
96
atom . workspace . destroyActivePaneItem ( ) ;
107
97
108
98
waitsForPromise ( ( ) =>
109
99
Promise . all ( [
110
100
atom . packages . activatePackage ( 'linter-elixirc' ) ,
111
101
atom . packages . activatePackage ( 'language-elixir' ) ,
112
- ] ) ,
113
- ) ;
102
+ ] ) ) ;
114
103
} ) ;
115
104
116
105
it ( 'works with mode 2 errors' , ( ) => {
@@ -123,8 +112,7 @@ describe('The elixirc provider for Linter', () => {
123
112
expect ( messages [ 0 ] . excerpt ) . toBe ( '(CompileError) Identicon.Image.__struct__/1 is undefined, cannot expand struct Identicon.Image' ) ;
124
113
expect ( messages [ 0 ] . location . file ) . toBe ( errorMode2PathMix ) ;
125
114
expect ( messages [ 0 ] . location . position ) . toEqual ( [ [ 11 , 4 ] , [ 11 , 30 ] ] ) ;
126
- } ) ,
127
- ) ;
115
+ } ) ) ;
128
116
} ) ;
129
117
130
118
it ( 'works with .exs files' , ( ) => {
@@ -136,27 +124,22 @@ describe('The elixirc provider for Linter', () => {
136
124
expect ( messages [ 0 ] . excerpt ) . toBe ( 'function simple_function/0 is unused' ) ;
137
125
expect ( messages [ 0 ] . location . file ) . toBe ( exsFilePathMix ) ;
138
126
expect ( messages [ 0 ] . location . position ) . toEqual ( [ [ 1 , 2 ] , [ 1 , 25 ] ] ) ;
139
- } ) ,
140
- ) ;
127
+ } ) ) ;
141
128
} ) ;
142
129
} ) ;
143
130
} ) ;
144
131
} ) ;
145
132
146
133
describe ( 'when using the setting forceElixirc' , ( ) => {
147
- let lint ;
148
-
149
134
beforeEach ( ( ) => {
150
135
atom . config . set ( 'linter-elixirc.forceElixirc' , true ) ;
151
- lint = require ( '../lib/init.js' ) . provideLinter ( ) . lint ;
152
136
atom . workspace . destroyActivePaneItem ( ) ;
153
137
154
138
waitsForPromise ( ( ) =>
155
139
Promise . all ( [
156
140
atom . packages . activatePackage ( 'linter-elixirc' ) ,
157
141
atom . packages . activatePackage ( 'language-elixir' ) ,
158
- ] ) ,
159
- ) ;
142
+ ] ) ) ;
160
143
} ) ;
161
144
162
145
it ( 'works with warnings' , ( ) => {
@@ -168,7 +151,6 @@ describe('when using the setting forceElixirc', () => {
168
151
expect ( messages [ 0 ] . excerpt ) . toBe ( '(CompileError) Identicon.Image.__struct__/1 is undefined, cannot expand struct Identicon.Image' ) ;
169
152
expect ( messages [ 0 ] . location . file ) . toBe ( errorMode2PathMix ) ;
170
153
expect ( messages [ 0 ] . location . position ) . toEqual ( [ [ 11 , 4 ] , [ 11 , 30 ] ] ) ;
171
- } ) ,
172
- ) ;
154
+ } ) ) ;
173
155
} ) ;
174
156
} ) ;
0 commit comments