-
Notifications
You must be signed in to change notification settings - Fork 34
Lint Config: Support Passing Context thru to Rules
#808
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
base: primary
Are you sure you want to change the base?
Conversation
…w + support for file ignores
Context thru to Lint RulesContext thru to Rules
lute/cli/commands/lint/init.luau
Outdated
| lintRules: { types.LintRule }, | ||
| autofixEnabled: boolean, | ||
| _lintConfig: types.LintConfig, -- will be used in follow-up PRs | ||
| lintConfig: types.LintConfig, -- will be used in follow-up PRs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| lintConfig: types.LintConfig, -- will be used in follow-up PRs | |
| lintConfig: types.LintConfig, |
lute/cli/commands/lint/init.luau
Outdated
| local ruleConfig: types.RuleConfig = if rulesConfig[rule.name] ~= nil then rulesConfig[rule.name] else {} | ||
|
|
||
| local context: types.RuleContext = { | ||
| globals = if config.globals ~= nil then config.globals else {}, | ||
| options = if ruleConfig.options ~= nil then ruleConfig.options else {}, | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should do this at the lintPaths level, instead of redoing it for every file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can move some of the derivation out for sure, but we'll need to pass thru globals and rule configs to this to lintString regardless, since I assume this is the level at which we'll do things like:
- override violation severity w/ the configured severity
- not run rules according to rule-specific ignores
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah sorry, i just meant we shouldn't do the computation of globals and options at this level
…r than per file + test for rule-specific ignores
This PR implements two next steps for lute lint's configuration system: rule context and rule-specific ignores.
Contextis a table ofglobalsand rule specificoptions, as configured by the user. For example, given a configuration of:we will the following context to each call of
myRule:This enables rule authors to write logic w/ configurability in mind, and extend their analyses to use-cases beyond the default.
Rule-specific ignores extend the global-lint ignores (implemented in this PR), but are evaluated per-rule. This enables more granular ignore behavior, where we can effectively turn off rules for certain files / paths.