Skip to content

Fix lint errors and enable lint in CI #345

@microbit-matt-hillsdon

Description

@microbit-matt-hillsdon

npm run lint fails - I'm not convinced it has passed any time recently.

Please can we run it in CI and either fix/ignore the errors or adjust the rules to suit the team?

If you're happy with the existing rules I can take a first pass through fixing and flag controversial bits here. It seems likely to mostly be uncontroversial fixes except for a few places where some Blockly naming conventions appear to differ from the rules. I think it would make sense to ignore those rules on a file or line basis in a first pass.

I tend to have eslint diagnostics enabled in my editor and find all the lint errors distract me from the new errors I'm introducing 😄

ASTNode createXXX return type

There's an annoyingly prevalent pattern of a non-null assertion (not allowed by the rules) in code like ASTNode.createBlockNode(newBlock)! that could do with a separate fix. Why can it (and similar, but mainly this one in practice) return null? The implementation seems to be undecided about its types:

  static createBlockNode(block: Block): ASTNode | null {
    if (!block) {
      return null;
    }
    return new ASTNode(ASTNode.types.BLOCK, block);
  }

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions