eslint-config-standard

repository·master·Indexed 25 days ago

https://github.com/standard/eslint-config-standard

ESLint shareable configuration for JavaScript Standard Style. It provides a flat configuration object for advanced users to integrate Standard Style rules, including ECMAScript 2022, JSX support, and plugins such as eslint-plugin-n, eslint-plugin-import, and eslint-plugin-promise.

Tokens
1.2K
Snippets
3
Records
6
Agent score
33%

What's inside eslint-config-standard

  1. Configure ESLint with eslint-config-standard

    master

    This package exports a flat ESLint configuration. To use it, import the configuration in your eslint.config.js file and include it in the exported array. You can add your own overrides after the standard configuration object.

    const standard = require('eslint-config-standard')
    
    module.exports = [
        standard,
        {
          // your overrides here
        }
    ]
  2. Use eslint-config-standard in eslint.config.js

    master

    The eslint-config-standard package exports a Flat Config object compatible with ESLint's new configuration system. You can import it directly into your eslint.config.js file to apply the StandardJS ruleset to your project.

    This configuration includes:

    • Language Options: ECMAScript 2022, module source type, and JSX support.
    • Globals: ES2021, Node.js, and browser globals (document, navigator, window).
    • Plugins: eslint-plugin-n, eslint-plugin-import, and eslint-plugin-promise.
    • Rules: A comprehensive set of rules enforcing the StandardJS style (e.g., no semicolons, 2-space indentation, single quotes).
  3. Add Standard Style badges to your README

    master

    If your project uses the standard style, you can include one of these badges in your README to inform users:

    Option 1:

    [![js-standard-style](https://cdn.rawgit.com/standard/standard/master/badge.svg)](http://standardjs.com)

    Option 2:

    [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com)
  4. Reference the eslint-config-standard ruleset

    master

    The following rules are defined within the eslint-config-standard configuration. Note that many rules are configured with specific options to enforce the StandardJS style guide.

    // Core ESLint Rules (Selected Examples)
    'no-var': 'warn',
    'object-shorthand': ['warn', 'properties'],
    'array-bracket-spacing': ['error', 'never'],
    'brace-style': ['error', '1tbs', { allowSingleLine: true }],
    'camelcase': ['error', { allow: ['^UNSAFE_'], properties: 'never', ignoreGlobals: true }],
    'comma-dangle': ['error', { arrays: 'never', objects: 'never', imports: 'never', exports: 'never', functions: 'never' }],
    'indent': ['error', 2, { /* ... extensive JSX/TemplateLiteral exclusions ... */ }],
    'quotes': ['error', 'single', { avoidEscape: true, allowTemplateLiterals: false }],
    'semi': ['error', 'never'],
    
    // eslint-plugin-import rules
    'import/export': 'error',
    'import/first': 'error',
    'import/no-absolute-path': ['error', { esmodule: true, commonjs: true, amd: false }],
    'import/no-duplicates': 'error',
    'import/no-named-default': 'error',
    'import/no-webpack-loader-syntax': 'error',
    
    // eslint-plugin-n rules
    'n/handle-callback-err': ['error', '^(err|error)$'],
    'n/no-callback-literal': 'error',
    'n/no-deprecated-api': 'error',
    'n/no-exports-assign': 'error',
    'n/no-new-require': 'error',
    'n/no-path-concat': 'error',
    'n/process-exit-as-throw': 'error',
    
    // eslint-plugin-promise rules
    'promise/param-names': 'error'