@@ -6,9 +6,6 @@ import Promise from 'bluebird';
6
6
import helpers from 'yeoman-test' ;
7
7
import assert from 'yeoman-assert' ;
8
8
import minimatch from 'minimatch' ;
9
- import Checker from 'jscs' ;
10
- const jscs = new Checker ( ) ;
11
- jscs . registerDefaultRules ( ) ;
12
9
import * as getExpectedFiles from './get-expected-files' ;
13
10
import {
14
11
copyAsync ,
@@ -71,50 +68,28 @@ function runEndpointGen(name, opt={}) {
71
68
} ) ;
72
69
}
73
70
74
- let jshintCmd = path . join ( TEST_DIR , '/fixtures/node_modules/.bin/jshint ' ) ;
71
+ let eslintCmd = path . join ( TEST_DIR , '/fixtures/node_modules/.bin/eslint ' ) ;
75
72
function testFile ( command , _path ) {
76
73
_path = path . normalize ( _path ) ;
77
74
return fs . accessAsync ( _path , fs . R_OK ) . then ( ( ) => {
78
75
return runCmd ( `${ command } ${ _path } ` ) ;
79
76
} ) ;
80
77
}
81
78
82
- function jshintDir ( dir , name , folder ) {
79
+ function eslintDir ( dir , name , folder ) {
83
80
if ( ! folder ) folder = name ;
84
81
let endpointDir = path . join ( dir , 'server/api' , folder ) ;
85
82
86
83
let regFiles = fs . readdirAsync ( endpointDir )
87
84
. then ( files => files . filter ( file => minimatch ( file , '**/!(*.spec|*.mock|*.integration).js' , { dot : true } ) ) )
88
- . map ( file => testFile ( jshintCmd , path . join ( './server/api/' , folder , file ) ) ) ;
85
+ . map ( file => testFile ( eslintCmd , path . join ( './server/api/' , folder , file ) ) ) ;
89
86
90
87
let specFiles = fs . readdirAsync ( endpointDir )
91
88
. then ( files => files . filter ( file => minimatch ( file , '**/+(*.spec|*.mock|*.integration).js' , { dot : true } ) ) )
92
- . map ( file => testFile ( `${ jshintCmd } --config server/.jshintrc-spec ` , path . join ( './server/api/' , folder , file ) ) ) ;
89
+ . map ( file => testFile ( `${ eslintCmd } --env node,es6,mocha --global sinon,expect ` , path . join ( './server/api/' , folder , file ) ) ) ;
93
90
94
91
return Promise . all ( [ regFiles , specFiles ] ) ;
95
92
}
96
- function jscsDir ( dir , name , folder ) {
97
- if ( ! folder ) folder = name ;
98
- let endpointDir = path . join ( dir , 'server/api' , folder ) ;
99
-
100
- return fs . readdirAsync ( endpointDir ) . then ( files => {
101
- return Promise . map ( files , file => {
102
- return fs . readFileAsync ( path . join ( 'server/api' , folder , file ) , 'utf8' ) . then ( data => {
103
- let results = jscs . checkString ( data )
104
- let errors = results . getErrorList ( ) ;
105
- if ( errors . length === 0 ) {
106
- return Promise . resolve ( ) ;
107
- } else {
108
- errors . forEach ( error => {
109
- var colorizeOutput = true ;
110
- console . log ( results . explainError ( error , colorizeOutput ) + '\n' ) ;
111
- } ) ;
112
- return Promise . reject ( ) ;
113
- }
114
- } ) ;
115
- } ) ;
116
- } ) ;
117
- }
118
93
119
94
var config ;
120
95
var genDir ;
@@ -124,10 +99,6 @@ describe('angular-fullstack:endpoint', function() {
124
99
return Promise . all ( [
125
100
runGen ( defaultOptions ) . then ( _dir => {
126
101
genDir = _dir ;
127
-
128
- return fs . readFileAsync ( path . join ( genDir , '.jscsrc' ) , 'utf8' ) . then ( data => {
129
- jscs . configure ( JSON . parse ( data ) ) ;
130
- } ) ;
131
102
} ) ,
132
103
readJSON ( path . join ( TEST_DIR , 'fixtures/.yo-rc.json' ) ) . then ( _config => {
133
104
_config [ 'generator-angular-fullstack' ] . insertRoutes = false ;
@@ -146,9 +117,8 @@ describe('angular-fullstack:endpoint', function() {
146
117
dir = _dir ;
147
118
148
119
return Promise . all ( [
149
- copyAsync ( path . join ( genDir , '/server/.jshintrc' ) , './server/.jshintrc' ) ,
150
- copyAsync ( path . join ( genDir , '/server/.jshintrc-spec' ) , './server/.jshintrc-spec' ) ,
151
- copyAsync ( path . join ( genDir , '/.jscsrc' ) , './.jscsrc' )
120
+ copyAsync ( path . join ( genDir , '/.eslintrc' ) , './.eslintrc' ) ,
121
+ copyAsync ( path . join ( genDir , '/server/.eslintrc' ) , './server/.eslintrc' )
152
122
] ) ;
153
123
} ) ;
154
124
} ) ;
@@ -157,12 +127,8 @@ describe('angular-fullstack:endpoint', function() {
157
127
assert . file ( getExpectedFiles . endpoint ( 'foo' ) ) ;
158
128
} ) ;
159
129
160
- it ( 'should pass jscs' , function ( ) {
161
- return jscsDir ( dir , 'foo' ) . should . be . fulfilled ( ) ;
162
- } ) ;
163
-
164
130
it ( 'should pass lint' , function ( ) {
165
- return jshintDir ( dir , 'foo' ) . should . be . fulfilled ( ) ;
131
+ return eslintDir ( dir , 'foo' ) . should . be . fulfilled ( ) ;
166
132
} ) ;
167
133
} ) ;
168
134
@@ -173,9 +139,8 @@ describe('angular-fullstack:endpoint', function() {
173
139
dir = _dir ;
174
140
175
141
return Promise . all ( [
176
- copyAsync ( path . join ( genDir , '/server/.jshintrc' ) , './server/.jshintrc' ) ,
177
- copyAsync ( path . join ( genDir , '/server/.jshintrc-spec' ) , './server/.jshintrc-spec' ) ,
178
- copyAsync ( path . join ( genDir , '/.jscsrc' ) , './.jscsrc' )
142
+ copyAsync ( path . join ( genDir , '/.eslintrc' ) , './.eslintrc' ) ,
143
+ copyAsync ( path . join ( genDir , '/server/.eslintrc' ) , './server/.eslintrc' )
179
144
] ) ;
180
145
} ) ;
181
146
} ) ;
@@ -184,12 +149,8 @@ describe('angular-fullstack:endpoint', function() {
184
149
assert . file ( getExpectedFiles . endpoint ( 'Foo' ) ) ;
185
150
} ) ;
186
151
187
- it ( 'should pass jscs' , function ( ) {
188
- return jscsDir ( dir , 'Foo' ) . should . be . fulfilled ( ) ;
189
- } ) ;
190
-
191
152
it ( 'should pass lint' , function ( ) {
192
- return jshintDir ( dir , 'Foo' ) . should . be . fulfilled ( ) ;
153
+ return eslintDir ( dir , 'Foo' ) . should . be . fulfilled ( ) ;
193
154
} ) ;
194
155
} ) ;
195
156
@@ -200,9 +161,8 @@ describe('angular-fullstack:endpoint', function() {
200
161
dir = _dir ;
201
162
202
163
return Promise . all ( [
203
- copyAsync ( path . join ( genDir , '/server/.jshintrc' ) , './server/.jshintrc' ) ,
204
- copyAsync ( path . join ( genDir , '/server/.jshintrc-spec' ) , './server/.jshintrc-spec' ) ,
205
- copyAsync ( path . join ( genDir , '/.jscsrc' ) , './.jscsrc' )
164
+ copyAsync ( path . join ( genDir , '/.eslintrc' ) , './.eslintrc' ) ,
165
+ copyAsync ( path . join ( genDir , '/server/.eslintrc' ) , './server/.eslintrc' )
206
166
] ) ;
207
167
} ) ;
208
168
} ) ;
@@ -211,12 +171,8 @@ describe('angular-fullstack:endpoint', function() {
211
171
assert . file ( getExpectedFiles . endpoint ( 'bar' , 'foo/bar' ) ) ;
212
172
} ) ;
213
173
214
- it ( 'should pass jscs' , function ( ) {
215
- return jscsDir ( dir , 'foo' , 'foo/bar' ) . should . be . fulfilled ( ) ;
216
- } ) ;
217
-
218
174
it ( 'should pass lint' , function ( ) {
219
- return jshintDir ( dir , 'foo' , 'foo/bar' ) . should . be . fulfilled ( ) ;
175
+ return eslintDir ( dir , 'foo' , 'foo/bar' ) . should . be . fulfilled ( ) ;
220
176
} ) ;
221
177
} ) ;
222
178
@@ -227,9 +183,8 @@ describe('angular-fullstack:endpoint', function() {
227
183
dir = _dir ;
228
184
229
185
return Promise . all ( [
230
- copyAsync ( path . join ( genDir , '/server/.jshintrc' ) , './server/.jshintrc' ) ,
231
- copyAsync ( path . join ( genDir , '/server/.jshintrc-spec' ) , './server/.jshintrc-spec' ) ,
232
- copyAsync ( path . join ( genDir , '/.jscsrc' ) , './.jscsrc' )
186
+ copyAsync ( path . join ( genDir , '/.eslintrc' ) , './.eslintrc' ) ,
187
+ copyAsync ( path . join ( genDir , '/server/.eslintrc' ) , './server/.eslintrc' )
233
188
] ) ;
234
189
} ) ;
235
190
} ) ;
@@ -238,12 +193,8 @@ describe('angular-fullstack:endpoint', function() {
238
193
assert . file ( getExpectedFiles . endpoint ( 'foo-bar' ) ) ;
239
194
} ) ;
240
195
241
- it ( 'should pass jscs' , function ( ) {
242
- return jscsDir ( dir , 'foo-bar' ) . should . be . fulfilled ( ) ;
243
- } ) ;
244
-
245
196
it ( 'should pass lint' , function ( ) {
246
- return jshintDir ( dir , 'foo-bar' ) . should . be . fulfilled ( ) ;
197
+ return eslintDir ( dir , 'foo-bar' ) . should . be . fulfilled ( ) ;
247
198
} ) ;
248
199
} ) ;
249
200
} ) ;
0 commit comments