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

chore: add linting rules #49

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

danielpeintner
Copy link
Member

@danielpeintner danielpeintner commented Aug 7, 2024

Note: I tried to take over the rules/options from node-wot.

However, I removed for now the following rules since they seem to require tsconfig files etc also (can be added later)

  • "@typescript-eslint/prefer-nullish-coalescing": "error",
  • "@typescript-eslint/strict-boolean-expressions": "error",

fixes #46

@danielpeintner
Copy link
Member Author

Running the current code causes some errors which we might want to fix...

> npx eslint . --config .eslintrc.json


D:\Projects\WoT\thingweb\td-tools-danielpeintner\node\async-api-converter\src\genChannels.js
   56:25  error  'scanPropForm' was used before it was defined  @typescript-eslint/no-use-before-define
  116:17  error  'addServer' was used before it was defined     @typescript-eslint/no-use-before-define

D:\Projects\WoT\thingweb\td-tools-danielpeintner\node\async-api-converter\src\mapSecurity.js
   17:5   error  'mapSecurity' was used before it was defined             @typescript-eslint/no-use-before-define
   18:5   error  'mapSecurityString' was used before it was defined       @typescript-eslint/no-use-before-define
   19:5   error  'mapSecurityDefinitions' was used before it was defined  @typescript-eslint/no-use-before-define
   20:5   error  'hasNoSec' was used before it was defined                @typescript-eslint/no-use-before-define
   21:5   error  'mapFormSecurity' was used before it was defined         @typescript-eslint/no-use-before-define
   31:41  error  'mapSecurityDefinitions' was used before it was defined  @typescript-eslint/no-use-before-define
   32:22  error  'mapSecurityString' was used before it was defined       @typescript-eslint/no-use-before-define
   33:34  error  'hasNoSec' was used before it was defined                @typescript-eslint/no-use-before-define
   54:41  error  'mapSecurityDefinitions' was used before it was defined  @typescript-eslint/no-use-before-define
   93:22  error  'mapSecurityString' was used before it was defined       @typescript-eslint/no-use-before-define
   95:34  error  'hasNoSec' was used before it was defined                @typescript-eslint/no-use-before-define
  191:50  error  'genaapDefinition' was used before it was defined        @typescript-eslint/no-use-before-define
  282:35  error  'genOAuthFlows' was used before it was defined           @typescript-eslint/no-use-before-define

D:\Projects\WoT\thingweb\td-tools-danielpeintner\node\async-api-converter\src\utils.js
  29:5  error  'copySpecExtensions' was used before it was defined  @typescript-eslint/no-use-before-define

D:\Projects\WoT\thingweb\td-tools-danielpeintner\node\json-spell-checker\src\index.js
   18:28  error  'configure' was used before it was defined                                                                  @typescript-eslint/no-use-before-define
   19:29  error  'checkTypos' was used before it was defined                                                                 @typescript-eslint/no-use-before-define
   32:25  error  'createSchemaLookupTable' was used before it was defined                                                    @typescript-eslint/no-use-before-define
   45:25  error  'createSchemaLookupTable' was used before it was defined                                                    @typescript-eslint/no-use-before-define
   70:5   error  'searchTypos' was used before it was defined                                                                @typescript-eslint/no-use-before-define
  103:5   error  The body of a for-in should be wrapped in an if statement to filter unwanted properties from the prototype  guard-for-in
  124:21  error  'doesTypoExist' was used before it was defined                                                              @typescript-eslint/no-use-before-define
  148:5   error  'findPathsInSchema' was used before it was defined                                                          @typescript-eslint/no-use-before-define
  190:27  error  'getRefObjectOfSchema' was used before it was defined                                                       @typescript-eslint/no-use-before-define
  208:25  error  'getRefObjectOfSchema' was used before it was defined                                                       @typescript-eslint/no-use-before-define
  233:25  error  'getRefObjectOfSchema' was used before it was defined                                                       @typescript-eslint/no-use-before-define
  256:25  error  'getRefObjectOfSchema' was used before it was defined                                                       @typescript-eslint/no-use-before-define
  267:9   error  'putKeysToPath' was used before it was defined                                                              @typescript-eslint/no-use-before-define
  286:25  error  'getRefObjectOfSchema' was used before it was defined                                                       @typescript-eslint/no-use-before-define
  295:9   error  'putKeysToPath' was used before it was defined                                                              @typescript-eslint/no-use-before-define
  365:24  error  'calculateSimilarity' was used before it was defined                                                        @typescript-eslint/no-use-before-define

