JavaScript for WordPress Forums Vanilla JavaScript 1.7.14.9 – ERROR LINTING WITH GULP

This topic contains 4 replies, has 2 voices, and was last updated by  Zac Gordon 2 years, 6 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #25869

    Jonathan
    Participant

    Hi! I’m having an issue related to Gulp and Eslint.

    Had to install Eslint globally with npm, and to init it manually for it to work; and it throws this error whenever I modify any .js

    [11:14:29] Using gulpfile ~/Desktop/gurupu/gulpfile.js
    [11:14:30] Starting 'connect'...
    [11:14:30] Finished 'connect' after 11 ms
    [11:14:30] Starting 'watch'...
    [11:14:30] Finished 'watch' after 15 ms
    [11:14:30] Starting 'default'...
    [11:14:30] Finished 'default' after 15 Ξs
    [11:14:30] Server started http://localhost:8080
    [11:14:30] LiveReload started on port 35729
    [11:14:34] Starting 'bundlejs'...
    [11:14:35] 
    /Users/Mistwalker/Desktop/gurupu/src/js/data.js
      95:5  error  'data' is assigned a value but never used  no-unused-vars
    
    /Users/Mistwalker/Desktop/gurupu/src/js/model.js
       18:31  error  'data' is not defined    no-undef
       62:14  error  'router' is not defined  no-undef
       94:8   error  'i' is not defined       no-undef
       94:15  error  'max' is not defined     no-undef
       94:35  error  'i' is not defined       no-undef
       94:39  error  'max' is not defined     no-undef
       94:44  error  'i' is not defined       no-undef
       96:24  error  'i' is not defined       no-undef
       97:20  error  'i' is not defined       no-undef
      132:8   error  'i' is not defined       no-undef
      132:15  error  'max' is not defined     no-undef
      132:35  error  'i' is not defined       no-undef
      132:39  error  'max' is not defined     no-undef
      132:44  error  'i' is not defined       no-undef
      134:23  error  'i' is not defined       no-undef
      135:19  error  'i' is not defined       no-undef
    
    /Users/Mistwalker/Desktop/gurupu/src/js/router.js
      29:3   error  'slug' is not defined     no-undef
      31:14  error  'slug' is not defined     no-undef
      37:12  error  'slug' is not defined     no-undef
      63:20  error  'model' is not defined    no-undef
      64:18  error  'helpers' is not defined  no-undef
      66:3   error  'view' is not defined     no-undef
      70:5   error  'view' is not defined     no-undef
      74:5   error  'view' is not defined     no-undef
      78:5   error  'view' is not defined     no-undef
      82:3   error  'editor' is not defined   no-undef
      85:5   error  'editor' is not defined   no-undef
      85:26  error  'editor' is not defined   no-undef
    
    /Users/Mistwalker/Desktop/gurupu/src/js/view.js
       30:15  error  'model' is not defined    no-undef
       32:17  error  'helpers' is not defined  no-undef
       33:19  error  'helpers' is not defined  no-undef
       34:2   error  Mixed spaces and tabs     no-mixed-spaces-and-tabs
       35:2   error  Mixed spaces and tabs     no-mixed-spaces-and-tabs
       55:21  error  'model' is not defined    no-undef
       56:18  error  'helpers' is not defined  no-undef
       57:20  error  'helpers' is not defined  no-undef
       85:17  error  'helpers' is not defined  no-undef
       99:19  error  'helpers' is not defined  no-undef
      111:17  error  'helpers' is not defined  no-undef
      112:19  error  'helpers' is not defined  no-undef
      125:16  error  'model' is not defined    no-undef
      127:21  error  'helpers' is not defined  no-undef
      128:2   error  Mixed spaces and tabs     no-mixed-spaces-and-tabs
      129:2   error  Mixed spaces and tabs     no-mixed-spaces-and-tabs
      133:30  error  'helpers' is not defined  no-undef
      151:19  error  'helpers' is not defined  no-undef
    
    /Users/Mistwalker/Desktop/gurupu/src/js/editor.js
       34:3   error  'model' is not defined    no-undef
       47:15  error  'helpers' is not defined  no-undef
       51:3   error  'view' is not defined     no-undef
       62:17  error  'helpers' is not defined  no-undef
       66:3   error  'view' is not defined     no-undef
       78:19  error  'helpers' is not defined  no-undef
       79:21  error  'helpers' is not defined  no-undef
      101:13  error  'helpers' is not defined  no-undef
      107:7   error  'saving' is not defined   no-undef
      115:3   error  'saving' is not defined   no-undef
      125:21  error  'helpers' is not defined  no-undef
      126:23  error  'helpers' is not defined  no-undef
      127:20  error  'helpers' is not defined  no-undef
      128:16  error  'helpers' is not defined  no-undef
      187:18  error  'helpers' is not defined  no-undef
      203:18  error  'model' is not defined    no-undef
      217:18  error  'helpers' is not defined  no-undef
      218:18  error  'helpers' is not defined  no-undef
      219:15  error  'helpers' is not defined  no-undef
      221:27  error  'model' is not defined    no-undef
      229:5   error  'model' is not defined    no-undef
      233:5   error  'model' is not defined    no-undef
    
    /Users/Mistwalker/Desktop/gurupu/src/js/app.js
      19:3  error  'model' is not defined        no-undef
      20:3  error  'router' is not defined       no-undef
      21:3  error  'view' is not defined         no-undef
      22:3  error  'editor' is not defined       no-undef
      23:3  error  Unexpected console statement  no-console
    
    ✖ 74 problems (74 errors, 0 warnings)
    
    #25883

    Jonathan
    Participant

    Nevermind, it kinda worked but the console outputs this:

    
    [11:28:49] Starting 'bundlejs'...
    [11:28:49] 
    /Users/Mistwalker/Desktop/gurupu/src/js/app.js
      10:18  error  Parsing error: Unexpected token {
    
    ✖ 1 problem (1 error, 0 warnings)
    
    stream.js:74
          throw er; // Unhandled stream error in pipe.
          ^
    GulpUglifyError: unable to minify JavaScript
        at createError (/Users/Mistwalker/Desktop/gurupu/node_modules/gulp-uglify/lib/create-error.js:6:14)
        at wrapper (/Users/Mistwalker/Desktop/gurupu/node_modules/gulp-uglify/node_modules/lodash/_createHybrid.js:87:15)
        at trycatch (/Users/Mistwalker/Desktop/gurupu/node_modules/gulp-uglify/minifier.js:26:12)
        at DestroyableTransform.minify [as _transform] (/Users/Mistwalker/Desktop/gurupu/node_modules/gulp-uglify/minifier.js:79:19)
        at DestroyableTransform.Transform._read (/Users/Mistwalker/Desktop/gurupu/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:159:10)
        at DestroyableTransform.Transform._write (/Users/Mistwalker/Desktop/gurupu/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:147:83)
        at doWrite (/Users/Mistwalker/Desktop/gurupu/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:338:64)
        at writeOrBuffer (/Users/Mistwalker/Desktop/gurupu/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:327:5)
        at DestroyableTransform.Writable.write (/Users/Mistwalker/Desktop/gurupu/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:264:11)
        at DestroyableTransform.ondata (stream.js:31:26)
    
    #25892

    Zac Gordon
    Keymaster

    Okay, so it looks like it is working, it’s just finding errors based on the default configuration.

    Try checking that there isn’t an error in app.js where it suggests.

    If you’re just running it on the sample code it should work properly.

    We haven’t covered eslint config in much depth yet (we will) but it may be that there is a global rule that is different than what I had in the demos and that is conflicting.

    Have you changed any of the sample code or are you just running the default demo?

    #25895

    Jonathan
    Participant

    Hi Zac! 🙂 Greetings from Venezuela (though I’m currently living in Chile).

    I’m sorry; I’m kinda sleepy, this is the problem I’m having, take a look! It’s kinda working, but not as it’s supposed to?

    Following the video completely, I installed the gulp-eslint package and followed all directions.

    If I modify an Js file while gulp is running, it throws this error:

    
    [11:45:05] Starting 'bundlejs'...
    /Users/Mistwalker/Desktop/gurupu/node_modules/eslint/lib/config.js:170
                throw noConfigError;
                ^
    
    Error: No ESLint configuration found.
        at getLocalConfig (/Users/Mistwalker/Desktop/gurupu/node_modules/eslint/lib/config.js:162:35)
        at Config.getConfig (/Users/Mistwalker/Desktop/gurupu/node_modules/eslint/lib/config.js:260:26)
        at processText (/Users/Mistwalker/Desktop/gurupu/node_modules/eslint/lib/cli-engine.js:224:33)
        at CLIEngine.executeOnText (/Users/Mistwalker/Desktop/gurupu/node_modules/eslint/lib/cli-engine.js:754:26)
        at verify (/Users/Mistwalker/Desktop/gurupu/node_modules/gulp-eslint/index.js:20:25)
        at Transform._transform (/Users/Mistwalker/Desktop/gurupu/node_modules/gulp-eslint/index.js:70:17)
        at Transform._read (_stream_transform.js:167:10)
        at Transform._write (_stream_transform.js:155:12)
        at doWrite (_stream_writable.js:300:12)
        at writeOrBuffer (_stream_writable.js:286:5)
    

    I haven’t touched anything but adding another number in the console log @ app.js:23

    
    console.log( 'Testing 1,2,3,4' );
    

    But whenever I add this code to the package.json

    
      "eslintConfig": {
        "eslintConfig": {
          "env": {
            "no-unused-vars": ["error", { "vars": "all" }]
          }
        }
      },
    

    And add another number to app.js:23

    
    console.log( 'Testing 1,2,3,4,5' );
    

    It works.

    In other words, without the eslintConfig part, the eslint won’t work with my project! Shouldn’t it be working without that snippet?

    #25947

    Zac Gordon
    Keymaster

    As we will discuss more on Eslint later, it runs based on a configuration file. If it is not configured properly you may not get the expected results.

    It looks like the error message before adding configuration information simply says it needs configuration information.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.