-
Notifications
You must be signed in to change notification settings - Fork 163
👷 fix MODULE_TYPELESS_PACKAGE_JSON warning #3906
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
Changes from all commits
d9b2156
656b69b
20a1fd9
af1f500
c35b530
67699e4
1f834b4
b000aac
834067a
581f460
e44f9de
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,15 @@ | ||
| const path = require('path') | ||
| const { minimatch } = require('minimatch') | ||
| const resolve = require('eslint-module-utils/resolve').default | ||
| const moduleVisitor = require('eslint-module-utils/moduleVisitor').default | ||
| const importType = require('eslint-plugin-import/lib/core/importType').default | ||
| import path from 'node:path' | ||
| import { minimatch } from 'minimatch' | ||
|
|
||
| module.exports = { | ||
| import resolvePackage from 'eslint-module-utils/resolve.js' | ||
| import moduleVisitorPackage from 'eslint-module-utils/moduleVisitor.js' | ||
| import importTypePackage from 'eslint-plugin-import/lib/core/importType.js' | ||
|
|
||
| const moduleVisitor = moduleVisitorPackage.default | ||
| const importType = importTypePackage.default | ||
| const resolve = resolvePackage.default | ||
|
Comment on lines
+4
to
+10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The refactor to ESM imports replaces Useful? React with 👍 / 👎.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these modules are weird, we need the
Comment on lines
+4
to
+10
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❓ question: Not from this PR, but are we using internals here?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it seems so
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not internal, it's actual public exports: https://github.com/import-js/eslint-plugin-import/blob/01c9eb04331d2efa8d63f2d7f4bfec3bc44c94f3/utils/package.json#L9-L38
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, maybe |
||
|
|
||
| export default { | ||
| meta: { | ||
| docs: { | ||
| description: | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,6 +1,6 @@ | ||||||
| const path = require('path') | ||||||
| import path from 'path' | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would that work for you if I fix these in a separate PR using import/enforce-node-protocol-usage? there is a lot more than these few instances.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wip: #3943 |
||||||
|
|
||||||
| module.exports = { | ||||||
| export default { | ||||||
| meta: { | ||||||
| docs: { | ||||||
| description: | ||||||
|
|
@@ -22,7 +22,7 @@ module.exports = { | |||||
| }, | ||||||
| } | ||||||
|
|
||||||
| const packagesRoot = path.resolve(__dirname, '..', 'packages') | ||||||
| const packagesRoot = path.resolve(import.meta.dirname, '..', 'packages') | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The rule now resolves Useful? React with 👍 / 👎.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we use node 24 |
||||||
|
|
||||||
| // Those modules are known to have side effects when evaluated | ||||||
| const pathsWithSideEffect = new Set([ | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| module.exports = { | ||
| export default { | ||
| meta: { | ||
| docs: { | ||
| description: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,12 @@ | ||
| const fs = require('fs') | ||
| const moduleVisitor = require('eslint-module-utils/moduleVisitor').default | ||
| const importType = require('eslint-plugin-import/lib/core/importType').default | ||
| const pkgUp = require('eslint-module-utils/pkgUp').default | ||
| import fs from 'node:fs' | ||
|
|
||
| import moduleVisitorPackage from 'eslint-module-utils/moduleVisitor.js' | ||
| import importTypePackage from 'eslint-plugin-import/lib/core/importType.js' | ||
| import pkgUpPackage from 'eslint-module-utils/pkgUp.js' | ||
|
|
||
| const moduleVisitor = moduleVisitorPackage.default | ||
| const pkgUp = pkgUpPackage.default | ||
| const importType = importTypePackage.default | ||
|
Comment on lines
+3
to
+9
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Similar to the protected-directory rule, these helpers are now imported via Useful? React with 👍 / 👎. |
||
|
|
||
| // The import/no-extraneous-dependencies rule cannot catch this issue[1] where we imported an | ||
| // aliased package in production code, because it resolves[2] the alias to the real package name, and | ||
|
|
@@ -15,7 +20,7 @@ const pkgUp = require('eslint-module-utils/pkgUp').default | |
|
|
||
| const packageJsonCache = new Map() | ||
|
|
||
| module.exports = { | ||
| export default { | ||
| meta: { | ||
| docs: { | ||
| description: 'Forbids importing non-prod dependencies in prod files', | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❓ question: I remember seeing an explanation for this in Slack. How can we keep the explanation in the codebase so we don't forget why we need this as private?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Indeed this is a bit of a hack, but this PR already improve things and we can always review the e2e test to not rely on these cjs file later. I can't add comment to a |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| "private": true | ||
| } |
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,12 +1,12 @@ | ||||||
| const os = require('os') | ||||||
| import os from 'os' | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| function getIp() { | ||||||
| return Object.values(os.networkInterfaces()) | ||||||
| export function getIp() { | ||||||
| return (Object.values(os.networkInterfaces()) as os.NetworkInterfaceInfo[][]) | ||||||
| .flat() | ||||||
| .find(({ family, internal }) => family === 'IPv4' && !internal).address | ||||||
| .find(({ family, internal }) => family === 'IPv4' && !internal)!.address | ||||||
| } | ||||||
|
|
||||||
| function getBuildInfos() { | ||||||
| export function getBuildInfos() { | ||||||
| const ciInfos = getCIInfos() | ||||||
| if (ciInfos) { | ||||||
| return ciInfos | ||||||
|
|
@@ -17,8 +17,8 @@ function getBuildInfos() { | |||||
| } | ||||||
| } | ||||||
|
|
||||||
| function getRunId() { | ||||||
| return process.env.CI_JOB_ID || process.env.USER | ||||||
| export function getRunId() { | ||||||
| return process.env.CI_JOB_ID || process.env.USER || 'n/a' | ||||||
| } | ||||||
|
|
||||||
| function getCIInfos() { | ||||||
|
|
@@ -32,24 +32,16 @@ function getLocalInfos() { | |||||
| return `${process.env.USER} ${new Date().toLocaleString()}` | ||||||
| } | ||||||
|
|
||||||
| function getTestReportDirectory() { | ||||||
| export function getTestReportDirectory() { | ||||||
| if (process.env.CI_JOB_NAME) { | ||||||
| return `test-report/${process.env.CI_JOB_NAME}` | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| function getCoverageReportDirectory() { | ||||||
| export function getCoverageReportDirectory() { | ||||||
| if (process.env.CI_JOB_NAME) { | ||||||
| return `coverage/${process.env.CI_JOB_NAME}` | ||||||
| } | ||||||
|
|
||||||
| return 'coverage' | ||||||
| } | ||||||
|
|
||||||
| module.exports = { | ||||||
| getRunId, | ||||||
| getBuildInfos, | ||||||
| getIp, | ||||||
| getTestReportDirectory, | ||||||
| getCoverageReportDirectory, | ||||||
| } | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.