Skip to content

Commit

Permalink
fix: fix empty dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
arianrhodsandlot committed Apr 19, 2024
1 parent 3089b52 commit 7dff921
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 5 deletions.
7 changes: 6 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.10.2] - 2024-04-19
### Fixed
- Fix parse error when there are empty dependencies or dev dependencies

## [0.10.1] - 2024-04-19
### Fixed
- Fix config loading failed when vue is not installed
Expand Down Expand Up @@ -138,7 +142,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- First release!

[unreleased]: https://github.com/arianrhodsandlot/eslint-config/compare/v0.10.1...HEAD
[unreleased]: https://github.com/arianrhodsandlot/eslint-config/compare/v0.10.2...HEAD
[0.9.1]: https://github.com/arianrhodsandlot/eslint-config/compare/v0.10.1...v0.10.2
[0.9.1]: https://github.com/arianrhodsandlot/eslint-config/compare/v0.10.0...v0.10.1
[0.9.1]: https://github.com/arianrhodsandlot/eslint-config/compare/v0.9.1...v0.10.0
[0.9.1]: https://github.com/arianrhodsandlot/eslint-config/compare/v0.9.0...v0.9.1
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@arianrhodsandlot/eslint-config",
"version": "0.10.1",
"version": "0.10.2",
"type": "module",
"description": "A set of predefined ESLint config.",
"main": "dist/umd/index.cjs",
Expand Down
1 change: 1 addition & 0 deletions src/flat-configs/custom/custom-rules/non-compatible.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const eslintMajorVersion = Number.parseInt(Linter.version, 10)
export const nonCompatibleRules: FlatConfigRules =
eslintMajorVersion > 8
? {
'compat/compat': 'off',
'import/first': 'off',
'import/newline-after-import': 'off',
'promise/no-callback-in-promise': 'off',
Expand Down
8 changes: 5 additions & 3 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ export function getPackageVersion(packageName: string) {
for (const packageJson of packageJsons) {
try {
const packageInfo = JSON.parse(fs.readFileSync(packageJson, 'utf8'))
const version: string = packageInfo.dependencies[packageName] || packageInfo.devDependencies[packageName]
if (version) {
return version
if (packageInfo) {
const version: string = packageInfo.dependencies?.[packageName] || packageInfo.devDependencies?.[packageName]
if (version) {
return version
}
}
} catch {}
}
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"extends": "@tsconfig/node-lts",
"include": ["src"],
"exclude": ["eslint.config.mjs", "dist", "tests"],
"compilerOptions": {
"outDir": "dist/types",
Expand Down

0 comments on commit 7dff921

Please sign in to comment.