From 326e2812bc2267f389a8e5ecfda8db64e30dd384 Mon Sep 17 00:00:00 2001
From: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com>
Date: Mon, 28 Oct 2024 13:31:13 -0500
Subject: [PATCH 1/2] fix!: dep-check tsx and jsx (#1661)
Adds configuration to dependency-check command to check for unused dependencies properly in jsx & tsx files.
BREAKING CHANGE: `.tsx` and `.jsx` files are now checked for missing/unused dependencies
---
src/dependency-check.js | 2 ++
test/dependency-check.js | 36 +++++++++++++++++++
.../dependency-check/jsx-fail/package.json | 13 +++++++
.../dependency-check/jsx-fail/src/index.jsx | 10 ++++++
.../dependency-check/jsx-pass/package.json | 12 +++++++
.../dependency-check/jsx-pass/src/index.jsx | 10 ++++++
.../dependency-check/tsx-fail/package.json | 13 +++++++
.../dependency-check/tsx-fail/src/index.tsx | 8 +++++
.../dependency-check/tsx-pass/package.json | 12 +++++++
.../dependency-check/tsx-pass/src/index.tsx | 8 +++++
tsconfig.json | 3 +-
11 files changed, 126 insertions(+), 1 deletion(-)
create mode 100644 test/fixtures/dependency-check/jsx-fail/package.json
create mode 100644 test/fixtures/dependency-check/jsx-fail/src/index.jsx
create mode 100644 test/fixtures/dependency-check/jsx-pass/package.json
create mode 100644 test/fixtures/dependency-check/jsx-pass/src/index.jsx
create mode 100644 test/fixtures/dependency-check/tsx-fail/package.json
create mode 100644 test/fixtures/dependency-check/tsx-fail/src/index.tsx
create mode 100644 test/fixtures/dependency-check/tsx-pass/package.json
create mode 100644 test/fixtures/dependency-check/tsx-pass/src/index.tsx
diff --git a/src/dependency-check.js b/src/dependency-check.js
index b0316e09d..964fa7d82 100644
--- a/src/dependency-check.js
+++ b/src/dependency-check.js
@@ -41,7 +41,9 @@ const tasks = new Listr(
const productionOnlyResult = await depcheck(cwd(), {
parsers: {
'**/*.js': depcheck.parser.es6,
+ '**/*.jsx': depcheck.parser.jsx,
'**/*.ts': depcheck.parser.typescript,
+ '**/*.tsx': depcheck.parser.jsx,
'**/*.cjs': depcheck.parser.es6,
'**/*.mjs': depcheck.parser.es6
},
diff --git a/test/dependency-check.js b/test/dependency-check.js
index 25df57485..b91735c63 100644
--- a/test/dependency-check.js
+++ b/test/dependency-check.js
@@ -137,4 +137,40 @@ describe('dependency check', () => {
})
).to.eventually.be.fulfilled()
})
+
+ it('should pass for jsx files', async () => {
+ await expect(
+ execa(bin, ['dependency-check'], {
+ cwd: path.join(__dirname, 'fixtures/dependency-check/jsx-pass')
+ })
+ ).to.eventually.be.fulfilled()
+ })
+
+ it('should fail for jsx files', async () => {
+ await expect(
+ execa(bin, ['dependency-check'], {
+ cwd: path.join(__dirname, 'fixtures/dependency-check/jsx-fail')
+ })
+ ).to.eventually.be.rejected()
+ .with.property('message')
+ .that.include('react-icons')
+ })
+
+ it('should pass for tsx files', async () => {
+ await expect(
+ execa(bin, ['dependency-check'], {
+ cwd: path.join(__dirname, 'fixtures/dependency-check/tsx-pass')
+ })
+ ).to.eventually.be.fulfilled()
+ })
+
+ it('should fail for tsx files', async () => {
+ await expect(
+ execa(bin, ['dependency-check'], {
+ cwd: path.join(__dirname, 'fixtures/dependency-check/tsx-fail')
+ })
+ ).to.eventually.be.rejected()
+ .with.property('message')
+ .that.include('react-icons')
+ })
})
diff --git a/test/fixtures/dependency-check/jsx-fail/package.json b/test/fixtures/dependency-check/jsx-fail/package.json
new file mode 100644
index 000000000..8071e1088
--- /dev/null
+++ b/test/fixtures/dependency-check/jsx-fail/package.json
@@ -0,0 +1,13 @@
+{
+ "name": "jsx-dep-check-fail",
+ "version": "1.0.0",
+ "main": "index.jsx",
+ "type": "module",
+ "dependencies": {
+ "react": "18.3.1",
+ "react-icons": "5.3.0"
+ },
+ "devDependencies": {
+ "@types/react": "^18.3.12"
+ }
+}
diff --git a/test/fixtures/dependency-check/jsx-fail/src/index.jsx b/test/fixtures/dependency-check/jsx-fail/src/index.jsx
new file mode 100644
index 000000000..8b6a61cae
--- /dev/null
+++ b/test/fixtures/dependency-check/jsx-fail/src/index.jsx
@@ -0,0 +1,10 @@
+// @ts-expect-error - not installed
+// eslint-disable-next-line no-unused-vars
+import React from 'react'
+
+// @ts-expect-error - not installed
+// eslint-disable-next-line no-unused-vars
+const Component = () => (
Hello, world!
)
+const App = () => ()
+
+export default App
diff --git a/test/fixtures/dependency-check/jsx-pass/package.json b/test/fixtures/dependency-check/jsx-pass/package.json
new file mode 100644
index 000000000..41a05c31d
--- /dev/null
+++ b/test/fixtures/dependency-check/jsx-pass/package.json
@@ -0,0 +1,12 @@
+{
+ "name": "jsx-dep-check-fail",
+ "version": "1.0.0",
+ "main": "index.jsx",
+ "type": "module",
+ "dependencies": {
+ "react": "18.3.1"
+ },
+ "devDependencies": {
+ "@types/react": "^18.3.12"
+ }
+}
diff --git a/test/fixtures/dependency-check/jsx-pass/src/index.jsx b/test/fixtures/dependency-check/jsx-pass/src/index.jsx
new file mode 100644
index 000000000..8b6a61cae
--- /dev/null
+++ b/test/fixtures/dependency-check/jsx-pass/src/index.jsx
@@ -0,0 +1,10 @@
+// @ts-expect-error - not installed
+// eslint-disable-next-line no-unused-vars
+import React from 'react'
+
+// @ts-expect-error - not installed
+// eslint-disable-next-line no-unused-vars
+const Component = () => (Hello, world!
)
+const App = () => ()
+
+export default App
diff --git a/test/fixtures/dependency-check/tsx-fail/package.json b/test/fixtures/dependency-check/tsx-fail/package.json
new file mode 100644
index 000000000..20f26afc4
--- /dev/null
+++ b/test/fixtures/dependency-check/tsx-fail/package.json
@@ -0,0 +1,13 @@
+{
+ "name": "tsx-dep-check-fail",
+ "version": "1.0.0",
+ "main": "index.tsx",
+ "type": "module",
+ "dependencies": {
+ "react": "18.3.1",
+ "react-icons": "5.3.0"
+ },
+ "devDependencies": {
+ "@types/react": "^18.3.12"
+ }
+}
diff --git a/test/fixtures/dependency-check/tsx-fail/src/index.tsx b/test/fixtures/dependency-check/tsx-fail/src/index.tsx
new file mode 100644
index 000000000..5526f4682
--- /dev/null
+++ b/test/fixtures/dependency-check/tsx-fail/src/index.tsx
@@ -0,0 +1,8 @@
+// @ts-expect-error - not installed
+import React from 'react'
+
+// @ts-expect-error - not installed
+const Component: React.FC = () => (Hello, world!
)
+const App: React.FC = () => ()
+
+export default App
diff --git a/test/fixtures/dependency-check/tsx-pass/package.json b/test/fixtures/dependency-check/tsx-pass/package.json
new file mode 100644
index 000000000..3cdf71a63
--- /dev/null
+++ b/test/fixtures/dependency-check/tsx-pass/package.json
@@ -0,0 +1,12 @@
+{
+ "name": "tsx-dep-check-pass",
+ "version": "1.0.0",
+ "main": "index.tsx",
+ "type": "module",
+ "dependencies": {
+ "react": "18.3.1"
+ },
+ "devDependencies": {
+ "@types/react": "^18.3.12"
+ }
+}
diff --git a/test/fixtures/dependency-check/tsx-pass/src/index.tsx b/test/fixtures/dependency-check/tsx-pass/src/index.tsx
new file mode 100644
index 000000000..5526f4682
--- /dev/null
+++ b/test/fixtures/dependency-check/tsx-pass/src/index.tsx
@@ -0,0 +1,8 @@
+// @ts-expect-error - not installed
+import React from 'react'
+
+// @ts-expect-error - not installed
+const Component: React.FC = () => (Hello, world!
)
+const App: React.FC = () => ()
+
+export default App
diff --git a/tsconfig.json b/tsconfig.json
index ca16e19bc..81c6de2e1 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -2,7 +2,8 @@
"extends": "./src/config/tsconfig.aegir.json",
"compilerOptions": {
"outDir": "dist",
- "emitDeclarationOnly": true
+ "emitDeclarationOnly": true,
+ "jsx": "preserve"
},
"include": [
"package.json",
From a0db46cdf34b04243fb8a12ccf18da17dce9c61d Mon Sep 17 00:00:00 2001
From: semantic-release-bot
Date: Mon, 28 Oct 2024 18:39:00 +0000
Subject: [PATCH 2/2] chore(release): 45.0.0 [skip ci]
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
## [45.0.0](https://github.com/ipfs/aegir/compare/v44.1.4...v45.0.0) (2024-10-28)
### ⚠ BREAKING CHANGES
* `.tsx` and `.jsx` files are now checked for missing/unused dependencies
### Bug Fixes
* dep-check tsx and jsx ([#1661](https://github.com/ipfs/aegir/issues/1661)) ([326e281](https://github.com/ipfs/aegir/commit/326e2812bc2267f389a8e5ecfda8db64e30dd384))
---
CHANGELOG.md | 10 ++++++++++
package.json | 2 +-
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 21e47d407..ea7267ee8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,13 @@
+## [45.0.0](https://github.com/ipfs/aegir/compare/v44.1.4...v45.0.0) (2024-10-28)
+
+### ⚠ BREAKING CHANGES
+
+* `.tsx` and `.jsx` files are now checked for missing/unused dependencies
+
+### Bug Fixes
+
+* dep-check tsx and jsx ([#1661](https://github.com/ipfs/aegir/issues/1661)) ([326e281](https://github.com/ipfs/aegir/commit/326e2812bc2267f389a8e5ecfda8db64e30dd384))
+
## [44.1.4](https://github.com/ipfs/aegir/compare/v44.1.3...v44.1.4) (2024-10-11)
### Bug Fixes
diff --git a/package.json b/package.json
index 5093f3db5..60e32aae3 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "aegir",
- "version": "44.1.4",
+ "version": "45.0.0",
"description": "JavaScript project management",
"license": "Apache-2.0 OR MIT",
"homepage": "https://github.com/ipfs/aegir#readme",