unconfigured-eslint-rules

7.0.0 • Public • Published

unconfigured-eslint-rules

npm version GitHub Actions codecov

Detect unconfigured ESLint rules

/*
    ./eslintrc.js:
 
    module.exports = {
      rules: {
        'no-alert': 'error',
        'no-array-constructor': 'warn',
        'no-bitwise': 'off',
        'linebreak-style': ['error', "unix"],
      }
    }
*/
 
const unconfiguredESLintRules = require('unconfigured-eslint-rules');
const unconfigured = unconfiguredESLintRules(); //=> ['no-caller', 'no-catch-shadow', 'no-class-assign', ...]
 
unconfigured.includes('no-alert'); //=> false
unconfigured.includes('no-array-constructor'); //=> false
unconfigured.includes('no-bitwise'); //=> false
unconfigured.includes('linebreak-style'); //=> false

This module is designed to help developing sharable configs. When a developer updates ESLint and the latest version introduces new rules, unconfiguredESLintRules().length increases and they'll notice those new rules. @shinnn/eslint-config provides a real world example of this approach.

Installation

Use npm.

npm install unconfigured-eslint-rules

API

const unconfiguredEslintRules = require('unconfigured-eslint-rules');

unconfiguredEslintRules([options])

options: Object (ESLint CLIEngine constructor options)
Return: string[]

The API is the same as configured-eslint-rules', but returns the inverse – an Array of rule names with no rule configurations.

/*
    ./my-dir/.eslintrc.json:
 
    {
      "rules": {
        "semi": ["error", "always"]
      }
    }
*/
 
unconfiguredEslintRules().includes('semi'); //=> true
 
process.chdir('my-dir');
 
unconfiguredEslintRules().includes('semi'); //=> false

The argument will be directly passed to the underlying CLIEngine constructor and affects the result.

/*
    ./eslintrc.yml:
 
    rules:
      eqeqeq: warn
*/
 
unconfiguredEslintRules({}).includes('curly'); //=> false
unconfiguredEslintRules({rules: {curly: 'warn'}}).includes('curly'); //=> true

License

ISC License © 2018 - 2019 Watanabe Shinnosuke

Package Sidebar

Install

npm i unconfigured-eslint-rules

Weekly Downloads

10

Version

7.0.0

License

ISC

Unpacked Size

5.75 kB

Total Files

4

Last publish

Collaborators

  • shinnn