'What is the preferred way to have multiple 'ESLint' Shareable Configs as NPM Library?
Overview
I want to create an NPM Library that contains my EsLint Sharable configs. In total, there are 9 shareable configs:
- eslintConfigImportExport.ts
- eslintConfigJest.ts
- eslintConfigJSX.ts
- eslintConfigReact.ts
- eslintConfigReactNative.ts
- eslintConfigStandard.ts
- eslintConfigTailwindCSS.ts
- eslintConfigTestingLibrary.ts
- eslintConfigTypeScript.ts
Exporting The Configs
If I want to create a shareable config that exports all in from an index file such as:
// Exports: EsLint Configs
export { eslintConfigImportExport } from './configs/eslintConfigImportExport';
export { eslintConfigJest } from './configs/eslintConfigJest';
export { eslintConfigJSX } from './configs/eslintConfigJSX';
export { eslintConfigReact } from './configs/eslintConfigReact';
export { eslintConfigReactNative } from './configs/eslintConfigReactNative';
export { eslintConfigStandard } from './configs/eslintConfigStandard';
export { eslintConfigTailwindCSS } from './configs/eslintConfigTailwindCSS';
export { eslintConfigTestingLibrary } from './configs/eslintConfigTestingLibrary';
export { eslintConfigTypeScript } from './configs/eslintConfigTypeScript';
Dependencies
"peerDependencies": {
"eslint": ">=8.12.0",
"eslint-plugin-import": ">=2.25.4",
"eslint-plugin-jest": ">=26.1.3",
"eslint-plugin-jsx-a11y": ">=6.5.1",
"eslint-plugin-react": ">=7.29.4",
"eslint-plugin-react-hooks": ">=4.4.0",
"eslint-plugin-react-native": ">=4.0.0",
"eslint-plugin-simple-import-sort": ">=7.0.0",
"eslint-plugin-tailwindcss": ">=3.5.0",
"eslint-plugin-testing-library": ">=5.2.0"
},
Question
What is would be the preferred method to export and import these shareable configs? Some projects may just use on shareable config, while others may use 4, or 7, and etc.
- Would it be best to have all
EsLintshareable configs in one repo/NPM Library? - Should I add all dependencies as
peerDependencies? Or will that be an issue for a React project not needing a package for exampleeslint-plugin-react-native? Will that be an issue if when trying to build and it has to resolve allpeerDependencies?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
