bpearson / atom-phpcs

PHP CodeSniffer package for Atom editor
MIT License
6 stars 1 forks source link

Uncaught SyntaxError: Unexpected token u in JSON at position 1 #34

Closed annalinneajohansson closed 7 years ago

annalinneajohansson commented 7 years ago

[Enter steps to reproduce:]

  1. ...
  2. ...

Atom: 1.17.2 x64 Electron: 1.3.15 OS: Ubuntu 17.04 Thrown From: atom-phpcs package 1.7.3

Stack Trace

Uncaught SyntaxError: Unexpected token u in JSON at position 1

At file:///usr/share/atom/resources/app/static/index.html:1

SyntaxError: Unexpected token u in JSON at position 1
    at Object.parse (native)
    at exit (/packages/atom-phpcs/lib/atom-phpcs.coffee:194:27)
    at triggerExitCallback (/usr/share/atom/resources/app/src/buffered-process.js:338:1)
    at ChildProcess.<anonymous> (/usr/share/atom/resources/app/src/buffered-process.js:368:1)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)

Commands

     -0:33.7.0 core:paste (input.hidden-input)
     -0:33 core:undo (input.hidden-input)
     -0:31.1.0 autocomplete-plus:confirm (input.hidden-input)
     -0:31.1.0 snippets:expand (atom-text-editor.editor.is-focused)
     -0:30.7.0 docblockr:parse-enter (input.hidden-input)
     -0:30.7.0 editor:newline (input.hidden-input)
     -0:29.8.0 core:select-right (input.hidden-input)
     -0:29.5.0 core:select-down (input.hidden-input)
     -0:28.9.0 core:paste (input.hidden-input)
     -0:20.3.0 core:backspace (input.hidden-input)
     -0:11.1.0 core:copy (input.hidden-input)
     -0:07.8.0 docblockr:parse-enter (input.hidden-input)
     -0:07.8.0 editor:newline (input.hidden-input)
     -0:07.3.0 core:paste (input.hidden-input)
     -0:04.8.0 docblockr:parse-enter (input.hidden-input)
     -0:03.4.0 core:save (input.hidden-input)

Non-Core Packages

aligner 1.2.4 
aligner-css 1.2.1 
aligner-javascript 1.3.0 
aligner-php 1.2.0 
aligner-scss 1.3.1 
atom-autocomplete-php 0.25.6 
atom-phpcs 1.7.3 
atom-ternjs 0.18.3 
atom-wordpress 0.3.0 
autoclose-html 0.23.0 
autocomplete-wordpress-hooks 0.2.3 
color-picker 2.2.5 
compile-watch 0.1.4 
craft-twig 0.4.0 
dash-syntax 0.3.0 
docblockr 0.11.0 
file-icons 2.1.11 
git-plus 7.9.3 
jQuery 1.2.5 
jquery-snippets 11.0.0 
language-log 1.8.0 
project-manager 3.3.5 
sass-autocompile 0.13.3 
todo-show 2.0.0 
wordpress 0.2.0 
wordpress-api 1.2.2 
wordpress-autocomplete 1.2.0 
wordpress-suite 1.2.0 
wp-dev 0.3.5 
bpearson commented 7 years ago

I think this is a problem with this package, I think its a problem with phpcs itself. At a guess you are producing an error which is breaking the JSON output of phpcs. Do you have a sample of the file? Have you tried running phpcs manually over the file?

annalinneajohansson commented 7 years ago

It's happening on save, on any php file. The one in question only contains:

add_action( 'wp_enqueue_scripts', 'storefront_parent_theme_enqueue_styles' );

function storefront_parent_theme_enqueue_styles() { wp_enqueue_style( 'storefront-style', get_template_directory_uri() . '/style.css' ); /**

  • @todo Add Google Fonts section to the customizer */ wp_enqueue_style( 'google-fonts', '//fonts.googleapis.com/css?family=Playfair+Display|Varela', array(), 1 ); wp_enqueue_style( 'hoxton-storefront-style', get_stylesheet_directory_uri() . '/style.css', array( 'storefront-style', 'google-fonts' ) );

}

Running phpcs on the file looks like this (not sure what it should look like, don't normally use it on the command line?):

[10:58:22]anna@EdenPredator:~/$ phpcs /home/anna/Projects/GetTheGallop/wp-content/themes/hoxton-storefront/functions.php . Time: 30ms; Memory: 4Mb

bpearson commented 7 years ago

Yeah its a prob with phpcs... `$ phpcs --report=json test.php E

{"totals":{"errors":18,"warnings":0,"fixable":14},"files":...`

I believe if you upgrade it to version 3, it should work.