Giter Site home page Giter Site logo

eslint-config's Introduction

eslint-config

This is based on the AirBnB style guide, but includes a number of additional plugins and some custom rules for our preferences.

Checkout the index.js for the details.

Plugins

Occasionally look here for new good stuff.

Install

To install just the config, use the line below.

npm i -D @searchspring/eslint-config

It's recommended to also install the Searchspring prettier config:

npm i -D @searchspring/prettier

In order to install all the related dependencies and a typical configuration for a JS project, also run the following:

npm i -D eslint husky lint-staged prettier fixpack

Then update your package.json with the following:

{
	husky: {
		hooks: {
			// Runs staged files for a commit through the scripts below
			'pre-commit': 'lint-staged',
		},
	},
	// Scripts for staged files
	'lint-staged': {
		'./package.json': ['fixpack', 'prettier --write'],
		'*.{js,ts}': ['prettier --write', 'eslint --fix'],
	},
	scripts: {
		format: 'prettier --write "**/*.{js,ts,json}"',
		lint: 'eslint --fix "**/*.{js,ts}"',
		// Important to run the fixpack before format, as format will fix the indentation
		style: 'fixpack && npm run format && npm run lint',
	},
}

Additional config if you are using Mocha

Update your eslint configuration with following:

	env: {
		...
+		mocha: true,
	},
	extends: [
		...
+		'plugin:mocha/recommended',
	]
+	plugins: [..., 'mocha'],
	rules: {
		...
+		'mocha/handle-done-callback': 'error',
+		'mocha/max-top-level-suites': 'off',
+		'mocha/no-exclusive-tests': 'error',
+		'mocha/no-global-tests': 'error',
+		'mocha/no-hooks-for-single-case': 'off',
+		'mocha/no-identical-title': 'error',
+		'mocha/no-mocha-arrows': 'off',
+		'mocha/no-nested-tests': 'error',
+		'mocha/no-pending-tests': 'error',
+		'mocha/no-return-and-callback': 'error',
+		'mocha/no-sibling-hooks': 'error',
	}

eslint-config's People

Contributors

leukanos avatar

Watchers

James Cloos avatar Greg Hellings avatar  avatar  avatar

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.