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

Add Tokamak project linter #77

Closed
19 of 23 tasks
hodovani opened this issue Mar 28, 2019 · 1 comment
Closed
19 of 23 tasks

Add Tokamak project linter #77

hodovani opened this issue Mar 28, 2019 · 1 comment
Assignees
Labels
API design API design and prototyping is needed

Comments

@hodovani
Copy link
Contributor

hodovani commented Mar 28, 2019

Create command-line util to lint projects that use Tokamak.

Todo:

  • Add Linter.md for linter documentation
  • Verify that SwiftSyntax 0.5 is able to parse the Example project
  • Add lint error Props is not Equatable
  • Add unit-tests to lint functions
  • Add lintFile -> [LintError]
  • Make lintFolder use lintFile
  • Make error output more user readable
  • Fix TokamakLint types access scope: remove public from TokenVisitor, Rule, Reporter, PropsIsEquatableRule
  • Fix TokenVisitor handling of Range, start and end are always equal to each other:
    node.range.startRow = row
    node.range.startColumn = column
    node.range.endRow = row
    node.range.endColumn = column
  • Fix processToken, kind variable is unused:
  private func processToken(_ token: TokenSyntax) {
    var kind = "\(token.tokenKind)"
    if let index = kind.firstIndex(of: "(") {
      kind = String(kind.prefix(upTo: index))
    }
    if kind.hasSuffix("Keyword") {
      kind = "keyword"
    }

    column += token.text.count
  }
  • Fix walkAndGrab, make it private, remove if node.children.count > 0 condition
  • Investigate if SwiftCLI package can be used in TokamakCLI module
  • Rename TokamakCLI to tokamak in Package.swift for Swift 5.0 and 4.2
.executable(name: "tokamak", targets: ["TokamakCLI"])
  • Lint "Only one render in component"
  • One render function rule should check all components, not only hooked components.
  • Lint "Rules of Hooks"
  • Lint "Components can only be declared as structs"
  • Integrate swift-log package
  • Remove direct usage of print, implement configurable output for stdout or files with a custom LogHandler implementation for swift-log

Long-term:

  • Lint "Arguments order"
  • Lint "Unused argument: hooks, children"
  • Lint "Declare non-static properties and functions in component"
  • Lint Rules of Hooks within extensions for all Hooks, not just state
@hodovani hodovani self-assigned this Mar 28, 2019
@MaxDesiatov MaxDesiatov added the API design API design and prototyping is needed label Mar 29, 2019
@MaxDesiatov
Copy link
Collaborator

Closing as outdated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API design API design and prototyping is needed
Development

No branches or pull requests

2 participants