@runespoorstack/eslint-config v2.1.0
Table of Contents
- Table of Contents
- ✨ Features
- 🦾 Installation
- ♾️ Usage
- 🛠️ Contributing
- 💕 Special Thanks
- ❤️ Support or Donate
✨ Features
- Provides a full, battle tested, ready for production set of Runespoor ESlint configs.
- Well managed system of separated
coreandmixinsconfigs:core/base-jscore/base-tscore/react-jscore/react-tsmixins/prettiermixins/tailwindmixins/jestmixins/vitest,mixins/testing-library-react
- Out of the box
no-restricted-importsrules that will save your time on dealing with bundle size. - The configs are created over the best
eslintplugin and configs:eslint-config-airbnb-baseeslint-config-airbnb@typescript-eslint/parser@typescript-eslint/eslint-plugineslint-plugin-prettiereslint-config-prettiereslint-plugin-jesteslint-plugin-jest-formattingeslint-plugin-importeslint-plugin-simple-import-sorteslint-import-resolver-custom-aliaseslint-plugin-jsx-a11yeslint-plugin-reacteslint-plugin-react-hookseslint-plugin-storybookeslint-plugin-tailwindcsseslint-plugin-testing-libraryeslint-plugin-vitest
🦾 Installation
npm i --save-dev @runespoorstack/eslint-config @rushstack/eslint-config@latest eslint@latest prettier@latest typescript@latest ♾️ Usage
Create .eslintrc.cjs in the root of the project.
Choose the core config
Use a native JavaScript base config:
// This is a workaround for https://github.com/eslint/eslint/issues/3458
require('@rushstack/eslint-config/patch/modern-module-resolution');
module.exports = {
"extends": ["@runespoorstack/eslint-config/core/base-js"]
}Use a TypeScript base config:
// This is a workaround for https://github.com/eslint/eslint/issues/3458
require('@rushstack/eslint-config/patch/modern-module-resolution');
module.exports = {
"extends": ["@runespoorstack/eslint-config/core/base-ts"]
}Use a native React base config:
// This is a workaround for https://github.com/eslint/eslint/issues/3458
require('@rushstack/eslint-config/patch/modern-module-resolution');
module.exports = {
ignorePatterns: ['!.storybook'],
"extends": ["@runespoorstack/eslint-config/core/react-js"]
}Use a TypesScript React base config:
// This is a workaround for https://github.com/eslint/eslint/issues/3458
require('@rushstack/eslint-config/patch/modern-module-resolution');
module.exports = {
ignorePatterns: ['!.storybook'],
"extends": ["@runespoorstack/eslint-config/core/react-ts"]
}Choose a mixins
Use a Prettier mixin:
// This is a workaround for https://github.com/eslint/eslint/issues/3458
require('@rushstack/eslint-config/patch/modern-module-resolution');
module.exports = {
ignorePatterns: ['!.storybook'],
"extends": [
"@runespoorstack/eslint-config/core/react-js",
"@runespoorstack/eslint-config/mixins/prettier"
]
}Use a Tailwind mixin:
// This is a workaround for https://github.com/eslint/eslint/issues/3458
require('@rushstack/eslint-config/patch/modern-module-resolution');
module.exports = {
ignorePatterns: ['!.storybook'],
"extends": [
"@runespoorstack/eslint-config/core/react-ts",
"@runespoorstack/eslint-config/mixins/prettier",
"@runespoorstack/eslint-config/mixins/tailwind"
]
}Use a Jest mixin:
// This is a workaround for https://github.com/eslint/eslint/issues/3458
require('@rushstack/eslint-config/patch/modern-module-resolution');
module.exports = {
ignorePatterns: ['!.storybook'],
"extends": [
"@runespoorstack/eslint-config/core/react-js",
"@runespoorstack/eslint-config/mixins/prettier",
"@runespoorstack/eslint-config/mixins/tailwind",
],
overrides: [
{
files: ['**/*.@(spec|test).[tj]s?(x)'], // or any other pattern
extends: [
'@runespoorstack/eslint-config/mixins/jest'
]
}
]
}Use a Vitest mixin:
// This is a workaround for https://github.com/eslint/eslint/issues/3458
require('@rushstack/eslint-config/patch/modern-module-resolution');
module.exports = {
ignorePatterns: ['!.storybook'],
"extends": [
"@runespoorstack/eslint-config/core/react-js",
"@runespoorstack/eslint-config/mixins/prettier",
"@runespoorstack/eslint-config/mixins/tailwind",
],
overrides: [
{
files: ['**/*.@(spec|test).[tj]s?(x)'], // or any other pattern
extends: [
'@runespoorstack/eslint-config/mixins/vitest'
]
}
]
}Use a Testing Library React mixin:
// This is a workaround for https://github.com/eslint/eslint/issues/3458
require('@rushstack/eslint-config/patch/modern-module-resolution');
module.exports = {
ignorePatterns: ['!.storybook'],
"extends": [
"@runespoorstack/eslint-config/core/react-js",
"@runespoorstack/eslint-config/mixins/prettier",
"@runespoorstack/eslint-config/mixins/tailwind",
],
overrides: [
{
files: ['**/*.@(spec|test).[tj]s?(x)'], // or any other pattern
extends: [
'@runespoorstack/eslint-config/mixins/testing-library-react'
]
}
]
}Add your own rules
// This is a workaround for https://github.com/eslint/eslint/issues/3458
require('@rushstack/eslint-config/patch/modern-module-resolution');
module.exports = {
ignorePatterns: ['!.storybook'],
"extends": [
"@runespoorstack/eslint-config/core/react-js",
"plugin:@tanstack/eslint-plugin-query/recommended"
]
}⚠️ no-restricted-imports overrides
Be careful with adding your own no-restricted-imports rules!
We use a set of predefined restriction rules to protect you from serious mistakes out of the box:
Use default imports from lodash/*.- to save your bundle size.Use custom 'render', 'renderHook' methods.- to cover the 80% usage of these methods (you commonly use only the custom once).Please use default @mui/icons-material/* import instead.- to save your bundle size.Use default imports from @mui/material/<Component>- to save your bundle size. =MUI: Do not use the third level imports- to save your bundle size.
If you define your own no-restricted-imports, all the predefined once would be cleared.
So in case of adding new rules or overriding only the separate rule, you should copy and paste the full no-restricted-imports rule definition from our source code.
⚠️ Linting .storybook folder
Make sure you have remove .storybook from ignore patterns to be able to lint this folder. By default eslint ignore all the .* files.
Use ignorePatterns: ['!.storybook'],
Run eslint
Run eslint check:
eslint . --ext .ts,.tsx,.js,.jsx,.cjs,.mjs --quietRun eslint autofix:
eslint . --ext .ts,.tsx,.js,.jsx,.cjs,.mjs --fix🛠️ Contributing
See the CONTRIBUTING.md document.
💕 Special Thanks
- I want to say thank you to the best woman in the world, my wife Diana for her love, daily support, motivation and inspiration.
❤️ Support or Donate
If you are enjoying this work and feel extra appreciative, you could buy me a book 📖 or 3 📖📖📖.
10 months ago
6 months ago
6 months ago
6 months ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago