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

feat: add fallback parser #884

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

antongolub
Copy link

@antongolub antongolub commented Feb 20, 2024

This PR provides a support for custom JS/TS-based DSLs / templates which cannot be properly parsed with babel or tsc. In this case, depcheck turns into an unpassable syntax validator, but we still need a dependency checker.

  • The new mode switch is controlled by a flag, and is disabled by default.
  • Parser compatibility with tests is about ~99,45%.
Report
916 passing (2s)
  5 failing

  1) depcheck command line
       should output call stack for invalid files in JSON view:
     AssertionError: expected Object {} to have property '/depcheck/test/fake_modules/bad_js/index.js'
      at Assertion.fail (node_modules/should/cjs/should.js:275:17)
      at Assertion.property (node_modules/should/cjs/should.js:356:19)
      at /depcheck/test/cli.js:151:12

  2) depcheck command line
       should not recognize JSX file when not pass jsx parser:
     AssertionError: expected Array [ 'No depcheck issue' ] to have property length of 2 (got 1)
      at Assertion.fail (node_modules/should/cjs/should.js:275:17)
      at Assertion.length (node_modules/should/cjs/should.js:356:19)
      at /depcheck/test/cli.js:227:24

  3) depcheck command line
       should not recognize JSX file when not enable require detector:
     AssertionError: expected Array [ 'No depcheck issue' ] to have property length of 2 (got 1)
      at Assertion.fail (node_modules/should/cjs/should.js:275:17)
      at Assertion.length (node_modules/should/cjs/should.js:356:19)
      at /depcheck/test/cli.js:241:24

  4) depcheck
       should ignore bad javascript:
     AssertionError: expected Array [] to have property length of 1 (got 0)
      at Assertion.fail (node_modules/should/cjs/should.js:275:17)
      at Assertion.length (node_modules/should/cjs/should.js:356:19)
      at /depcheck/test/index.js:51:32

  5) depcheck
       should use custom detector to find dependencies:

      AssertionError: expected Array [ 'depend-1', 'depend-2', 'depend-3' ] to equal Array [] (at length, A has 3 and B has 0)
      + expected - actual

      -[
      -  "depend-1"
      -  "depend-2"
      -  "depend-3"
      -]
      +[]
      
      at Assertion.fail (node_modules/should/cjs/should.js:275:17)
      at Assertion.deepEqual (node_modules/should/cjs/should.js:356:19)
      at /depcheck/test/index.js:176:34

@antongolub
Copy link
Author

Hey, @rumpl,

Could you help me to move this forward?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant