Skip to content

fix: show type on invalid semver error #559

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
May 12, 2023
Merged
Prev Previous commit
Next Next commit
chore: use eslint plugin for preventing externals/builtins
  • Loading branch information
tjenkinson committed May 5, 2023
commit 3cfdf1e9ca3cdeb13be70be24246c4968f150c03
27 changes: 27 additions & 0 deletions .eslintrc.local.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
'use strict'

module.exports = {
plugins: ['import'],
rules: {
'import/no-extraneous-dependencies': [
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this may not be required. checking

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yep. I think this config is useful though? The default would allow importing from devDependencies

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file is already imported as a plugin, so the extra dependency isn't needed. I think a single new rule is all we need here with an allow of ./test and map.js.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then this needs to be addressed in template-oss, that's not a rule that we'd want to only apply to a single one of our over 80 repos.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wraithgar so given this doesn't follow the standard structure npm/eslint-config#67 doesn't have any effect here, so is the custom config in this PR good to go?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah we'll need a custom config but this one looks to be a bit different in approach than the one we landed on in eslint-config. We should pattern it after the one there but instead of lib and bin it should be bin, classes, functions, internal, and ranges (and now we begin to see why we standardized on lib).

The way this PR currently does it is by completely bypassing the no-extraneous-dependencies rule for the test files, which is a regression.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. done!

'error',
{
devDependencies: false,
optionalDependencies: false,
peerDependencies: false,
bundledDependencies: false,
includeInternal: true,
},
],
'import/no-nodejs-modules': ['error'],
},
overrides: [
{
files: ['**/test/**', '.eslintrc.js', '.eslintrc.local.js'],
rules: {
'import/no-extraneous-dependencies': 0,
'import/no-nodejs-modules': 0,
},
},
],
}
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,3 @@
!/SECURITY.md
!/tap-snapshots/
!/test/
!/rollup.config.js
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
"description": "The semantic version parser used by npm.",
"main": "index.js",
"scripts": {
"test": "tap && npm run check-self-contained",
"test": "tap",
"snap": "tap",
"check-self-contained": "rollup -c --silent > /dev/null",
"lint": "eslint \"**/*.js\"",
"postlint": "template-oss-check",
"lintfix": "npm run lint -- --fix",
Expand All @@ -16,8 +15,7 @@
"devDependencies": {
"@npmcli/eslint-config": "^4.0.0",
"@npmcli/template-oss": "4.14.1",
"@rollup/plugin-commonjs": "^24.1.0",
"rollup": "^3.21.5",
"eslint-plugin-import": "^2.27.5",
"tap": "^16.0.0"
},
"license": "ISC",
Expand Down
22 changes: 0 additions & 22 deletions rollup.config.js

This file was deleted.

2 changes: 1 addition & 1 deletion test/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ const ignore = [
'.github',
'.commitlintrc.js',
'.eslintrc.js',
'.eslintrc.local.js',
'node_modules',
'coverage',
'tap-snapshots',
'test',
'fixtures',
'rollup.config.js',
]

const { statSync, readdirSync } = require('fs')
Expand Down