From c10622b85d4765ee4c9b427b109cd446d77579d2 Mon Sep 17 00:00:00 2001 From: Robin Kehl Date: Tue, 3 Jan 2023 13:41:04 +0100 Subject: [PATCH] fix: potentially fix vue and react bug --- configs/react/index.js | 8 ++++++-- configs/vue/index.js | 7 +++++-- package-lock.json | 23 +++++++++++++++++++++-- package.json | 3 +++ 4 files changed, 35 insertions(+), 6 deletions(-) diff --git a/configs/react/index.js b/configs/react/index.js index 689ac92..9e91267 100644 --- a/configs/react/index.js +++ b/configs/react/index.js @@ -1,4 +1,8 @@ -module.exports = { +const { isPackageExists } = require('local-pkg') + +const react = isPackageExists('react') + +module.exports = react ? { plugins: [ 'react', 'react-hooks', @@ -115,5 +119,5 @@ module.exports = { }, ], }, -} +} : {} diff --git a/configs/vue/index.js b/configs/vue/index.js index 6024ef9..3fa0e1c 100644 --- a/configs/vue/index.js +++ b/configs/vue/index.js @@ -1,4 +1,7 @@ -module.exports = { +const {isPackageExists} = require("local-pkg"); +const vue = isPackageExists('vue') + +module.exports = vue ? { overrides: [ { files: ['*.vue'], @@ -13,4 +16,4 @@ module.exports = { '@singularit/eslint-config-typescript', ], rules: {}, -} +} : {} diff --git a/package-lock.json b/package-lock.json index fda3946..feee8a3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,6 +11,9 @@ "workspaces": [ "configs/*" ], + "dependencies": { + "local-pkg": "^0.4.2" + }, "devDependencies": { "eslint": "^8.16.0", "semantic-release-monorepo": "^7.0.5", @@ -22,7 +25,7 @@ "version": "1.1.1", "license": "MIT", "dependencies": { - "@singularit/eslint-config-react": "^0.0.1", + "@singularit/eslint-config-react": "*", "@singularit/eslint-config-vue": "^1.1.3", "@typescript-eslint/eslint-plugin": "^5.26.0", "@typescript-eslint/parser": "^5.26.0", @@ -3486,6 +3489,17 @@ "node": ">=4" } }, + "node_modules/local-pkg": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/local-pkg/-/local-pkg-0.4.2.tgz", + "integrity": "sha512-mlERgSPrbxU3BP4qBqAvvwlgW4MTg78iwJdGGnv7kibKjWcJksrG3t6LB5lXI93wXRDvG4NpUgJFmTG4T6rdrg==", + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + } + }, "node_modules/locate-path": { "version": "2.0.0", "license": "MIT", @@ -8753,7 +8767,7 @@ "@singularit/eslint-config": { "version": "file:configs/all", "requires": { - "@singularit/eslint-config-react": "^0.0.1", + "@singularit/eslint-config-react": "*", "@singularit/eslint-config-vue": "^1.1.3", "@typescript-eslint/eslint-plugin": "^5.26.0", "@typescript-eslint/parser": "^5.26.0", @@ -10586,6 +10600,11 @@ } } }, + "local-pkg": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/local-pkg/-/local-pkg-0.4.2.tgz", + "integrity": "sha512-mlERgSPrbxU3BP4qBqAvvwlgW4MTg78iwJdGGnv7kibKjWcJksrG3t6LB5lXI93wXRDvG4NpUgJFmTG4T6rdrg==" + }, "locate-path": { "version": "2.0.0", "requires": { diff --git a/package.json b/package.json index 1e4142e..e266f01 100644 --- a/package.json +++ b/package.json @@ -29,5 +29,8 @@ }, "publishConfig": { "access": "public" + }, + "dependencies": { + "local-pkg": "^0.4.2" } }