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

False positive for dev dependency listed in jest config #603

Closed
mountEvarus opened this issue Apr 26, 2024 · 2 comments
Closed

False positive for dev dependency listed in jest config #603

mountEvarus opened this issue Apr 26, 2024 · 2 comments
Labels
feature request Feature request good first issue Good for newcomers

Comments

@mountEvarus
Copy link

I am running knip on a TS application with the following knip & jest files:

knip.json

{
  "$schema": "https://unpkg.com/knip@5/schema.json",
  "entry": ["src/server.ts", "src/commands/command.ts", "test/**/*.ts", "!test/mocks/**/*"],
  "paths": {
    "@/src/*": ["./src/*"],
    "@/test/*": ["./test/*"]
  },
  "project": ["src/**/*.ts", "test/**/*.ts"],
  "husky": {
    "config": [".husky/pre-commit"]
  },
  "prettier": {
    "config": [".prettierrc"]
  },
  "eslint": {
    "config": [".eslintrc"]
  },
  "jest": {
    "config": ["jest.config.js"]
  },
  "ignoreDependencies": ["@instana/collector", "@side/jest-runtime"]
}

jest.config.js

const { pathsToModuleNameMapper } = require('ts-jest');
const { compilerOptions } = require('./tsconfig.json');

module.exports = {
  transform: {
    '^.+\\.ts$': '@swc/jest',
  },
  clearMocks: true,
  runtime: '@side/jest-runtime',
  testEnvironment: 'node',
  testPathIgnorePatterns: ['node_modules', 'dist'],
  verbose: false,
  collectCoverage: true,
  coverageReporters: ['clover', 'json', 'lcov', 'text', 'text-summary'],
  globalSetup: '<rootDir>/test/jest/globalSetup.ts',
  globalTeardown: '<rootDir>/test/jest/globalTeardown.ts',
  setupFiles: ['<rootDir>/test/jest/setupTests.ts'],
  moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, { prefix: '<rootDir>/' }),
};

I am getting a false positive, claiming @side/jest-runtime is an unused dev dependency, but is is mentioned in the jest config under the runtime key

@mountEvarus mountEvarus added the bug Something isn't working label Apr 26, 2024
@mountEvarus mountEvarus changed the title Not picking up in jest config False positive for dev dependency listed in jest config Apr 26, 2024
@webpro
Copy link
Collaborator

webpro commented Apr 29, 2024

Thanks for the report, @mountEvarus.

This is the Jest plugin: https://github.com/webpro/knip/blob/main/packages/knip/src/plugins/jest/index.ts

Any chance you're up for a PR? No worries if not!

@webpro webpro added good first issue Good for newcomers feature request Feature request and removed bug Something isn't working labels Apr 29, 2024
@webpro webpro closed this as completed in d766006 Nov 3, 2024
@webpro
Copy link
Collaborator

webpro commented Nov 3, 2024

🚀 This issue has been resolved in v5.36.2. See Release 5.36.2 for release notes.

Using Knip in a commercial project? Please consider becoming a sponsor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Feature request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants