@@ -27,17 +27,20 @@ define(function (require, exports, module) {
2727 var SpecRunnerUtils = require ( "spec/SpecRunnerUtils" ) ;
2828
2929 describe ( "integration:ESLint" , function ( ) {
30- let testProjectsFolder = SpecRunnerUtils . getTestPath ( "/spec/ESLintExtensionTest-files/" ) ,
30+ const testRootSpec = "/spec/ESLintExtensionTest-files/" ;
31+ let testProjectsFolder = SpecRunnerUtils . getTestPath ( testRootSpec ) ,
3132 Strings = require ( "strings" ) ,
3233 testWindow ,
3334 $ ,
34- CodeInspection ;
35+ CodeInspection ,
36+ NodeUtils ;
3537
3638 beforeAll ( async function ( ) {
3739 testWindow = await SpecRunnerUtils . createTestWindowAndRun ( ) ;
3840 // Load module instances from brackets.test
3941 $ = testWindow . $ ;
4042 CodeInspection = testWindow . brackets . test . CodeInspection ;
43+ NodeUtils = testWindow . brackets . test . NodeUtils ;
4144 CodeInspection . toggleEnabled ( true ) ;
4245 await awaitsFor ( ( ) => testWindow . _JsHintExtensionReadyToIntegTest ,
4346 "JsHint extension to be loaded" , 10000 ) ;
@@ -46,15 +49,27 @@ define(function (require, exports, module) {
4649 afterAll ( async function ( ) {
4750 testWindow = null ;
4851 $ = null ;
52+ NodeUtils = null ;
53+ CodeInspection = null ;
4954 await SpecRunnerUtils . closeTestWindow ( ) ;
5055 } , 30000 ) ;
5156
52- const JSHintErrorES6Errir_js = "Missing semicolon. jshint (W033)" ;
57+ const JSHintErrorES6Error_js = "Missing semicolon. jshint (W033)" ,
58+ ESLintErrorES7Error_js = "Parsing error: Unexpected token ; ESLint (null)" ;
59+
60+ async function _createTempProject ( esLintSpecSubFolder ) {
61+ return await SpecRunnerUtils . getTempTestDirectory ( testRootSpec + esLintSpecSubFolder ) ;
62+ }
5363
5464 async function _openProjectFile ( fileName ) {
5565 await awaitsForDone ( SpecRunnerUtils . openProjectFiles ( [ fileName ] ) , "opening " + fileName ) ;
5666 }
5767
68+ async function _npmInstallInFolder ( folder ) {
69+ const npmInstallPlatformPath = Phoenix . fs . getTauriPlatformPath ( folder ) ;
70+ await NodeUtils . _npmInstallInFolder ( npmInstallPlatformPath ) ;
71+ }
72+
5873 async function _waitForProblemsPanelVisible ( visible ) {
5974 await awaitsFor ( ( ) => {
6075 return $ ( "#problems-panel" ) . is ( ":visible" ) === visible ;
@@ -80,8 +95,8 @@ define(function (require, exports, module) {
8095 await _openSimpleES6Project ( ) ;
8196
8297 await awaitsFor ( ( ) => {
83- return $ ( "#problems-panel" ) . text ( ) . includes ( JSHintErrorES6Errir_js ) ;
84- } , JSHintErrorES6Errir_js ) ;
98+ return $ ( "#problems-panel" ) . text ( ) . includes ( JSHintErrorES6Error_js ) ;
99+ } , JSHintErrorES6Error_js ) ;
85100 } ) ;
86101 return ;
87102 }
@@ -92,10 +107,9 @@ define(function (require, exports, module) {
92107 await awaitsFor ( ( ) => {
93108 return $ ( "#problems-panel" ) . text ( ) . includes ( Strings . DESCRIPTION_ESLINT_DO_NPM_INSTALL ) ;
94109 } , Strings . DESCRIPTION_ESLINT_DO_NPM_INSTALL ) ;
95- } ) ;
110+ } , 5000 ) ;
96111
97- it ( "should show JSHint in desktop app if ESLint load failed for project" , async function ( ) {
98- await _openSimpleES6Project ( ) ;
112+ async function _fileSwitcherroForESLintFailDetection ( ) {
99113 // at this point, ESLint will try to load and fail to load. During first load only ESLint results will
100114 // be shown. But upon detecting ESLint load failure, the next JSHint will be shown too to help the user.
101115 // so we switch to another file and switch back to show jshint.
@@ -104,13 +118,78 @@ define(function (require, exports, module) {
104118 await _waitForProblemsPanelVisible ( false ) ;
105119 await _openProjectFile ( "error.js" ) ;
106120 await _waitForProblemsPanelVisible ( true ) ;
121+ }
107122
123+ it ( "should show JSHint in desktop app if ESLint load failed for project" , async function ( ) {
124+ await _openSimpleES6Project ( ) ;
125+ await _fileSwitcherroForESLintFailDetection ( ) ;
108126 await awaitsFor ( ( ) => {
109127 return $ ( "#problems-panel" ) . text ( ) . includes ( Strings . DESCRIPTION_ESLINT_DO_NPM_INSTALL ) ;
110128 } , "ESLint error to be shown" ) ;
111129 await awaitsFor ( ( ) => {
112- return $ ( "#problems-panel" ) . text ( ) . includes ( JSHintErrorES6Errir_js ) ;
130+ return $ ( "#problems-panel" ) . text ( ) . includes ( JSHintErrorES6Error_js ) ;
113131 } , "JShint error to be shown" ) ;
132+ } , 5000 ) ;
133+
134+ describe ( "ES6 project" , function ( ) {
135+ let es6ProjectPath ;
136+
137+ beforeAll ( async function ( ) {
138+ es6ProjectPath = await _createTempProject ( "es6" ) ;
139+ await _npmInstallInFolder ( es6ProjectPath ) ;
140+ await SpecRunnerUtils . loadProjectInTestWindow ( es6ProjectPath ) ;
141+ } , 30000 ) ;
142+
143+ async function _loadAndValidateES6Project ( ) {
144+ await _openProjectFile ( "error.js" ) ;
145+ await _waitForProblemsPanelVisible ( true ) ;
146+ await awaitsFor ( ( ) => {
147+ return $ ( "#problems-panel" ) . text ( ) . includes ( Strings . DESCRIPTION_ESLINT_LOAD_FAILED ) ;
148+ } , "ESLint v6 not supported error to be shown" ) ;
149+ }
150+
151+ it ( "should ESLint v6 show unsupported version error" , async function ( ) {
152+ await _loadAndValidateES6Project ( ) ;
153+ } , 5000 ) ;
154+
155+ it ( "should show ESLint and JSHint in desktop app for es6 project or below" , async function ( ) {
156+ await _loadAndValidateES6Project ( ) ;
157+ await _fileSwitcherroForESLintFailDetection ( ) ;
158+ await awaitsFor ( ( ) => {
159+ return $ ( "#problems-panel" ) . text ( ) . includes ( JSHintErrorES6Error_js ) ;
160+ } , "JShint error to be shown" ) ;
161+ } , 5000 ) ;
162+ } ) ;
163+
164+ describe ( "ES7 and JSHint project" , function ( ) {
165+ let es7ProjectPath ;
166+
167+ beforeAll ( async function ( ) {
168+ es7ProjectPath = await _createTempProject ( "es7_JSHint" ) ;
169+ await _npmInstallInFolder ( es7ProjectPath ) ;
170+ await SpecRunnerUtils . loadProjectInTestWindow ( es7ProjectPath ) ;
171+ } , 30000 ) ;
172+
173+ async function _loadAndValidateES7Project ( ) {
174+ await _openProjectFile ( "error.js" ) ;
175+ await _waitForProblemsPanelVisible ( true ) ;
176+ await awaitsFor ( ( ) => {
177+ return $ ( "#problems-panel" ) . text ( ) . includes ( ESLintErrorES7Error_js ) ;
178+ } , "ESLint v7 error to be shown" ) ;
179+ }
180+
181+ it ( "should ESLint v7 work as expected" , async function ( ) {
182+ await _loadAndValidateES7Project ( ) ;
183+ } , 5000 ) ;
184+
185+ it ( "should show ESLint and JSHint in desktop app if .jshintrc Present" , async function ( ) {
186+ await _loadAndValidateES7Project ( ) ;
187+ await awaitsFor ( ( ) => {
188+ return $ ( "#problems-panel" ) . text ( ) . includes ( JSHintErrorES6Error_js ) ;
189+ } , "JShint error to be shown" ) ;
190+ } , 5000 ) ;
191+
192+ // todo eslint module test
114193 } ) ;
115194 } ) ;
116195} ) ;
0 commit comments