Code Monkey home page Code Monkey logo

eslintify's Introduction

eslintify

Stream module for linting JavaScript programs.



installation

npm install eslintify --save-dev

The major version number of eslintify is tied to eslint, so if you want to use eslint@3, install eslintify@3.


browserify

browserify your_file.js -t eslintify

"quiet" mode

Functionally equivalent to the ESLint CLI flag --quiet: it causes all warnings to be silently ignored. The default is for warnings to be outputted along with errors.

browserify your_file.js -t [ eslintify --quiet ]

If you only wish to suppress "ignored file" warnings, use the --quiet-ignored flag instead.


"ignored file" warnings

If you choose to exclude files via .eslintignore or elsewhere and the linter is run over them (due to them being in the globbing path), it will produce a warning. eslint@3 introduced a way for these unnecessary warnings to be suppressed; the implementation in this module is as follows:

browserify your_file.js -t [ eslintify --quiet-ignored ]

setting when to break the build

If you wish to get linting reports in the console but not break the build, use the passthrough flag like so:

browserify your_file.js -t [ eslintify --passthrough errors --passthrough warnings ]

You can customize this functionality to only allow errors to break the build (or warnings, if you want!):

browserify your_file.js -t [ eslintify --passthrough warnings ]

"continuous" mode (DEPRECATED)

NOTE: THIS IS DEPRECATED AND WILL BE REMOVED IN eslintify@4. Use the --passthrough flag.

If you wish to get linting reports in the console but not break the build, enable "continuous mode" like so:

browserify your_file.js -t [ eslintify --continuous ]

included files

If you wish to lint files with extensions other than *.js *.jsx *.es6, add extension options. The API mirrors how Browserify handles adding extra extensions:

via CLI

browserify your_file.js -t [ eslintify --extension html --extension haml ]

via JS

.transform({extensions: ['html', 'haml']}, eslintify)

other result formatters

Starting with eslintify 2.0, the default formatter is royriojas/eslint-friendly-formatter. You can opt to switch it out for your own choice by providing one of the eslint official formatter names or a path to a requireable node module.

via CLI

browserify your_file.js -t [ eslintify --formatter json ]

via JS

.transform({formatter: 'json'}, eslintify)

custom formatter via CLI

browserify your_file.js -t [ eslintify --formatter ./node_modules/eslint-path-formatter ]

custom formatter via JS

.transform({formatter: './node_modules/eslint-path-formatter'}, eslintify)

eslintify's People

Contributors

goatslacker avatar jmm avatar thedewi avatar tiddolangerak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

eslintify's Issues

Configurable suppression of warnings

At the moment, the only two warning types I can think of are files that have been ignored being passed through ESLint, and then real warnings for syntax issues. Need to figure out a way to suppress one or both in a less naïve way than #10.

I'm thinking the eventual implementation will be an extension of --quiet, like:

browserify your_file.js -t [ eslintify --quiet=ignored ]

eslintify not respecting .eslintrc with jsx set to true

This might not be a bug or is intentional, but i just wanted to confirm since i can't this config as a browserify transform, yet configuriged as a grunt task it will work fine.

{ "rules": { "indent": [ 2, 4 ], "quotes": [ 2, "single" ], "linebreak-style": [ 2, "unix" ], "semi": [ 2, "always" ], "no-console": 0, "no-undef": 0, "no-unused-vars": 0 }, "env": { "amd": true }, "extends": "eslint:recommended", "ecmaFeatures": { "jsx": true, "experimentalObjectRestSpread": true }, "plugins": [ "react" ] }

So this .eslintrc config will always throw an error (error Parsing error: Unexpected token <) when performed on jsx code for instance like this:

browserify app/app.js -t eslintify

So it is obviously not respecting jsx syntax.

but if i run it through grunt-eslint for example, it will compile fine.

Maybe i am doing something wrong here. Can't figure it out though.

Thanks in advance,
Simon

Options aren't getting passed to eslintify when using watchify

It's worth noting it works fine with Browserify (non watchify).

Trying to pass options to the plugin with v3.1.0 requiring the plugins as so.

var eslintify = require('eslintify');
var babelify = require('babelify');

Transforming the stream like so

        b.transform(eslintify, {formatter: 'json'}); 
        b.transform(eslintify, {passthrough: ['warnings']});
        b.transform(babelify, {presets: ['es2015', 'react'], plugins: ["transform-object-rest-spread"]});

results in no formatter change, nor any options being passed to eslintify.

I added a console.log into the mix to see what is being passed as the "options" parameter and did the same with babelify as a litmus.

eslintify

{ '0': '/js/core.components.js',
  '1': 
   { _flags: 
      { cache: {},
        packageCache: [Object],
        entries: [Object],
        external: [Object],
        insertGlobals: true,
        insertGlobalVars: [Object],
        poll: true,
        dedupe: true } } }

(object at index 1 are passed from watchify/browserify args)

babelify

{ '0': '/js/core.components.js',
  '1': 
   { presets: [ 'es2015', 'react' ],
     plugins: [ 'transform-object-rest-spread' ],
     sourceMaps: 'inline' } }

Pass options to ESLint

This is a simple and important feature I'm sorely missing. eslintrc is not enough when building different bundles tat have different requirements with browserify. Instead of duplicating options like quiet, IMO it would be way better to be able to use the documented ESLint options with eslintify. You may have to filter out the eslintify-specific options like continuous but that's easy to do.

In addition, I think it would make a lot of sense to set the --env "commonjs" option.

wish: bypass / configure filename test?

Could an option be exposed to skip the /\.(js|jsx|es6)$/ test, or configure the regular expression? I am using javascript transformed/extracted from HTML, so this skips many of the files I want to lint. The behaviour is a little surprising also, IMO.

In case this helps anyone reading, my current workaround is to fool it:

        .transform({ continuous: true }, function (file, options) {
            return eslintify(file + '.js', options);
        })

Thanks for a very useful plugin, Evan et al.

Don't count warnings as errors

Here's the output of using eslintify with only warnings:

✘ 19 problems (0 errors, 19 warnings)                                                                                                                                                        


Warnings:                                                                                                                                                                                    
  19  http://eslint.org/docs/rules/global-require                                                                                                                                            
eslintify: linting error(s) detected.

Browserify exits after this with a 1 for the exit code.

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.