detect typo in metadata when linting
makes use of https://github.com/openstyles/usercss-meta/pull/78
This commit is contained in:
parent
404efcecf9
commit
b6cc6a09b9
|
@ -970,6 +970,18 @@
|
||||||
},
|
},
|
||||||
"description": "Error displayed when unknown metadata is parsed"
|
"description": "Error displayed when unknown metadata is parsed"
|
||||||
},
|
},
|
||||||
|
"meta_unknownMetaTypo": {
|
||||||
|
"message": "Maybe @$keyOk$? Unknown metadata: @$keyErr$",
|
||||||
|
"placeholders": {
|
||||||
|
"keyErr": {
|
||||||
|
"content": "$1"
|
||||||
|
},
|
||||||
|
"keyOk": {
|
||||||
|
"content": "$2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"description": "Try translating it so that at least the first placeholder is visible in our narrow panel. This is the error displayed when an unknown metadata key was sufficiently similar to a known one to consider it a typo."
|
||||||
|
},
|
||||||
"meta_unknownPreprocessor": {
|
"meta_unknownPreprocessor": {
|
||||||
"message": "Unknown @preprocessor: $preprocessor$",
|
"message": "Unknown @preprocessor: $preprocessor$",
|
||||||
"placeholders": {
|
"placeholders": {
|
||||||
|
|
|
@ -326,13 +326,17 @@ function SourceEditor() {
|
||||||
if (errors.every(err => err.code === 'unknownMeta')) {
|
if (errors.every(err => err.code === 'unknownMeta')) {
|
||||||
onUpdated(metadata);
|
onUpdated(metadata);
|
||||||
}
|
}
|
||||||
cache = errors.map(err => ({
|
cache = errors.map(({code, index, args, message}) => {
|
||||||
from: cm.posFromIndex((err.index || 0) + match.index),
|
const isUnknownMeta = code === 'unknownMeta';
|
||||||
to: cm.posFromIndex((err.index || 0) + match.index),
|
const typo = isUnknownMeta && args.length === 2 ? 'Typo' : '';
|
||||||
message: err.code && t(`meta_${err.code}`, err.args, false) || err.message,
|
return ({
|
||||||
severity: err.code === 'unknownMeta' ? 'warning' : 'error',
|
from: cm.posFromIndex((index || 0) + match.index),
|
||||||
rule: err.code,
|
to: cm.posFromIndex((index || 0) + match.index),
|
||||||
}));
|
message: code && t(`meta_${code}${typo}`, args, false) || message,
|
||||||
|
severity: isUnknownMeta ? 'warning' : 'error',
|
||||||
|
rule: code,
|
||||||
|
});
|
||||||
|
});
|
||||||
meta = match[0];
|
meta = match[0];
|
||||||
metaIndex = match.index;
|
metaIndex = match.index;
|
||||||
return cache;
|
return cache;
|
||||||
|
|
14
package-lock.json
generated
14
package-lock.json
generated
|
@ -16,7 +16,7 @@
|
||||||
"lz-string-unsafe": "^1.4.4-fork-1",
|
"lz-string-unsafe": "^1.4.4-fork-1",
|
||||||
"stylelint-bundle": "^13.8.0",
|
"stylelint-bundle": "^13.8.0",
|
||||||
"stylus-lang-bundle": "github:openstyles/stylus-lang-bundle#v0.54.7",
|
"stylus-lang-bundle": "github:openstyles/stylus-lang-bundle#v0.54.7",
|
||||||
"usercss-meta": "^0.11.0",
|
"usercss-meta": "^0.12.0",
|
||||||
"webext-launch-web-auth-flow": "^0.1.1"
|
"webext-launch-web-auth-flow": "^0.1.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
@ -11125,9 +11125,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/usercss-meta": {
|
"node_modules/usercss-meta": {
|
||||||
"version": "0.11.0",
|
"version": "0.12.0",
|
||||||
"resolved": "https://registry.npmjs.org/usercss-meta/-/usercss-meta-0.11.0.tgz",
|
"resolved": "https://registry.npmjs.org/usercss-meta/-/usercss-meta-0.12.0.tgz",
|
||||||
"integrity": "sha512-I6yJacP9zxr2Urww7loqJOzHfrrxxelziRiZZn4zKLj2117/MXt6Q4ix7Y1IWm4FrrL4JAo3LPpB4ggHeNWtMw==",
|
"integrity": "sha512-zKrXCKdpeIwtVe87omxGo9URf+7mbozduMZEg79dmT4KB3XJwfIkEi/Uk0PcTwR/nZLtAK1+k7isgbGB/g6E7Q==",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=8.3"
|
"node": ">=8.3"
|
||||||
}
|
}
|
||||||
|
@ -21126,9 +21126,9 @@
|
||||||
"optional": true
|
"optional": true
|
||||||
},
|
},
|
||||||
"usercss-meta": {
|
"usercss-meta": {
|
||||||
"version": "0.11.0",
|
"version": "0.12.0",
|
||||||
"resolved": "https://registry.npmjs.org/usercss-meta/-/usercss-meta-0.11.0.tgz",
|
"resolved": "https://registry.npmjs.org/usercss-meta/-/usercss-meta-0.12.0.tgz",
|
||||||
"integrity": "sha512-I6yJacP9zxr2Urww7loqJOzHfrrxxelziRiZZn4zKLj2117/MXt6Q4ix7Y1IWm4FrrL4JAo3LPpB4ggHeNWtMw=="
|
"integrity": "sha512-zKrXCKdpeIwtVe87omxGo9URf+7mbozduMZEg79dmT4KB3XJwfIkEi/Uk0PcTwR/nZLtAK1+k7isgbGB/g6E7Q=="
|
||||||
},
|
},
|
||||||
"util-deprecate": {
|
"util-deprecate": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
"lz-string-unsafe": "^1.4.4-fork-1",
|
"lz-string-unsafe": "^1.4.4-fork-1",
|
||||||
"stylelint-bundle": "^13.8.0",
|
"stylelint-bundle": "^13.8.0",
|
||||||
"stylus-lang-bundle": "github:openstyles/stylus-lang-bundle#v0.54.7",
|
"stylus-lang-bundle": "github:openstyles/stylus-lang-bundle#v0.54.7",
|
||||||
"usercss-meta": "^0.11.0",
|
"usercss-meta": "^0.12.0",
|
||||||
"webext-launch-web-auth-flow": "^0.1.1"
|
"webext-launch-web-auth-flow": "^0.1.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
2
vendor/usercss-meta/README.md
vendored
2
vendor/usercss-meta/README.md
vendored
|
@ -1,4 +1,4 @@
|
||||||
## usercss-meta v0.11.0
|
## usercss-meta v0.12.0
|
||||||
|
|
||||||
Following files are copied from npm (node_modules):
|
Following files are copied from npm (node_modules):
|
||||||
|
|
||||||
|
|
2
vendor/usercss-meta/usercss-meta.min.js
vendored
2
vendor/usercss-meta/usercss-meta.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user