forked from opentypejs/opentype.js
-
Notifications
You must be signed in to change notification settings - Fork 1
/
eslint-local-rules.js
43 lines (41 loc) · 1.05 KB
/
eslint-local-rules.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
'use strict';
module.exports = {
'ban-foreach': {
meta: {
type: 'suggestion',
schema: [],
},
create(context) {
return {
CallExpression(node) {
if (node.callee.property && node.callee.property.name === 'forEach') {
context.report({node, message: 'Use for() loops instead of .forEach()'})
}
},
}
},
},
'import-extensions': {
meta: {
type: 'problem',
schema: []
},
create(context) {
const checkImportPath = (node) => {
const importPath = node.source.value;
const isRelative = importPath.startsWith('.') || importPath.startsWith('/');
const extensionMissing = require('path').extname(importPath) === '';
if (!isRelative || !extensionMissing) {
return;
}
context.report({
node: node.source,
message: 'Import paths require a file extension to work in browser module context'
});
};
return {
ImportDeclaration: checkImportPath
};
},
}
};