Skip to content

ESLint config to be used across MaaS projects

Notifications You must be signed in to change notification settings

maasglobal/eslint-config-maasglobal

Repository files navigation

eslint-config-maasglobal

DEPRECATED

This eslint config was used for old JavaScript based MaaS Global projects. The focus of development has since moved to TypeScript. The config available in this package has been deprecated as a result. Please migrate to eslint-config-maasglobal-ts that is used for all new MaaS Global projects.

Usage

In package.json reference eslint-config-maasglobal, eslint-plugin-import, eslint-plugin-jsdoc as one of devDependencies, and configure eslint as:

{
  "eslintConfig": {
    "extends": "maasglobal"
  }
}

Prettier integration

Note that provided eslint setup doesn't handle eventual code style formatting. This is supposed to be solely guarded by Prettier

Within new projects, ensure prettier as one of devDependencies and setup .prettierrc.js as:

'use strict';

module.exports = require('eslint-config-maasglobal/.prettierrc');

It's highly recommended that for consistent whitespace formatting, an IDE is configured to also apply Prettier formatting on each file save.

Scripts setup and CI integration

For proper CI integration it's recommended that all MaaS projects have following scripts preconfgured:

{
  "lint": "eslint --ignore-path=.gitignore .",
  "lint-updated": "pipe-git-updated --ext=js -- eslint --ignore-pattern '!*'",
  "prettier-check-updated": "pipe-git-updated --ext=css --ext=html --ext=js --ext=json --ext=md --ext=yaml --ext=yml -- prettier -c",
  "prettify": "prettier --write --ignore-path .gitignore '**/*.{css,html,js,json,md,yaml,yml}'",
  "prettify-updated": "pipe-git-updated --ext=css --ext=html --ext=js --ext=json --ext=md --ext=yaml --ext=yml -- prettier --write"
}

Note: Scripts require additional git-list-updated dependency to be installed, reference it in devDependencies

In Travis CI configuration, ensure that following validation is made on each PR build (but not on branch deployment):

npm run lint-updated && npm run prettier-check-updated