@lvce-editor/eslint-plugin-extension-json 18.13.0 → 18.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +37 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -31,7 +31,7 @@ const findMember = (node, name) => {
|
|
|
31
31
|
};
|
|
32
32
|
|
|
33
33
|
const requiredFirstDirective = "default-src 'none'";
|
|
34
|
-
const meta$
|
|
34
|
+
const meta$2 = {
|
|
35
35
|
docs: {
|
|
36
36
|
description: 'Require a secure content security policy for extension workers'
|
|
37
37
|
},
|
|
@@ -48,7 +48,7 @@ const hasMainEntry = manifest => {
|
|
|
48
48
|
const isValidPolicyArray = node => {
|
|
49
49
|
return isArrayNode(node) && node.elements.every(element => isStringNode(element.value));
|
|
50
50
|
};
|
|
51
|
-
const create$
|
|
51
|
+
const create$2 = context => {
|
|
52
52
|
return {
|
|
53
53
|
Document(node) {
|
|
54
54
|
if (!isObjectNode(node.body)) {
|
|
@@ -83,6 +83,39 @@ const create$1 = context => {
|
|
|
83
83
|
};
|
|
84
84
|
|
|
85
85
|
const contentSecurityPolicy = {
|
|
86
|
+
__proto__: null,
|
|
87
|
+
create: create$2,
|
|
88
|
+
meta: meta$2
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const meta$1 = {
|
|
92
|
+
docs: {
|
|
93
|
+
description: 'Disallow empty languages arrays in extension manifests'
|
|
94
|
+
},
|
|
95
|
+
messages: {
|
|
96
|
+
emptyLanguages: 'extension languages array must not be empty'
|
|
97
|
+
},
|
|
98
|
+
type: 'problem'
|
|
99
|
+
};
|
|
100
|
+
const create$1 = context => {
|
|
101
|
+
return {
|
|
102
|
+
Document(node) {
|
|
103
|
+
if (!isObjectNode(node.body)) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
const languages = findMember(node.body, 'languages');
|
|
107
|
+
if (!languages || !isArrayNode(languages.value) || languages.value.elements.length > 0) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
context.report({
|
|
111
|
+
loc: languages.name.loc,
|
|
112
|
+
messageId: 'emptyLanguages'
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
const nonEmptyLanguages = {
|
|
86
119
|
__proto__: null,
|
|
87
120
|
create: create$1,
|
|
88
121
|
meta: meta$1
|
|
@@ -210,6 +243,7 @@ const plugin = {
|
|
|
210
243
|
},
|
|
211
244
|
rules: {
|
|
212
245
|
'content-security-policy': contentSecurityPolicy,
|
|
246
|
+
'non-empty-languages': nonEmptyLanguages,
|
|
213
247
|
'valid-keybindings': validKeybindings
|
|
214
248
|
}
|
|
215
249
|
};
|
|
@@ -223,6 +257,7 @@ const recommended = [{
|
|
|
223
257
|
},
|
|
224
258
|
rules: {
|
|
225
259
|
'extension-json/content-security-policy': 'error',
|
|
260
|
+
'extension-json/non-empty-languages': 'error',
|
|
226
261
|
'extension-json/valid-keybindings': 'error'
|
|
227
262
|
}
|
|
228
263
|
}];
|