Add eslint rule/plugin to handle $foo global vars
stalniy opened this issue · 6 comments
stalniy commented
Requirements:
- perceive all variables with name
$*
as defined - if
onlyDefined
option is set totrue
, then additionally check whether the lazy var is defined withdef
- if
noDynamicName
option is set totrue
, then rule will not allow to use dynamically defined lazy vars - allow to specify dialects (
bdd
,bdd/getter
,bdd/global
) to check defined lazy vars - adds
its
,def
,subject
,get
,sharedExamplesFor
,includeExamplesFor
,itBehavesLike
andis
to global variables - this rule must play nice with
no-undef
rule or substitute it (implement its behavior inside)
EricRoos commented
+1 from me. Love the lib but I also love a clean lint log.
stalniy commented
I started the work in feat/eslint-rule
branch, probably it need to be a plugin not just a few rules
Kukunin commented
I did work around this issue by disabling the rule specifically for tests:
"overrides": [
{
"files": ["*.test.js"],
"rules": {
"no-undef": 0
}
}
],
in eslintrc.js
vhoyer commented
I did work around this issue by disabling the rule specifically for tests:
"overrides": [ { "files": ["*.test.js"], "rules": { "no-undef": 0 } } ],
in
eslintrc.js
not Ideal to ignore the rule, but it's a good enough workaround while we don't have the real deal 🤷
stalniy commented
Another good workaround which I saw in the wild is $.name
. You have almost the same as with global interface using getter interface (bdd-lazy-var/getter)
const { get } = require('bdd-lazy-var/getter')
global.$ = get
stalniy commented
This will be redundant with a new version. The API is shown in this comment