js-project-commons

raw JSON →
1.3.2 verified Fri May 01 auth: no javascript maintenance

Version 1.3.2 (last release 2021-02-08) is a collection of shared Grunt tasks, lint configurations, and markdown templates for personal Node.js and web projects. It centralizes common build processes (e.g., linting, testing, security validations, GitHub release) and uses ES6 syntax since v1.3.0. Unlike standalone tools, this package bundles dependencies internally (since v1.0.34) and provides ready-to-use Grunt tasks for tasks like stylelint, htmlhint, API doc generation, and file name linting. Release cadence has stopped after 2021, and it is now in maintenance mode. The library is opinionated and primarily intended for the author's projects.

error Error: Cannot find module 'js-project-commons'
cause Package not installed or missing from node_modules.
fix
Run 'npm install --save-dev js-project-commons'
error Warning: Task "eslint" not found. Use --force to continue.
cause Grunt task not loaded because js-project-commons is not loaded via loadNpmTasks.
fix
Add grunt.loadNpmTasks('js-project-commons') in Gruntfile.
error TypeError: js_project_commons is not a function
cause Trying to call require('js-project-commons') as a function (it's not callable).
fix
Use require('js-project-commons') only to load tasks, not as a function.
breaking ES6 syntax introduced in v1.3.0 may break projects using Node <6.
fix Upgrade Node.js to version 6 or higher.
gotcha Internal dependencies are bundled (since v1.0.34); do not install them separately.
fix Only install js-project-commons; its dependencies are loaded internally.
deprecated jslint is disabled by default since v1.0.96
fix Use eslint instead of jslint.
gotcha Bower.json is no longer required for web projects since v1.3.1
fix Remove unnecessary bower.json file.
breaking Karma browser configuration moved to karma conf instead of grunt task since v1.1.6
fix Set browser in karma.conf.js, not in Gruntfile.
npm install js-project-commons
yarn add js-project-commons
pnpm add js-project-commons

Shows how to load the package in a Gruntfile and override eslint config.

// Install: npm install --save-dev js-project-commons
// Gruntfile.js
module.exports = function(grunt) {
  grunt.loadNpmTasks('js-project-commons');
  grunt.initConfig({
    // Override specific task configs here
    eslint: {
      options: {
        configFile: '.eslintrc.js'
      }
    }
  });
  grunt.registerTask('build', ['eslint', 'mochaTest']);
};