springload/eslint-plugin-springload

Name: eslint-plugin-springload

Owner: Springload

Description: Springload's ESLint shareable configurations, as a plugin.

Created: 2017-06-10 16:13:35.0

Updated: 2017-09-29 17:02:03.0

Pushed: 2017-09-25 01:51:50.0

Homepage: https://www.npmjs.com/package/eslint-plugin-springload

Size: 82

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

eslint-plugin-springload npm Build Status

Springload's ESLint shareable configurations, as a plugin.

Why

We want shareable configs to have as low of an overhead as possible. Users shouldn't have to know exactly what plugins are required by the config, install them and manage their versions manually. This plugin exposes eslint-config-springload for reuse, with plugins automatically installed.

See https://github.com/eslint/eslint/issues/3458 for further discussion on this topic. Approach inspired by eslint-plugin-react-app.

Usage

Install the config and its dependencies:

install --save-dev eslint@3 eslint-plugin-springload

Configure ESLint to use this config. For example, in your package.json, this would be:

intConfig": {
xtends": "plugin:springload/recommended"

With Prettier

This ESLint plugin comes with a built-in Prettier-compatible config. First, install Prettier:

install --save-dev prettier

Switch to the Prettier config:

intConfig": {
xtends": "plugin:springload/prettier"

Then, to configure Prettier itself, create a prettier.config.js file in the root of your project with:

se the Prettier config that comes with eslint-plugin-springload.
le.exports = require('eslint-plugin-springload/prettier.config');
Integration in a development workflow

For Springload projects, linting commands are defined in the package.json as npm scripts. Here are example commands leveraging the ESLint and Prettier configuration, to process code in a lib subfolder:

ipts": {
"linter:js": "eslint",
"formatter:js": "prettier --write",
"lint": "npm run linter:js -s -- lib",
"format": "npm run formatter:js -s -- lib/**/*.js",

Those commands can then be ran manually.

Usage with git pre-commit hook

The above commands are meant to be usable on arbitrary lists of files. Here is an example pre-commit script that leverages them to re-format and lint JS when committing:

ly keep staged files that are added (A), copied (C) or modified (M).
ED=$(git --no-pager diff --name-only --cached --diff-filter=ACM)
les which are only partly staged (eg. git add --patch).
H_STAGED=$(git --no-pager diff --name-only --diff-filter=ACM $STAGED)
les which are fully staged.
Y_STAGED=$(comm -23 <(echo "$STAGED") <(echo "$PATCH_STAGED"))

TAGED=$(grep .js$ <<< "$STAGED" || true)
ULLY_STAGED=$(grep .js$ <<< "$FULLY_STAGED" || true)
SHOT_STAGED=$(grep .snap$ <<< "$STAGED" || true)

 -n "$JS_FULLY_STAGED" ];

# Format and re-stage fully staged files only.
npm run formatter:js -s -- $JS_FULLY_STAGED
git add $JS_FULLY_STAGED


 -n "$JS_STAGED" ];

npm run linter:js -s -- $JS_STAGED

Configuring the rules

This is a drop-in configuration for Springload projects. Should further customisation be required, rules coming from external plugins require the springload prefix:


xtends": "plugin:springload/recommended"
ules": {
 "react/react-in-jsx-scope": ["warn"],
 "springload/react/react-in-jsx-scope": ["warn"],
 "import/prefer-default-export": ["warn"],
 "springload/import/prefer-default-export": ["warn"],


Usage
Development
Install
clone git@github.com:springload/eslint-plugin-springload.git
slint-plugin-springload
install
en, install all project dependencies.
install
stall the git hooks.
ithooks/deploy
Development
ns linting.
run lint
ns tests.
run test
Releases

This project follows Semantic Versioning as well as ESLint's Semantic Versioning Policy.

 Make a new branch for the release of the new version.
chore release-vx.y.z
 Update the version in package.json
 Use irish-pub to check the package content. Install with `npm install -g` first.
h-pub
 Update the [CHANGELOG](CHANGELOG.md) for the upcoming release.
 Create a PR and merge it.
 On master,
publish
 Finally, go to GitHub and create a release and a tag for the new version.

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.