/
imports.js
74 lines (65 loc) · 2.68 KB
/
imports.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
72
73
74
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules
module.exports = {
extends: ['plugin:import/typescript'],
plugins: ['import'],
rules: {
// Disallow specified import patterns
// https://eslint.org/docs/rules/no-restricted-imports
'no-restricted-imports': [
'error',
{
paths: [
{
name: 'lodash',
message: "Please use 'ramda' instead",
},
{
name: '@testing-library/react',
message: "Please use '@vtex/test-tools/react' instead",
},
],
// Patterns don't support messages yet :(
// https://github.com/eslint/eslint/issues/11843
patterns: ['lodash/*'],
},
],
// Disallow non-import statements appearing before import statements
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/first.md
'import/first': 'error',
// Disallow duplicate imports
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-duplicates.md
'import/no-duplicates': 'error',
// Ensure native, external and internal imports are separated, above relative imports and that unassigned imports are ignored
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/order.md
'import/order': [
'error',
{
'newlines-between': 'always',
groups: [
'builtin',
'external',
'internal',
['parent', 'sibling', 'index'],
],
},
],
// Require a newline after the last import/require in a group
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/newline-after-import.md
'import/newline-after-import': 'error',
// Forbid import of modules using absolute paths
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-absolute-path.md
'import/no-absolute-path': 'error',
// Forbid mutable exports
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-mutable-exports.md
'import/no-mutable-exports': 'error',
// Disallow invalid exports, e.g. multiple defaults
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/export.md
'import/export': 'error',
// Ensures that there are no useless path segments
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-useless-path-segments.md
'import/no-useless-path-segments': ['error', { commonjs: true }],
// Forbid a module from importing itself
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-self-import.md
'import/no-self-import': 'error',
},
}