From 67b36a87326402cb50d642e2601e9ae6de126c79 Mon Sep 17 00:00:00 2001 From: Josh Stillman Date: Sat, 28 Sep 2024 15:23:35 -0400 Subject: [PATCH] add eslint-plugin-n support --- README.md | 2 +- .../installDependencies.ts | 4 ++-- src/installDependencies/pinnedVersions.ts | 1 + src/writeConfigs/getEslintConfig.ts | 19 ++++++++++++++++--- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index cd8acee..77d8039 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Lintier's goal is to provide a minimal foundation, allowing you to further custo ## Update for ESLint 9 -As of Fall 2024, the community is still updating various packages to be compatible with ESLint 9. This version of lintier disables currently incompatible packages like [eslint-plugin-react-hooks](https://github.com/facebook/react/issues/28313), [eslint-plugin-node](https://github.com/mysticatea/eslint-plugin-node), and the [airbnb styleguide](https://github.com/airbnb/javascript/issues/2961). +As of Fall 2024, the community is still updating various packages to be compatible with ESLint 9. This version of lintier disables currently incompatible packages like [eslint-plugin-react-hooks](https://github.com/facebook/react/issues/28313) and the [airbnb styleguide](https://github.com/airbnb/javascript/issues/2961). ## Usage diff --git a/src/installDependencies/installDependencies.ts b/src/installDependencies/installDependencies.ts index 77ae7b8..af6e9af 100644 --- a/src/installDependencies/installDependencies.ts +++ b/src/installDependencies/installDependencies.ts @@ -50,7 +50,7 @@ export const installDeps = async ({ export const getDepList = ({ react, - // eslint-disable-next-line @typescript-eslint/no-unused-vars + node, styleLint, sass, @@ -73,7 +73,7 @@ export const getDepList = ({ 'eslint-plugin-prettier', 'globals', 'typescript-eslint', - // ...(node ? ['eslint-plugin-node'] : []), + ...(node ? ['eslint-plugin-n'] : []), ...(react ? ['eslint-plugin-react' /* , 'eslint-plugin-react-hooks' */] : []), diff --git a/src/installDependencies/pinnedVersions.ts b/src/installDependencies/pinnedVersions.ts index c9c104c..39d57ba 100644 --- a/src/installDependencies/pinnedVersions.ts +++ b/src/installDependencies/pinnedVersions.ts @@ -4,6 +4,7 @@ export const PINNED_VERSIONS = { eslint: '9.11.1', 'eslint-config-prettier': '9.1.0', 'eslint-plugin-prettier': '5.2.1', + 'eslint-plugin-n': '17.10.3', 'eslint-plugin-react': '7.36.1', globals: '15.9.0', 'lint-staged': '15.2.10', diff --git a/src/writeConfigs/getEslintConfig.ts b/src/writeConfigs/getEslintConfig.ts index 87ea70e..9330e65 100644 --- a/src/writeConfigs/getEslintConfig.ts +++ b/src/writeConfigs/getEslintConfig.ts @@ -20,6 +20,11 @@ export default tseslint.config( ? ` react.configs.flat.recommended,` : '' + }${ + node + ? ` + nodePlugin.configs['flat/recommended'],` + : '' } eslintPluginPrettierRecommended, { @@ -44,7 +49,6 @@ export default tseslint.config( `; const getImports = ({ - // eslint-disable-next-line @typescript-eslint/no-unused-vars node, react, }: { @@ -55,8 +59,17 @@ const getImports = ({ import eslint from '@eslint/js'; import js from '@eslint/js'; import tseslint from 'typescript-eslint'; -import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'; -${react ? "import react from 'eslint-plugin-react';" : ''} +import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';${ + react + ? ` + import react from 'eslint-plugin-react';` + : '' +}${ + node + ? ` + import nodePlugin from 'eslint-plugin-n';` + : '' +} import globals from 'globals';`; // eslint-disable-next-line @typescript-eslint/no-unused-vars