Shareable ESLint config for Scratch
Find a file
Ray Schamp b1b0042cde fix(base): Enforce array-bracket-spacing
Array brackets should not have spaces inside of them

BREAKING CHANGE: http://eslint.org/docs/rules/array-bracket-spacing ([2, 'never'])
2016-10-24 11:26:21 -04:00
.gitignore Initial commit 2016-10-21 16:56:57 -04:00
.travis.yml build(release): Configure semantic release 2016-10-23 10:47:15 -04:00
es6.js Fix up rules after one pass of linting 2016-10-22 11:47:23 -04:00
index.js fix(base): Enforce array-bracket-spacing 2016-10-24 11:26:21 -04:00
node.js fix(node): add node env to node module 2016-10-24 10:36:10 -04:00
package.json docs(setup): Add installation and usage instructions 2016-10-23 22:49:16 -04:00
react.js style(react): Fix dangling comma 2016-10-23 18:14:53 -04:00
README.md docs(setup): Add installation and usage instructions 2016-10-23 22:49:16 -04:00

Scratch ESLint config

eslint-config-scratch defines the eslint rules used for Scratch Javascript projects

Installation

Install the config along with its peer dependencies, eslint and babel-eslint.

npm install -D eslint-config-scratch eslint@3 babel-eslint@7

If you're using the React config, also install the dependency for that

npm install -D eslint-plugin-react@6

Usage

The configuration is split up into several modules:

  • scratch: The base configuration. Always extend this.
  • scratch/node: Rules for node, e.g., server-side code, tests, and scripts
  • scratch/es6: Rules for ES6, for use when you're transpiling with webpack
  • scratch/react: Rules for React projects

Usually web projects have a mix of node and web environment files. To lint both with the appropriate rules, set up a base .eslintrc.js with the rules for node and then override the node configuration in src (where web code usually lives). E.g., with a file structure like this:

scratch-project
- .eslintrc.js
- package.json
- src
  - .eslintrc.js
  - index.js

Your config files should be set up like

// scratch-project/.eslintrc.js
module.exports = {
    extends: ['scratch', 'scratch/node'],
    env: {
        node: true
    }
};

// scratch-project/src/.eslintrc.js
module.exports = {
    root: true,
    extends: ['scratch', 'scratch/es6', 'scratch/react'],
    env: {
        browser: true
    }
};

This will set up all the files in the project for linting as Node.js by default, except for those in src/, which will be linted as ES6 and React files.

Committing

This project uses semantic release to ensure version bumps follow semver so that projects using the config don't break unexpectedly.

In order to automatically determine the type of version bump necessary, semantic release expects commit messages to be formatted following conventional-changelog.

Use the commitizen CLI to make commits formatted in this way:

npm install -g commitizen
npm install

Now you're ready to make commits using git cz.

Breaking changes

If you're committing a change that makes the linter more strict, or will otherwise require changes to existing code, ensure your commit specifies a breaking change. In your commit body, prefix the changes with "BREAKING CHANGE: " This will cause a major version bump so downstream projects must choose to upgrade the config and will not break the build unexpectedly.