Giter Site home page Giter Site logo

lintlovin's Introduction

Lintlovin

Lintlovin sets up your project for automatic linting, whitespace checking, and runs mocha tests (if you have any).

On install (npm install lintlovin --save-dev) it will set up a Grunt file, .editorconfig, .jshintrc, and a git hook that runs test before you push. The gotcha here is that it will run tests on what is in you working directory, and not on the actual contents of the branch.

To run tests continually while editing run grunt watch in your project. To run tests manually just run npm test.

JSHint options

  asi: false # Don't allow missing semicolons.
  bitwise: true # Bitwise ops are forbidden.
  camelcase: false # Do not force use of camelCase.
  curly: true # Force code blocks after flow control statement.
  eqeqeq: true # Force === for equality checking.
  freeze: true # Don't allow fiddling with prototypes of native objects
  immed: true # Prohibit the use of immediate function invocations without wrapping them in parentheses
  indent: 2 # Two spaces indent
  latedef: nofunc # Only allow late definition of functions.
  newcap: true # Force capitalisation of constructor functions
  noarg: true # Prohibit the use of arguments.caller and arguments.callee.
  noempty: true # Warn when you have an empty block in your code.
  nonbsp: true # Catch non-breaking whitespace.
  nonew: true # Prohibit the use of constructor functions for side-effects.
  quotmark: single # Single quotes for strings.
  strict: true # Strict mode!
  undef: true # Prohibit the use of explicitly undeclared variables.
  unused: true # Warns when you define and never use your variables.

Rationale for not forcing camelCase: It's quite common to get data from modules and APIs that doesn't use camel case, that would then generate errors when you try to access non-camel properties.

Available Grunt tasks

The npm-based commands don't need grunt-cli, but the grunt commands do.

  • default – the default task, the one invoked when running just grunt, will if no additional tasks are added just run the test task.
  • test – lints all files to the defined JSHint and EditorConfig coding style guidelines and, unless noMocha has been set to true, runs all tests in a test/-folder if such a one exist, with the exclusion of any tests in a test/integration/ folder. Can be invoked through either grunt test or npm test.
  • test-all – like test, but also runs the tests in the test/integration/ folder. Can be invoked through either grunt test-all or npm run test-all.
  • watch – watches for file changes and runs test on any relevant change. Can be invoked through grunt watch.

lintlovin.initConfig(grunt[, config] [, options])

To be run from the parent project's Gruntfile.js. Initializes the grunt object sent in with a basic task setup. Also allows additional task setups to be sent in through config and for altering the basic setup in some ways through options.

Options

  • integrationWatch – makes the watch task also run tests in test/integration/, which can be unfeasable in big projects, but nice in smaller ones. Defaults to false.
  • jsFiles – an array of additional files to watch and lint. By default .js-files in top folder or below the bin/, cli/, lib/ or test/ folders will be watched and linted. (Also any non-js file in test/ will be watched and will thus retrigger a test when changed)
  • spaceFiles – an array of additional files to just watch and whitespace lint.
  • dependencyFiles – an array of additional files to just check for dependencies.
  • watchFiles – an array of additional files to just watch.
  • enableCoverageEvent – enables the grunt-mocha-istanbul coverage event on tests
  • extraDefaultTasks – an array of additional tasks to add to the default task alias
  • extraTestTasks – an array of additional tasks to add to the test task alias
  • extraTestAllTasks – an array of additional tasks to add to the test-all task alias
  • extraWatchTasks – an object of additional watch task definitions
  • noIntegration – whether there are integration tests in test/integration/ or not. Defaults to true if test/integration/ exists.
  • noMocha – disables the Mocha tests. Mocha tests are otherwise run if a test/-folder is found in the parent project.
  • noTiming – disables the time-grunt performance output
  • noJSCS – disables the jscs plugin
  • noDependencyCheck – disables the dependency-check plugin
  • ignoreUnusedDependencies – ignores the specified modules when looking for unused modules

lintlovin's People

Contributors

voxpelli avatar hugowetterberg avatar ptte avatar jmedoy avatar mortonfox avatar singwai avatar

Stargazers

Tom Rogers avatar  avatar Rodrigo Tello avatar Aseem Kishore avatar  avatar Zach Ambrose avatar Martin avatar Daniel Grossfeld avatar Fredrik Forsmo avatar Teddy Zetterlund avatar

Watchers

 avatar  avatar John O'Neill avatar James Cloos avatar Dan Carlberg avatar christian avatar  avatar Russell J.B. avatar Alex Qin avatar  avatar Paolo Vaca avatar Billy Ohgren avatar Adam Nyberg avatar Eric Doty avatar Emil Vikström avatar Nicholas Vincent DiSanto avatar  avatar Dev0 avatar Daniel Tyner-Bryan avatar Jake Etter avatar Nichole Boseman avatar Skye Freeman avatar Victor Crispin avatar Mike Chan avatar Zayne Halsall avatar Nancy Thornton avatar Len Gillespie avatar  avatar Bloglovin CI avatar Alex Harris avatar Darren avatar Douglas Moore avatar  avatar Kevin Naughton Jr. avatar  avatar  avatar  avatar Suraj Kumar Maurya avatar  avatar  avatar Rashmi avatar

lintlovin's Issues

noMocha have no effect?

I didn't not test this properly. But it seems like noMocha has no effect, it still expects a test directory to be around.

Warn about outdated dependencies

If it was X time ago that new dependency versions was looked for, then trigger a background process that checks for new dependency versions and updates a local dependency cache.

Then on each test, check that cache for new versions and warn/notify the user about outdated dependencies.

(In the case of an outdated Lintlovin and/or other specified versions, perhaps even throw an error)

Construct this as a new grunt task that can be used independently of Lintlovin.

Check that used dependencies are included and non-used excluded from package.json

Using eg. Max Ogden's https://github.com/maxogden/dependency-check or some alternatives like https://github.com/rumpl/depcheck or https://github.com/dylang/npm-check to parse all used packages and ensure that those and only those are included as dependencies.

This is a good addition to the already existing JSHint checks for unused variables that will remind one to remove the inclusion of non-used modules in the JS-code. An addition like this will ensure that if a module is removed from all JS-files, that the module is also removed as a dependency from the project.

Warn about outdated/undesired node.js / npm version

If we're doing an app for Node 0.10 or for iojs then we want to ensure that everyone that uses that app uses it with the right node version and even more we want to ensure that the tests that are run are run with the right node version.

As different npm versions can also treat package.json files different we also want to ensure that the npm version is fairly new – if not of the latest version so at least one of the third latest or so.

This should be checked on at least push time.

No dependency check fails

Running "dependency-check:files" (dependency-check) task Fatal error: No entry paths found

If all files have been ignored in dependencyFiles

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.