@ken0x0a/eslint-config

Examples of eslint configuration

Usage no npm install needed!

<script type="module">
  import ken0x0aEslintConfig from 'https://cdn.skypack.dev/@ken0x0a/eslint-config';
</script>

README

Install

yarn add @ken0x0a/eslint-config

# if you use `react` configuration, also need to install `@ken0x0a/eslint-config-react-deps`
yarn add @ken0x0a/eslint-config @ken0x0a/eslint-config-react-deps # optional

Usage

module.exports = require('@ken0x0a/eslint-config')

module.exports = {
  extends: ['@ken0x0a/eslint-config'],
}
module.exports = {
  extends: ['@ken0x0a/eslint-config', '@ken0x0a/eslint-config/autofix'],
}

// or if you prefer to pick only what you want ( the following is default )
module.exports = {
  /**
   * NOTE: The **order is important**, to properly override rules by later one
   */
  extends: [
    '@ken0x0a/eslint-config/base',
    '@ken0x0a/eslint-config/tslint-rules',
    '@ken0x0a/eslint-config/import',
    '@ken0x0a/eslint-config/jest',
    // '@ken0x0a/eslint-config/autofix', // DO NOT USE WITH TypeScript, as it doesn't care about `interface` & `type` and remove them.
    // '@ken0x0a/eslint-config/graphql', // requires to install `eslint-plugin-graphql`
    /**
     * if you need to use `react` related configs like following,
     * you need to install optional dependency "@ken0x0a/eslint-config-react-deps" by
     * `yarn add -D "@ken0x0a/eslint-config-react-deps"`
     */
    '@ken0x0a/eslint-config/react',
    // '@ken0x0a/eslint-config/react-native',
    '@ken0x0a/eslint-config/expo', // extends "./react-native"
    '@ken0x0a/eslint-config/typescript',
  ],
}

Command

https://eslint.org/docs/user-guide/command-line-interface

yarn --silent eslint -c .eslintrc.js --ext .ts,.tsx .
yarn --silent eslint --ext .ts,.tsx .
yarn --silent eslint --ext .ts,.tsx --report-unused-disable-directives .
# "--no-error-on-unmatched-pattern" from 3.8.0
yarn --silent eslint --ext .ts,.tsx --report-unused-disable-directives --no-error-on-unmatched-pattern .
yarn --silent eslint --ext .ts,.tsx --ignore-pattern '**/*.d.ts' --report-unused-disable-directives
yarn --silent eslint '**/*.ts{,x}'
yarn --silent eslint '*.ts{,x}'
yarn --silent eslint --report-unused-disable-directives '*.ts'
yarn --silent eslint --cache '*.ts'
yarn --silent eslint --no-inline-config some-file.ts

husky config

module.exports = {
  '*.{ts,tsx}': [
    /**
     * https://eslint.org/docs/user-guide/command-line-interface#--ignore-pattern
     */
    "eslint --fix --ext .ts,.tsx --ignore-pattern '**/*.d.ts' --report-unused-disable-directives",
    'git add',
  ],
}

NOTE

eslint-plugin-autofix doesn't care interface & type. Thus, really useless with TypeScript