opral / inlang-message-sdk

0 stars 0 forks source link

Figure out how to best configure Lint Rules #102

Open LorisSigrist opened 1 week ago

LorisSigrist commented 1 week ago

Context

Lint rules need a lot of configuration

Open Questions

LorisSigrist commented 1 week ago

After looking at how ESLint handles lint rule configuration:
ESLint uses a combination of pre, and post-filtering for their lint-reports.

Lint rule severity (warn/error) and filter rules are not exposed to the lint-rule. They're purely in ESLint's own config

Visually:

IMG_1034.jpg

As for fixing: Rules return callbacks for fixing the issue as part of the message-report.

context.report({
    node: node, // the AST node where the issue is
    message: "Missing semicolon", // the error-message
    fix(fixer) { //callback to fix it
        return fixer.insertTextAfter(node, ";");
    }
});

IMO this is suboptimal since the callback cannot be passed between worker boundaries, so having the lint process in a separate worker will be inconvenient. We should consider having the fix be a separate function that get's passed the report.

fix(report, fixer) {
  return fixer.insertTextAfter(report.node, ";");
}
samuelstroschein commented 1 week ago

fix function attached to the report function seems to make most sense 👍

regarding severity: