1.1.0 • Published 4 years ago

@javiermaestre/eslint-config v1.1.0

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

ESLint configs

This project have presets for ESLint which I use in private projects:

Available configs

  • @javiermaestre/eslint-config/a11y - Accessibility rules from eslint-plugin-jsx-a11y
  • @javiermaestre/eslint-config/core - ESLINT base config from eslint-config-airbnb
  • @javiermaestre/eslint-config/react - Based on React rules of Airbnb
  • @javiermaestre/eslint-config/react-hooks - Based on React Hooks rules of Airbnb
  • @javiermaestre/eslint-config/react-typescript - Based on @typescript-eslint/eslint-plugin

Install

Install as a DEV dependency

yarn add --dev @javiermaestre/eslint-config
npm install --D @javiermaestre/eslint-config

Extend

Extend configs creating a .eslintrc.js or eslintrc.json file on your project:

// eslintrc.js
module.exports = {
  extends: [
    '@javiermaestre/eslint-config/core',
    '@javiermaestre/eslint-config/react',
    '@javiermaestre/eslint-config/react-hooks',
    '@javiermaestre/eslint-config/react-typescript'
  ]
};
// eslintrc.json
{
  "extends": ["@javiermaestre/eslint-config/core", "@javiermaestre/eslint-config/react-typescript"]
}

Also, you can override and customise rules:

Default configs

This are configs ready to use:

  • Config for JS
// eslintrc.js
module.exports = {
  extends: ['@javiermaestre/eslint-config/core']
};
  • Config for Typescript
// eslintrc.js
module.exports = {
  extends: ['@javiermaestre/eslint-config/typescript']
};
  • Config for React
// eslintrc.js
module.exports = {
  extends: [
    '@javiermaestre/eslint-config/react' // React package extends from /core
  ]
};
  • Config for React with Typescript
// eslintrc.js
module.exports = {
  extends: [
    '@javiermaestre/eslint-config/react-typescript' // React Typescript package extends from /react and /core
  ]
};
  • Config for React with Typescript and Hooks
// eslintrc.js
module.exports = {
  extends: [
    '@javiermaestre/eslint-config/react-typescript', // React Typescript package with Hooks extends from /react and /core
    '@javiermaestre/eslint-config/react-hooks'
  ]
};

Extra configuration

The plugin is ready to work with:

  • Prettier - Adding a .prettierrc file
  • Editorconfig - Adding a .editorconfig file

You can override the settings on this files

Run linter

  • For report
eslint --ext .js,.jsx .
  • For auto fixing
eslint --ext .js,.jsx . --fix

Next steps

Add support for:

    // for Node.js projects
    '@javiermaestre/eslint-config/node',

    // for Angular projects
    '@javiermaestre/eslint-config/angular',

    ...