forked from csscomb/csscomb.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.js
71 lines (53 loc) · 1.97 KB
/
errors.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
'use strict';
let format = require('./format');
module.exports = {
configParsingError(configPath) {
return `Error parsing configuration file ${configPath}.`;
},
implementSetValue(valueType) {
if (typeof valueType === 'undefined') throw new Error();
return format(`If you see this message and you are not
a developer adding a new option, please open an issue here:
https://github.com/csscomb/core/issues/new\n
For option to accept values of type "${valueType}"
you need to implement custom \`setValue()\` method.`);
},
missingName() {
return 'Plugin must have a valid \`name\` property.';
},
missingSetValue() {
return format(`Plugin must either implemet \`setValue()\` method
or provide \`accepts\` object with acceptable values.`);
},
missingSyntax() {
return 'Plugin must list supported syntaxes.';
},
missingTemplateFile(file) {
return format(`Template configuration file ${file}
was not found.`);
},
twoPluginsWithSameName(pluginName) {
if (typeof pluginName === 'undefined') throw new Error();
return format(`You're trying to use one plugin twice:
${pluginName}. Please make sure there are not two different
plugins with the same name.`);
},
unacceptableBoolean(pattern) {
if (typeof pattern === 'undefined') throw new Error();
return `Value must be one of the following: ${pattern.join(', ')}.`;
},
unacceptableNumber() {
return 'Value must be an integer.';
},
unacceptableString(pattern) {
if (typeof pattern === 'undefined') throw new Error();
return `Value must match pattern ${pattern}.`;
},
unacceptableValueType(valueType, accepts) {
if (typeof valueType === 'undefined' ||
typeof accepts === 'undefined') throw new Error();
return format(`The option does not accept values of type
${valueType}.\nValue\'s type must be one the following:
${Object.keys(accepts).join(', ')}.`);
}
};