'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:

  1. eslintConfigImportExport.ts
  2. eslintConfigJest.ts
  3. eslintConfigJSX.ts
  4. eslintConfigReact.ts
  5. eslintConfigReactNative.ts
  6. eslintConfigStandard.ts
  7. eslintConfigTailwindCSS.ts
  8. eslintConfigTestingLibrary.ts
  9. 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.

  1. Would it be best to have all EsLint shareable configs in one repo/NPM Library?
  2. Should I add all dependencies as peerDependencies? Or will that be an issue for a React project not needing a package for example eslint-plugin-react-native? Will that be an issue if when trying to build and it has to resolve all peerDependencies?


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source