How to display all JavaScript global variables with static code analysis?

前端 未结 3 1100
忘掉有多难
忘掉有多难 2020-12-22 07:19

I know that I can type into Chrome or FF the following command:

Object.keys(window);

but this displays DHTMLX stuff and also function names in w

3条回答
  •  南方客
    南方客 (楼主)
    2020-12-22 07:54

    I found a very good solution to list all the global variables with the jsl command line tool:

    Here is the documentation

    I just have to put /*jsl:option explicit*/ into each file that I want to check. Then it is enough to run ./jsl -process | grep 'undeclared identifier'

    It is also possible to use referenceFile that contains some intentional global variables /*jsl:import */ so these variables will not be listed.

提交回复
热议问题