charlierudolph / dependency-lint

Lints NPM dependencies and devDependencies
MIT License
14 stars 6 forks source link

Always errors #53

Open andrearx opened 5 years ago

andrearx commented 5 years ago

Hi, I'm using it on windows, installed globally.

D:\MyProject>npm install -g dependency-lint
C:\Users\<pcUser>\AppData\Roaming\npm\dependency-lint -> C:\Users\<pcUser>\AppData\Roaming\npm\node_modules\dependency-lint\bin\dependency-lint.js
+ dependency-lint@6.0.0
added 45 packages from 35 contributors in 4.64s

D:\MyProject>dependency-lint --generate-config
Configuration file generated at "dependency-lint.yml"

D:\MyProject>dependency-lint
SyntaxError: index.js: 'return' outside of function (5:3)
    at Object.raise (C:\Users\<pcUser>\AppData\Roaming\npm\node_modules\dependency-lint\node_modules\@babel\parser\lib\index.js:6322:17)
    at Object.parseReturnStatement (C:\Users\<pcUser>\AppData\Roaming\npm\node_modules\dependency-lint\node_modules\@babel\parser\lib\index.js:10124:12)
    at Object.parseStatementContent (C:\Users\<pcUser>\AppData\Roaming\npm\node_modules\dependency-lint\node_modules\@babel\parser\lib\index.js:9811:21)
    at Object.parseStatement (C:\Users\<pcUser>\AppData\Roaming\npm\node_modules\dependency-lint\node_modules\@babel\parser\lib\index.js:9763:17)
    at Object.parseStatement (C:\Users\<pcUser>\AppData\Roaming\npm\node_modules\dependency-lint\node_modules\@babel\parser\lib\index.js:2019:26)
    at Object.parseBlockOrModuleBlockBody (C:\Users\<pcUser>\AppData\Roaming\npm\node_modules\dependency-lint\node_modules\@babel\parser\lib\index.js:10340:25)
    at Object.parseBlockBody (C:\Users\<pcUser>\AppData\Roaming\npm\node_modules\dependency-lint\node_modules\@babel\parser\lib\index.js:10327:10)
    at Object.parseBlock (C:\Users\<pcUser>\AppData\Roaming\npm\node_modules\dependency-lint\node_modules\@babel\parser\lib\index.js:10311:10)
    at Object.parseStatementContent (C:\Users\<pcUser>\AppData\Roaming\npm\node_modules\dependency-lint\node_modules\@babel\parser\lib\index.js:9839:21)
    at Object.parseStatement (C:\Users\<pcUser>\AppData\Roaming\npm\node_modules\dependency-lint\node_modules\@babel\parser\lib\index.js:9763:17)
    at Object.parseStatement (C:\Users\<pcUser>\AppData\Roaming\npm\node_modules\dependency-lint\node_modules\@babel\parser\lib\index.js:2019:26)
    at Object.parseIfStatement (C:\Users\<pcUser>\AppData\Roaming\npm\node_modules\dependency-lint\node_modules\@babel\parser\lib\index.js:10117:28)
    at Object.parseStatementContent (C:\Users\<pcUser>\AppData\Roaming\npm\node_modules\dependency-lint\node_modules\@babel\parser\lib\index.js:9808:21)
    at Object.parseStatement (C:\Users\<pcUser>\AppData\Roaming\npm\node_modules\dependency-lint\node_modules\@babel\parser\lib\index.js:9763:17)
    at Object.parseStatement (C:\Users\<pcUser>\AppData\Roaming\npm\node_modules\dependency-lint\node_modules\@babel\parser\lib\index.js:2019:26)
    at Object.parseBlockOrModuleBlockBody (C:\Users\<pcUser>\AppData\Roaming\npm\node_modules\dependency-lint\node_modules\@babel\parser\lib\index.js:10340:25)

D:\MyProject>cd webapp

D:\MyProject\webapp>dependency-lint
SyntaxError: myfolder/myfile.js: 'import' and 'export' may appear only with 'sourceType: module' (1:0)
    at _class.pp$4.raise (C:\Users\<pcUser>\AppData\Roaming\npm\node_modules\dependency-lint\node_modules\acorn\dist\acorn.js:2844:13)
    at _class.pp$1.parseStatement (C:\Users\<pcUser>\AppData\Roaming\npm\node_modules\dependency-lint\node_modules\acorn\dist\acorn.js:859:16)
    at _class.parseStatement (C:\Users\<pcUser>\AppData\Roaming\npm\node_modules\dependency-lint\node_modules\acorn-dynamic-import\lib\index.js:63:118)
    at _class.pp$1.parseTopLevel (C:\Users\<pcUser>\AppData\Roaming\npm\node_modules\dependency-lint\node_modules\acorn\dist\acorn.js:749:23)
    at _class.parse (C:\Users\<pcUser>\AppData\Roaming\npm\node_modules\dependency-lint\node_modules\acorn\dist\acorn.js:552:15)
    at Function.parse (C:\Users\<pcUser>\AppData\Roaming\npm\node_modules\dependency-lint\node_modules\acorn\dist\acorn.js:575:35)
    at Object.parse (C:\Users\<pcUser>\AppData\Roaming\npm\node_modules\dependency-lint\node_modules\acorn-node\index.js:26:28)
    at parse (C:\Users\<pcUser>\AppData\Roaming\npm\node_modules\dependency-lint\node_modules\detective\index.js:22:18)
    at Function.exports.find (C:\Users\<pcUser>\AppData\Roaming\npm\node_modules\dependency-lint\node_modules\detective\index.js:47:15)
    at module.exports (C:\Users\<pcUser>\AppData\Roaming\npm\node_modules\dependency-lint\node_modules\detective\index.js:26:20)
    at RequiredModuleFinder.findInFile (C:\Users\<pcUser>\AppData\Roaming\npm\node_modules\dependency-lint\dist\linter\used_module_finder\required_module_finder.js:94:53)

The proj works perfectly. 1st run is an electron proj 2nd a react proj

I don't understaand if i can set this plugin ignoring those errors and how. Thanks

charlierudolph commented 3 years ago

The stack traces point to files and have line numbers:

SyntaxError: index.js: 'return' outside of function (5:3) -> Thus D:\MyProject\index.js line 5 has the syntax error reported

SyntaxError: myfolder/myfile.js: 'import' and 'export' may appear only with 'sourceType: module' (1:0) -> Thus D:\MyProject\webapp\myfolder\myfile.js line 1 has the syntax error reported.

These errors come from failed parsing of the files. I'll look at updating the code so the thrown error has more context.