-
Notifications
You must be signed in to change notification settings - Fork 34
/
dependency-suggestions.ts
40 lines (36 loc) · 1.15 KB
/
dependency-suggestions.ts
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
import { Rule } from 'eslint';
import ts from 'typescript';
import { stencilComponentContext } from '../utils';
import * as tsutils from 'tsutils';
const rule: Rule.RuleModule = {
meta: {
docs: {
description: 'This rule can provide suggestions about dependencies in stencil apps',
recommended: true
},
schema: [],
type: 'suggestion',
},
create(context): Rule.RuleListener {
return {
'ImportDeclaration': (node: any) => {
const importName = node.source.value;
const message = SUGGESTIONS[importName];
if (message) {
context.report({
node,
message
});
}
}
};
}
};
const SUGGESTIONS: {[importName: string]: string} = {
'classnames': `Stencil can already render conditional classes:
<div class={{disabled: condition}}>`,
'lodash': `"lodash" will bloat your build, use "lodash-es" instead: https://www.npmjs.com/package/lodash-es`,
'moment': `"moment" will bloat your build, use "dayjs", "date-fns" or other modern lightweight alternaitve`,
'core-js': `Stencil already include the core-js polyfills only when needed`,
}
export default rule;