Code Monkey home page Code Monkey logo

grunt-esformatter's Issues

'skipHashbang' option issue

Hello,

I'm experiencing an issue when I tried skipHashbang: true in options.

In package.json, I have these in devDependencies:

"grunt-esformatter": "1.0.1",
"esformatter": "0.7.3",
"esformatter-semicolons": "1.1.1",
"esformatter-var-each": "2.1.0",
"esformatter-quotes": "1.0.3",
"esformatter-eol-last": "1.0.0",
"esformatter-dot-notation": "1.3.1",
"esformatter-literal-notation": "1.0.1"

And this is a part of Gruntfile.js:

  var step1 = {
    src: [
      'src/js/*.js'
    ],
    options: {
      'plugins': [
        'esformatter-semicolons',
        'esformatter-var-each'
      ],
      'skipHashbang': true,
      'quotes': {
        'type': 'single',
        'avoidEscape': true
      },
      'whiteSpace': {
        'before': {
          'Property': '>=0',
          'PropertyName': 1,
          'ArrayExpressionClosing': 1,
          'ObjectExpressionClosingBrace': 1
        },
        'after': {
          'FunctionReservedWord': 1,
          'ArrayExpressionOpening': 1,
          'ObjectExpressionOpeningBrace': '>=0'
        }
      },
      'lineBreak': {
        'before': {
          'ArrayExpressionClosing': '>=0',
          'ObjectExpressionClosingBrace': '>=0',
          'Property': '>=0'
        },
        'after': {
          'ArrayExpressionOpening': '>=0',
          'ArrayExpressionComma': '>=0',
          'ObjectExpressionClosingBrace': '>=0',
          'ObjectExpressionOpeningBrace': '>=0',
          'PropertyValue': '>=0'
        }
      }
    }
  };

  var step2 = JSON.parse(JSON.stringify(step1));

  step2.options.plugins = [
    'esformatter-quotes',
    'esformatter-eol-last',
    'esformatter-dot-notation',
    'esformatter-literal-notation'
  ];

  grunt.config.set('esformatter', {
    step1: step1,
    step2: step2
  });

  grunt.registerTask('compassFormat', ['esformatter']);

The issue I see while formatting is going on is this: whenever there's a line that has 'null' (in multiple files), for example, at this kind of line:

var foo = null;

error is thrown. One sample error message looks like this:

>> Exception while formatting js/views/slides.js
>> Error: Line 321: Unexpected token ;
>>     at createError (/Users/glee/demo_proj/node_modules/grunt-esformatter/node_modules/esformatter/node_modules/rocambole/node_modules/esprima/esprima.js:2392:21)
>>     at unexpectedTokenError (/Users/glee/demo_proj/node_modules/grunt-esformatter/node_modules/esformatter/node_modules/rocambole/node_modules/esprima/esprima.js:2467:13)
>>     at throwUnexpectedToken (/Users/glee/demo_proj/node_modules/grunt-esformatter/node_modules/esformatter/node_modules/rocambole/node_modules/esprima/esprima.js:2472:15)
>>     at parsePrimaryExpression (/Users/glee/demo_proj/node_modules/grunt-esformatter/node_modules/esformatter/node_modules/rocambole/node_modules/esprima/esprima.js:3266:13)
>>     at inheritCoverGrammar (/Users/glee/demo_proj/node_modules/grunt-esformatter/node_modules/esformatter/node_modules/rocambole/node_modules/esprima/esprima.js:2648:18)
>>     at parseLeftHandSideExpressionAllowCall (/Users/glee/demo_proj/node_modules/grunt-esformatter/node_modules/esformatter/node_modules/rocambole/node_modules/esprima/esprima.js:3373:20)
>>     at inheritCoverGrammar (/Users/glee/demo_proj/node_modules/grunt-esformatter/node_modules/esformatter/node_modules/rocambole/node_modules/esprima/esprima.js:2648:18)
>>     at parsePostfixExpression (/Users/glee/demo_proj/node_modules/grunt-esformatter/node_modules/esformatter/node_modules/rocambole/node_modules/esprima/esprima.js:3449:16)
>>     at parseUnaryExpression (/Users/glee/demo_proj/node_modules/grunt-esformatter/node_modules/esformatter/node_modules/rocambole/node_modules/esprima/esprima.js:3509:20)
>>     at inheritCoverGrammar (/Users/glee/demo_proj/node_modules/grunt-esformatter/node_modules/esformatter/node_modules/rocambole/node_modules/esprima/esprima.js:2648:18)

Do you have any idea what caused this error? Please let me know if you want me to provide more info. Thanks.

Add configuration option to specify an options file

At the moment, AFAICS all the configuration options needs to be done in the Gruntfile.js. When using esformatter standalone it allows you to create an additional configuration file and specify that file using the --config command-line switch.

It would be great if there was an equivalent for --config in the Grunt task so you do not have to replicate all the rules.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.