eslint-config-eloquence
Adaptive, robust, elqouent ESLint configuration
Last updated 3 days ago by crystal-ball-ci .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install eslint-config-eloquence 
SYNC missed versions from official npm registry.

Eloquence


Package version NPM downloads Build status Known vulnerabilities :status      
Renovate Commitizen friendly ZenHub Semantic Release Contributor Covenant :integrations
Contains magic Full of love :flair       

Eloquence is a robust and adaptive ESLint configuration set for code linting code quality, style and formatting.

  • ???? Manages all ESLint dependencies for simple setup and version maintenance
  • ???? Intelligently adjusts error severity for style and formatting rules for development workflows
  • ???? Smartly overrides configurations for Storybook, Cypress, webpack and Jest files.
  • ✅ React Testing Library and Jest DOM rules
  • ???? Fully integrated with linting for Prettier formatting
  • ???? Includes Cypress tests specific ruleset
  • ????‍♀️ Supports linting TypeScript projects

The most important opinion of Eloquence is that linters shouldn't get in your way while developing, so outside test environments all rules related to styling are downgraded to warnings and all formatting rules are silenced. See Rules for details.

⚙️ Setup

Install Dependencies

# All projects:
npm i eslint-config-eloquence prettier -D

# TypeScript projects
npm i @typescript-eslint/eslint-plugin @typescript-eslint/parser -D

Eloquence recommends adding Prettier as an exact version project dependency to ensure all contributors are using the same version of Prettier, while still allowing projects to update Prettier versions on their own schedule.

Configure ESLint

The minimum configuration is the target option:

// .eslintrc.js
'use strict'

const eloquence = require('eslint-config-eloquence')

module.exports = eloquence({ target: 'react|node' })
  • Pass 'node' - for Node services and NPM packages
  • Pass 'react' - for React applications bundled with webpack

Option esm

The esm option can be used to explicitly declare whether a project is using ESModules or CommonJS. The default value is true.

Option ignorePatterns

Files and directories can be ignored by passing an array of string patterns. Ref ignorePatterns in config files

Option rules

