browserslist
browserslist copied to clipboard
Add `browserslist.lint()`
Add a method to find errors in current Browserslist config.
Possible checks:
-
missed-not-dead
: onlast N versions
withoutnot dead
-
limited-browsers
: on queries only with browser names (and < 7 browser names) -
country-was-ignored
: on significant (≥20%) drop of coverage in some country (we can use all countries or only countries with ≥1M population).
@ai
on significant (≥20%) drop of coverage in some country (we can use all countries or only countries with ≥1M population).
As I understood, if coverage for country is <80% then issue should be reported. But then "defaults" query will not pass this check (for countries with ≥1M population)
$ browserslist --coverage=AM "defaults"
These browsers account for 59.15% of all users in the AM
$ browserslist --coverage=MA "defaults"
These browsers account for 58.51% of all users in the MA
$ browserslist --coverage=RU "defaults"
These browsers account for 72.13% of all users in the RU
$ browserslist --coverage=SG "defaults"
These browsers account for 61.77% of all users in the SG
Is this ok?
I think linter can be implemented in a separated pacakge, as https://github.com/browserslist/browserslist/issues/549#issuecomment-1044474071 said.
I think linter can be implemented in a separated pacakge, as https://github.com/browserslist/browserslist/issues/549#issuecomment-1044474071 said.
I can move it by my own
As I understood, if coverage for country is <80% then issue should be reported. But then "defaults" query will not pass this check (for countries with ≥1M population)
Wow! It is a shame for our defaults
.
But let add warning first and then we will think how to improve defaults
(as part of another task).
@ai it looks weird
$ browserslist --coverage=RU "last 100 versions"
These browsers account for 83.4% of all users in the RU
Agree. Can I ask you to investigate? Maybe we have an error in coverage calculation?
@ai 👌
@ai In caniuse country data there is "total" value, it can be not 100%
https://github.com/Fyrd/caniuse/blob/main/region-usage-json/RU.json
"total":81.56795
my suggestion is to interpret this value as 100% and recalculate coverage relative to it
var total = 0
for (var j in data) {
total += data[j] || 0
}
var tx = 100 / total
return browsers.reduce(function (all, i) {
var usage = data[i] * tx
if (usage === undefined) {
usage = data[i.replace(/ \S+$/, ' 0')] * tx
}
return all + (usage || 0)
}, 0)
then coverage for "defaults" is
$ browserslist --coverage=AM "defaults"
These browsers account for 59.33% of all users in the AM
$ browserslist --coverage=MA "defaults"
These browsers account for 52.39% of all users in the MA
$ browserslist --coverage=RU "defaults"
These browsers account for 88.36% of all users in the RU
$ browserslist --coverage=SG "defaults"
These browsers account for 64.85% of all users in the SG
Example with "last 100 versions"
Before:
$ browserslist --coverage=AM "last 100 versions"
These browsers account for 97.63% of all users in the AM
$ browserslist --coverage=MA "last 100 versions"
These browsers account for 95.88% of all users in the MA
$ browserslist --coverage=RU "last 100 versions"
These browsers account for 81.5% of all users in the RU
$ browserslist --coverage=SG "last 100 versions"
These browsers account for 94.91% of all users in the SG
After:
$ browserslist --coverage=AM "last 100 versions"
These browsers account for 99.96% of all users in the AM
$ browserslist --coverage=MA "last 100 versions"
These browsers account for 99.98% of all users in the MA
$ browserslist --coverage=RU "last 100 versions"
These browsers account for 99.92% of all users in the RU
$ browserslist --coverage=SG "last 100 versions"
These browsers account for 99.93% of all users in the SG
Seems like total
≠100% because of browsers which are not on Can I Use (like Yandex browser).
Let’s keep old logic for --coverage
and use / total
only in linter.
@ai ok. But it solve problem only for RU.
Weak places in other regions:
AM
'firefox 52': 37.23163,
- popular but not in "defaults"
MA
'ios_saf 6.0-6.1': 14.55397,
- popular but not in "defaults"
SG
'android 4.4.3-4.4.4': 21.76044,
- popular but not in "defaults"
Yes, we will think about solving this problem later.
BTW, it will be nice to suggest in warning what browser to add to fix coverage in the region.
It seems like this hasn't been updated since browserslist-lint
was created. Can this be updated or closed?