JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2817
  • Score
    100M100P100Q110404F
  • License MIT

Modular ESLint configuration

Package Exports

  • eslint-config-modular

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (eslint-config-modular) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Modular ESLint Configuration

Build Status Windows Build Status Dependencies

npm License

eslint-config-modular is a shareable config for ESLint that's broken-up into different modules for different types of JavaScript projects (browser, Node, ES5, ES6, etc.). These modules can be used individually or in combination to match the needs of your project.

Each module defines rules that are meant to be reasonable defaults and best practices, but you can easily extend or override any of the rules to suit your needs.

Installation

Run the following NPM command to install ESLint and eslint-config-modular as dev-dependencies of your project:

npm install eslint eslint-config-modular --save-dev

Usage

Shareable configs are designed to work with the extends feature of .eslintrc files. You can learn more about Shareable Configs on the official ESLint website.

To use eslint-config-modular in your project, create an .eslintrc.yml file with the following contents:

.eslintrc.yml

extends:
  # These modules would be good for a Node.js project written in ES5
  - modular/best-practices
  - modular/style
  - modular/node
  - modular/es5

rules:
  # You can override or extend the rules here

Modules

eslint-config-modular includes the following modules. Mix-and-match them as applicable to your project.

modular/best-practices (source)

This module contains rules that enforce good JavaScript coding practices, such as avoiding the eval() statement, not reassigning native objects, and using === instead of == for comparisons. Most of the rules in this file will raise an error if violated, but some less-severe ones will only raise warnings.

modular/browser (source)

This module configures ESLint to recognize browser globals, such as window, document, navigator, etc. It also contains rules that are specific to projects that are intended to run in web browsers, such as avoiding the alert() statement.

modular/node (source)

This module configures ESLint to recognize Node.js globals, such as process, __dirname, Buffer, etc. It also contains rules that are specific to Node.js projects, such as avoding new require() syntax and disallowing concatenation with __dirname.

modular/es5 (source)

This module configures ESLint to parse EcmaScript 5 code. It also disables ES6-specific rules and enables ES5-specifc rules, such as requiring the "use strict" pragma.

modular/es6 (source)

This module configures ESLint to parse EcmaScript 6 (and newer) code. It also contains ES6-specific rules, such as not assigning to constants, calling super() in constructors, and using let instead of var.

modular/jsx (source)

This module configures ESLint to parse JSX syntax. It also contains JSX-specific rules, such as enforcing the use of double-quotes in JSX attributes.

modular/style (source)

This module contains code-styling and consistency rules, such as single-quotes, two-space indentation, and semi-colons. Obviously, the rules in this module are entirely subjective and reflect my personal preferences. You are free to override or extend these rules as you desire, or not use this module at all.

modular/test (source)

This module configures ESLint to recognize globals that are defined by common test frameworks, such as describe, it, beforeEach, assert, expect, etc. It also disables rules that tend to cause problems with certain test frameworks.

Note: I recommend that you create a separate .eslintrc.yml file in your test folder. That way, it can use different modules and rules than the rest of your codebase.