sdk-typescript icon indicating copy to clipboard operation
sdk-typescript copied to clipboard

[Feature Request] eslint plugin

Open lorensr opened this issue 3 years ago • 4 comments

Mainly for catching some determinism things at compile time in workflow code, but perhaps there are other things we can do as well.

Shawn Wang 2 hours ago we will probably make an eslint rule eventually but ultimately we are limited by what we can do with static analysis - cant query a module to see if it uses one of the banned Node globals. better to throw a helpful error.

src/workflows/.eslintrc.json

{
    "plugins": [
        "@temporalio",   // @temporalio/eslint-plugin
    ],
    "extends": [
        "plugin:@temporalio/recommended"
    ],
}

lorensr avatar Feb 09 '22 16:02 lorensr

Another option is to use https://semgrep.dev/ which would allows us to centralize on one tool for many langauges rather than something specific per language.

That said I can see an argument for avoiding having users install something else. But, if it's automated/reliable then we might go that direction to reduce the maintenance load.

Sushisource avatar Feb 09 '22 17:02 Sushisource

Currently we recommend no-restricted-imports: https://github.com/temporalio/samples-typescript/blob/b3a106c27086b8db7612016ba681939de221fa3f/hello-world/.eslintrc.js#L41

lorensr avatar May 23 '22 21:05 lorensr

An eslint plugin could also check for async code inside signal handlers. They are risky.

One thing though... A single project generally contains both workflow code and activity code. A temporal eslint plugin would need some way to determine what is workflow code and what isn't. The example eslint config does it by explicitly naming workflow files, but that strategy might be more difficult to apply to user projects.

mjameswh avatar Aug 15 '22 14:08 mjameswh

catching throw Error('...'); in workflows would be an awesome add as well. i was about to start writing a custom rule for that and figured i would check the issues if this was created already and found this.

tommyk avatar Feb 17 '23 23:02 tommyk