Skip to content
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

fix: do not allow importing dev dependencies from src #316

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,16 @@ module.exports = {
'@npmcli',
...localConfigs,
],
rules: {
'import/no-extraneous-dependencies': ['error', { devDependencies: false }],
},
overrides: [
{
files: ['**/test/**', '.eslintrc.js', '.eslintrc.local.js'],
Copy link
Author

Choose a reason for hiding this comment

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

making an assumption this covers everything that's not considered package src. Not sure if that's actually the case?

Copy link
Member

Choose a reason for hiding this comment

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

The standard that templateOSS sets up is

  "files": [
    "bin/",
    "lib/"
  ],

It's much easier to explicitly specify where the code is than where it isn't. The rule should apply to those two directories and the handful of projects that need to override this can do so.

Copy link
Author

Choose a reason for hiding this comment

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

Ah that’s good to know. Shall I open a pr on the config repo then for these folders?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah let's start there.

Copy link
Member

Choose a reason for hiding this comment

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

My glob is rusty but something like this is what I had in mind to start
"import/no-extraneous-dependencies": ["error", {"devDependencies": ["!lib/**", "!bin/**"]}]

Copy link
Author

Choose a reason for hiding this comment

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

rules: {
// back to default options
'import/no-extraneous-dependencies': ['error', {}],
},
},
],
}
12 changes: 12 additions & 0 deletions lib/content/eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,16 @@ module.exports = {
'@npmcli',
...localConfigs,
],
rules: {
'import/no-extraneous-dependencies': ['error', { devDependencies: false }],
},
overrides: [
{
files: ['**/test/**', '.eslintrc.js', '.eslintrc.local.js'],
rules: {
// back to default options
'import/no-extraneous-dependencies': ['error', {}],
},
},
],
}
72 changes: 72 additions & 0 deletions tap-snapshots/test/apply/source-snapshots.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ module.exports = {
'@npmcli',
...localConfigs,
],
rules: {
'import/no-extraneous-dependencies': ['error', { devDependencies: false }],
},
overrides: [
{
files: ['**/test/**', '.eslintrc.js', '.eslintrc.local.js'],
rules: {
// back to default options
'import/no-extraneous-dependencies': ['error', {}],
},
},
],
}

.github/CODEOWNERS
Expand Down Expand Up @@ -1449,6 +1461,18 @@ module.exports = {
'@npmcli',
...localConfigs,
],
rules: {
'import/no-extraneous-dependencies': ['error', { devDependencies: false }],
},
overrides: [
{
files: ['**/test/**', '.eslintrc.js', '.eslintrc.local.js'],
rules: {
// back to default options
'import/no-extraneous-dependencies': ['error', {}],
},
},
],
}

.github/CODEOWNERS
Expand Down Expand Up @@ -3104,6 +3128,18 @@ module.exports = {
'@npmcli',
...localConfigs,
],
rules: {
'import/no-extraneous-dependencies': ['error', { devDependencies: false }],
},
overrides: [
{
files: ['**/test/**', '.eslintrc.js', '.eslintrc.local.js'],
rules: {
// back to default options
'import/no-extraneous-dependencies': ['error', {}],
},
},
],
}

workspaces/a/.gitignore
Expand Down Expand Up @@ -3182,6 +3218,18 @@ module.exports = {
'@npmcli',
...localConfigs,
],
rules: {
'import/no-extraneous-dependencies': ['error', { devDependencies: false }],
},
overrides: [
{
files: ['**/test/**', '.eslintrc.js', '.eslintrc.local.js'],
rules: {
// back to default options
'import/no-extraneous-dependencies': ['error', {}],
},
},
],
}

workspaces/b/.gitignore
Expand Down Expand Up @@ -4463,6 +4511,18 @@ module.exports = {
'@npmcli',
...localConfigs,
],
rules: {
'import/no-extraneous-dependencies': ['error', { devDependencies: false }],
},
overrides: [
{
files: ['**/test/**', '.eslintrc.js', '.eslintrc.local.js'],
rules: {
// back to default options
'import/no-extraneous-dependencies': ['error', {}],
},
},
],
}

workspaces/a/.gitignore
Expand Down Expand Up @@ -4541,6 +4601,18 @@ module.exports = {
'@npmcli',
...localConfigs,
],
rules: {
'import/no-extraneous-dependencies': ['error', { devDependencies: false }],
},
overrides: [
{
files: ['**/test/**', '.eslintrc.js', '.eslintrc.local.js'],
rules: {
// back to default options
'import/no-extraneous-dependencies': ['error', {}],
},
},
],
}

workspaces/b/.gitignore
Expand Down
12 changes: 12 additions & 0 deletions workspace/test-workspace/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,16 @@ module.exports = {
'@npmcli',
...localConfigs,
],
rules: {
'import/no-extraneous-dependencies': ['error', { devDependencies: false }],
},
overrides: [
{
files: ['**/test/**', '.eslintrc.js', '.eslintrc.local.js'],
rules: {
// back to default options
'import/no-extraneous-dependencies': ['error', {}],
},
},
],
}