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

Open
mountEvarus opened this issue Apr 26, 2024 · 1 comment · May be fixed by #639
Open

False positive for dev dependency listed in jest config #603

mountEvarus opened this issue Apr 26, 2024 · 1 comment · May be fixed by #639
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
Owner

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
@decadef20 decadef20 linked a pull request May 15, 2024 that will close this issue
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