@@ -6,9 +6,6 @@ import Promise from 'bluebird';
66import helpers from 'yeoman-test' ;
77import assert from 'yeoman-assert' ;
88import minimatch from 'minimatch' ;
9- import Checker from 'jscs' ;
10- const jscs = new Checker ( ) ;
11- jscs . registerDefaultRules ( ) ;
129import * as getExpectedFiles from './get-expected-files' ;
1310import {
1411 copyAsync ,
@@ -71,50 +68,28 @@ function runEndpointGen(name, opt={}) {
7168 } ) ;
7269}
7370
74- let jshintCmd = path . join ( TEST_DIR , '/fixtures/node_modules/.bin/jshint ' ) ;
71+ let eslintCmd = path . join ( TEST_DIR , '/fixtures/node_modules/.bin/eslint ' ) ;
7572function testFile ( command , _path ) {
7673 _path = path . normalize ( _path ) ;
7774 return fs . accessAsync ( _path , fs . R_OK ) . then ( ( ) => {
7875 return runCmd ( `${ command } ${ _path } ` ) ;
7976 } ) ;
8077}
8178
82- function jshintDir ( dir , name , folder ) {
79+ function eslintDir ( dir , name , folder ) {
8380 if ( ! folder ) folder = name ;
8481 let endpointDir = path . join ( dir , 'server/api' , folder ) ;
8582
8683 let regFiles = fs . readdirAsync ( endpointDir )
8784 . 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 ) ) ) ;
8986
9087 let specFiles = fs . readdirAsync ( endpointDir )
9188 . 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 ` , path . join ( './server/api/' , folder , file ) ) ) ;
9390
9491 return Promise . all ( [ regFiles , specFiles ] ) ;
9592}
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- }
11893
11994var config ;
12095var genDir ;
@@ -124,10 +99,6 @@ describe('angular-fullstack:endpoint', function() {
12499 return Promise . all ( [
125100 runGen ( defaultOptions ) . then ( _dir => {
126101 genDir = _dir ;
127-
128- return fs . readFileAsync ( path . join ( genDir , '.jscsrc' ) , 'utf8' ) . then ( data => {
129- jscs . configure ( JSON . parse ( data ) ) ;
130- } ) ;
131102 } ) ,
132103 readJSON ( path . join ( TEST_DIR , 'fixtures/.yo-rc.json' ) ) . then ( _config => {
133104 _config [ 'generator-angular-fullstack' ] . insertRoutes = false ;
@@ -146,9 +117,8 @@ describe('angular-fullstack:endpoint', function() {
146117 dir = _dir ;
147118
148119 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' )
152122 ] ) ;
153123 } ) ;
154124 } ) ;
@@ -157,12 +127,8 @@ describe('angular-fullstack:endpoint', function() {
157127 assert . file ( getExpectedFiles . endpoint ( 'foo' ) ) ;
158128 } ) ;
159129
160- it ( 'should pass jscs' , function ( ) {
161- return jscsDir ( dir , 'foo' ) . should . be . fulfilled ( ) ;
162- } ) ;
163-
164130 it ( 'should pass lint' , function ( ) {
165- return jshintDir ( dir , 'foo' ) . should . be . fulfilled ( ) ;
131+ return eslintDir ( dir , 'foo' ) . should . be . fulfilled ( ) ;
166132 } ) ;
167133 } ) ;
168134
@@ -173,9 +139,8 @@ describe('angular-fullstack:endpoint', function() {
173139 dir = _dir ;
174140
175141 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' )
179144 ] ) ;
180145 } ) ;
181146 } ) ;
@@ -184,12 +149,8 @@ describe('angular-fullstack:endpoint', function() {
184149 assert . file ( getExpectedFiles . endpoint ( 'Foo' ) ) ;
185150 } ) ;
186151
187- it ( 'should pass jscs' , function ( ) {
188- return jscsDir ( dir , 'Foo' ) . should . be . fulfilled ( ) ;
189- } ) ;
190-
191152 it ( 'should pass lint' , function ( ) {
192- return jshintDir ( dir , 'Foo' ) . should . be . fulfilled ( ) ;
153+ return eslintDir ( dir , 'Foo' ) . should . be . fulfilled ( ) ;
193154 } ) ;
194155 } ) ;
195156
@@ -200,9 +161,8 @@ describe('angular-fullstack:endpoint', function() {
200161 dir = _dir ;
201162
202163 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' )
206166 ] ) ;
207167 } ) ;
208168 } ) ;
@@ -211,12 +171,8 @@ describe('angular-fullstack:endpoint', function() {
211171 assert . file ( getExpectedFiles . endpoint ( 'bar' , 'foo/bar' ) ) ;
212172 } ) ;
213173
214- it ( 'should pass jscs' , function ( ) {
215- return jscsDir ( dir , 'foo' , 'foo/bar' ) . should . be . fulfilled ( ) ;
216- } ) ;
217-
218174 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 ( ) ;
220176 } ) ;
221177 } ) ;
222178
@@ -227,9 +183,8 @@ describe('angular-fullstack:endpoint', function() {
227183 dir = _dir ;
228184
229185 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' )
233188 ] ) ;
234189 } ) ;
235190 } ) ;
@@ -238,12 +193,8 @@ describe('angular-fullstack:endpoint', function() {
238193 assert . file ( getExpectedFiles . endpoint ( 'foo-bar' ) ) ;
239194 } ) ;
240195
241- it ( 'should pass jscs' , function ( ) {
242- return jscsDir ( dir , 'foo-bar' ) . should . be . fulfilled ( ) ;
243- } ) ;
244-
245196 it ( 'should pass lint' , function ( ) {
246- return jshintDir ( dir , 'foo-bar' ) . should . be . fulfilled ( ) ;
197+ return eslintDir ( dir , 'foo-bar' ) . should . be . fulfilled ( ) ;
247198 } ) ;
248199 } ) ;
249200} ) ;
0 commit comments