Final rule values can be overridden in a project by passing a rules option with the override values. (Values are used as is, it isn't possible to pass only a severity override at this time.)

Pretty print output

The eslint-formatter-pretty package is included in the dependencies and can be used to output pretty formatted results. The pretty printed results include hyperlinks to the rule docs and the files.

eslint --format=pretty src

Pretty prints links

Recommended linting command

The recommended package.json command for linting runs on the entire directory, and uses the configuration ignorePatterns to ignore files or directories. By default node_modules and all dotfiles other than .eslintrc.js are ignored. The below config and command will lint all .js, .ts, and .tsx files in the repo, including dotfiles and directories starting with a dot, except for the public directory.

{
  "test:lint": "NODE_ENV=test eslint --format=pretty ."
}
'use strict'

const eloquence = require('eslint-config-eloquence')

module.exports = eloquence({
  target: 'react',
  ignorePatterns: ['!.*', 'public/*'],
})

⚙️ Imports customizations

Repositories can configure custom rules to enforce some common requirements:

  • Restrict importing a specific module by setting a no-restricted-imports value. This can be useful for things like preventing React Router's Link component from being used instead of an application Link component.
  • Restrict where certain modules can be imported by setting an import/no-restricted-paths value. This can be useful for enforcing boundaries between modules, like separating Electron client code from main code, or for enforcing that an index file is used for a component library directory

????‍???? Rules

The Eloquence ruleset balances providing a rigorous, comprehensive ruleset with providing only valuable linting messaging during non-test workflows. A comprehensive ruleset helps people contribute to projects by programatically answering questions about the code conventions expected by a project. However a comprehensive ruleset can also be really noisy and problematically irritating. To solve this issue Eloquence intelligently adjusts the linter error level for rule types by environment:

Error levels

Env Quality rules Style rules Formatting rules
Test error error error
Dev error warn off

This means linting related to code quality is always surfaced as a priority, but during development non critical feedback related to code style and formatting is moderated.

Linting philosphy

In general, the Eloquence ruleset tries to encourage these coding practices:

  • Readable, explicit code is always preferred over clever code.
  • Premature abstraction leads to more issues than duplicated code.
  • Whenever possible try to write simple code that can be read through without puzzle solving.

????‍♀️ TypeScript

TypeScript rules are supported out of the box for React and Node configurations using an override. Projects using TS must install @typescript-eslint/eslint-plugin and @typescript-eslint/parser and provide a tsconfig in the project root.

VSCode

By default the ESLint extension for VSCode is only configured to lint JS language files and you need to add the TypeScript and TypeScript+React languages if you haven't.

{
  "eslint.validate": [
    "javascript",
    "javascriptreact",
    "typescript",
    "typescriptreact"
  ]
}

File overrides

Eloquence overrides the base project rules and settings for specific file patterns to eliminate the need for ESLint configuration comments:

Files Updates
['*.ts', '*.tsx'] TypeScript rules enabled
['*.spec.js'] Adds Jest globals
['cypress/**/*'] Adds Cypress globals and rules
['.storybook/**/*'] Support ESmodules

Finally, configuration files for Storybook, Cypress, Babel, Jest, and webpack are all set to CommonJS modules with Node globals for configuring tooling executed by Node.js.

???? Batteries included

This package will automatically include all of the packages needed to run ESLint. Projects should allow this package to "own" the dependency management for packages related to ESLint. (When possible ensure that the only version of eslint and babel-eslint included in a project are the versions specified by this package.)

Included dependencies:

???? Contributing

This is an open source project that welcomes and appreciates contributions from everyone ????.
Please read the Code of Conduct and Contributing guides to get started.

Thank You!

  • The base ESLint rules for this project began with the Airbnb ESLint configuration and have evolved to the current rule definitions.

Current Tags

  • 14.10.0                                ...           latest (3 days ago)

86 Versions

  • 14.10.0                                ...           3 days ago
  • 14.9.0                                ...           11 days ago
  • 14.8.0                                ...           14 days ago
  • 14.7.0                                ...           a month ago
  • 14.6.0                                ...           a month ago
  • 14.5.0                                ...           2 months ago
  • 14.4.0                                ...           2 months ago
  • 14.3.2                                ...           2 months ago
  • 14.3.1                                ...           2 months ago
  • 14.3.0                                ...           2 months ago
  • 14.2.1                                ...           2 months ago
  • 14.2.0                                ...           2 months ago
  • 14.1.5                                ...           2 months ago
  • 14.1.4                                ...           2 months ago
  • 14.1.3                                ...           2 months ago
  • 14.1.2                                ...           2 months ago
  • 14.1.1                                ...           3 months ago
  • 14.1.0                                ...           3 months ago
  • 14.0.0                                ...           3 months ago
  • 13.8.0                                ...           3 months ago
  • 13.7.0                                ...           4 months ago
  • 13.6.0                                ...           5 months ago
  • 13.5.0                                ...           5 months ago
  • 13.4.0                                ...           5 months ago
  • 13.3.0                                ...           6 months ago
  • 13.2.2                                ...           6 months ago
  • 13.2.1                                ...           6 months ago
  • 13.2.0                                ...           6 months ago
  • 13.1.0                                ...           6 months ago
  • 13.0.2                                ...           6 months ago
  • 13.0.1                                ...           6 months ago
  • 13.0.0                                ...           6 months ago
  • 12.21.0                                ...           6 months ago
  • 12.20.0                                ...           6 months ago
  • 12.19.0                                ...           7 months ago
  • 12.18.0                                ...           7 months ago
  • 12.17.0                                ...           7 months ago
  • 12.16.0                                ...           8 months ago
  • 12.15.1                                ...           8 months ago
  • 12.15.0                                ...           8 months ago
  • 12.14.0                                ...           8 months ago
  • 12.13.0                                ...           9 months ago
  • 12.12.0                                ...           9 months ago
  • 12.11.0                                ...           9 months ago
  • 12.10.1                                ...           9 months ago
  • 12.10.0                                ...           9 months ago
  • 12.9.1                                ...           9 months ago
  • 12.9.0                                ...           9 months ago
  • 12.8.0                                ...           9 months ago
  • 12.7.2                                ...           10 months ago
  • 12.7.1                                ...           10 months ago
  • 12.7.0                                ...           10 months ago
  • 12.6.0                                ...           10 months ago
  • 12.5.0                                ...           10 months ago
  • 12.4.0                                ...           a year ago
  • 12.3.0                                ...           a year ago
  • 12.2.1                                ...           a year ago
  • 12.2.0                                ...           a year ago
  • 12.1.0                                ...           a year ago
  • 12.0.1                                ...           a year ago
  • 12.0.0                                ...           a year ago
  • 11.2.0                                ...           a year ago
  • 11.1.0                                ...           a year ago
  • 11.0.0                                ...           2 years ago
  • 10.1.0                                ...           2 years ago
  • 10.0.0                                ...           2 years ago
  • 9.6.0                                ...           2 years ago
  • 9.5.1                                ...           2 years ago
  • 9.5.0                                ...           2 years ago
  • 9.4.0                                ...           2 years ago
  • 9.3.2                                ...           2 years ago
  • 9.3.1                                ...           2 years ago
  • 9.3.0                                ...           2 years ago
  • 9.2.0                                ...           2 years ago
  • 9.1.0                                ...           2 years ago
  • 9.0.0                                ...           2 years ago
  • 8.0.0                                ...           2 years ago
  • 7.5.0                                ...           2 years ago
  • 7.4.0                                ...           2 years ago
  • 7.3.2                                ...           2 years ago
  • 7.3.1                                ...           2 years ago
  • 7.3.0                                ...           2 years ago
  • 7.2.0                                ...           2 years ago
  • 7.1.1                                ...           2 years ago
  • 7.1.0                                ...           2 years ago
  • 7.0.0                                ...           2 years ago

Copyright 2014 - 2016 © taobao.org |