D:\Projects\WoT\thingweb\td-tools-danielpeintner\node\open-api-converter\crawlPaths.js
   20:18  error  'crawlPaths' was used before it was defined       @typescript-eslint/no-use-before-define
   53:21  error  'addForm' was used before it was defined          @typescript-eslint/no-use-before-define
   71:17  error  'addForm' was used before it was defined          @typescript-eslint/no-use-before-define
  102:34  error  'extractPath' was used before it was defined      @typescript-eslint/no-use-before-define
  132:23  error  'recognizeMethod' was used before it was defined  @typescript-eslint/no-use-before-define
  146:9   error  'addPaths' was used before it was defined         @typescript-eslint/no-use-before-define

D:\Projects\WoT\thingweb\td-tools-danielpeintner\node\open-api-converter\genInteraction.js
  18:18  error  'genInteraction' was used before it was defined          @typescript-eslint/no-use-before-define
  19:25  error  'genParameters' was used before it was defined           @typescript-eslint/no-use-before-define
  28:30  error  'genInteractionSchemas' was used before it was defined   @typescript-eslint/no-use-before-define
  29:26  error  'addInteractionExamples' was used before it was defined  @typescript-eslint/no-use-before-define
  31:29  error  'genInteractionInfo' was used before it was defined      @typescript-eslint/no-use-before-define
  32:36  error  'genParameters' was used before it was defined           @typescript-eslint/no-use-before-define
  76:25  error  'extractDataSchema' was used before it was defined       @typescript-eslint/no-use-before-define
  77:26  error  'extractDataSchema' was used before it was defined       @typescript-eslint/no-use-before-define
  81:25  error  'extractDataSchema' was used before it was defined       @typescript-eslint/no-use-before-define
  84:26  error  'extractDataSchema' was used before it was defined       @typescript-eslint/no-use-before-define
  89:25  error  'extractDataSchema' was used before it was defined       @typescript-eslint/no-use-before-define

D:\Projects\WoT\thingweb\td-tools-danielpeintner\node\open-api-converter\index.js
  23:18  error  'toOpenAPI' was used before it was defined     @typescript-eslint/no-use-before-define
  44:25  error  'crawlServers' was used before it was defined  @typescript-eslint/no-use-before-define
  50:22  error  'addTags' was used before it was defined       @typescript-eslint/no-use-before-define

D:\Projects\WoT\thingweb\td-tools-danielpeintner\node\open-api-converter\mapSecurity.js
   16:20  error  'mapSecurity' was used before it was defined             @typescript-eslint/no-use-before-define
   16:33  error  'mapSecurityString' was used before it was defined       @typescript-eslint/no-use-before-define
   16:52  error  'mapSecurityDefinitions' was used before it was defined  @typescript-eslint/no-use-before-define
   16:76  error  'hasNoSec' was used before it was defined                @typescript-eslint/no-use-before-define
   16:86  error  'mapFormSecurity' was used before it was defined         @typescript-eslint/no-use-before-define
   25:41  error  'mapSecurityDefinitions' was used before it was defined  @typescript-eslint/no-use-before-define
   26:22  error  'mapSecurityString' was used before it was defined       @typescript-eslint/no-use-before-define
   28:34  error  'hasNoSec' was used before it was defined                @typescript-eslint/no-use-before-define
   49:41  error  'mapSecurityDefinitions' was used before it was defined  @typescript-eslint/no-use-before-define
   88:22  error  'mapSecurityString' was used before it was defined       @typescript-eslint/no-use-before-define
   90:34  error  'hasNoSec' was used before it was defined                @typescript-eslint/no-use-before-define
  188:50  error  'genOapDefinition' was used before it was defined        @typescript-eslint/no-use-before-define
  254:35  error  'genOAuthFlows' was used before it was defined           @typescript-eslint/no-use-before-define

✖ 65 problems (65 errors, 0 warnings)

@danielpeintner
Copy link
Member Author

danielpeintner commented Aug 7, 2024

Note: I also wonder why the CI build runs fine... I assume it should fail 🤷‍♂️

EDIT: It seems to run npm run lint:sarif. Running locally npm run lint shows the errors above

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.

.eslintrc.js Usage
1 participant