@toptal/eslint-plugin-davinci 5.4.2-alpha-fix-execute-graphql-command-8169aa3b.95 → 5.4.2
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.
|
@@ -5,7 +5,7 @@ const looksLike = require('../utils/looks-like')
|
|
|
5
5
|
// Examples: certification-item, talent-loader-${state.isLoading}
|
|
6
6
|
const TEST_ID_REGEX = /^[a-z]+(-[a-z0-9]+)*(-\${[a-zA-Z_$][0-9a-zA-Z_$.]*})?$/g
|
|
7
7
|
const NAMING_CONVETNION_DOC_LINK =
|
|
8
|
-
'https://toptal-core.atlassian.net/l/
|
|
8
|
+
'https://toptal-core.atlassian.net/l/cp/C7cmiiX1'
|
|
9
9
|
const VALID_TEST_ID_METHODS = [
|
|
10
10
|
'getByTestId',
|
|
11
11
|
'getAllByTestId',
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
const isImportPathStartsWithPackageName = require('./is-import-path-starts-with-package-name')
|
|
2
|
+
|
|
3
|
+
describe('isImportPathStartsWithPackageName', () => {
|
|
4
|
+
describe('true cases', () => {
|
|
5
|
+
it.each([
|
|
6
|
+
{
|
|
7
|
+
packageName: '@toptal/picasso',
|
|
8
|
+
importFromPath: '@toptal/picasso',
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
packageName: '@toptal/picasso',
|
|
12
|
+
importFromPath: '@toptal/picasso/test-utils',
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
packageName: '@toptal/picasso',
|
|
16
|
+
importFromPath: '@toptal/picasso/utils',
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
packageName: '@toptal/picasso',
|
|
20
|
+
importFromPath: '@toptal/picasso/TagSelectorInput',
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
packageName: 'picasso-package',
|
|
24
|
+
importFromPath: 'picasso-package/test-utils',
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
packageName: 'picasso',
|
|
28
|
+
importFromPath: 'picasso/TagSelectorInput',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
packageName: 'picasso',
|
|
32
|
+
importFromPath: 'picasso/TagSelectorInput/utils',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
packageName: 'picasso/sub-package',
|
|
36
|
+
importFromPath: 'picasso/sub-package/utils',
|
|
37
|
+
},
|
|
38
|
+
])(
|
|
39
|
+
`import '$importFromPath' comes from the '$packageName'`,
|
|
40
|
+
({ packageName, importFromPath }) => {
|
|
41
|
+
expect(
|
|
42
|
+
isImportPathStartsWithPackageName(packageName, importFromPath)
|
|
43
|
+
).toBe(true)
|
|
44
|
+
}
|
|
45
|
+
)
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
describe('false cases', () => {
|
|
49
|
+
it.each([
|
|
50
|
+
{
|
|
51
|
+
packageName: '@toptal/picasso-shared',
|
|
52
|
+
importFromPath: '@toptal/picasso-not-shared',
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
packageName: '@toptal/picasso',
|
|
56
|
+
importFromPath: '@toptal/picasso-shared',
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
packageName: '@toptal/picasso',
|
|
60
|
+
importFromPath: '@davinci/picasso/test-forms',
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
packageName: '@toptal/picasso',
|
|
64
|
+
importFromPath: '@davinci/picasso',
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
packageName: '@toptal/picasso',
|
|
68
|
+
importFromPath: '@davinci/picasso-shared',
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
packageName: 'picasso',
|
|
72
|
+
importFromPath: 'davinci',
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
packageName: 'picasso',
|
|
76
|
+
importFromPath: 'davinci/cli-shared',
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
packageName: 'picasso',
|
|
80
|
+
importFromPath: '@davinci',
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
packageName: 'picasso/sub-package',
|
|
84
|
+
importFromPath: 'another-package',
|
|
85
|
+
},
|
|
86
|
+
])(
|
|
87
|
+
`imports '$importFromPath' comes from a package different from '$packageName'`,
|
|
88
|
+
({ packageName, importFromPath }) => {
|
|
89
|
+
expect(
|
|
90
|
+
isImportPathStartsWithPackageName(packageName, importFromPath)
|
|
91
|
+
).toBe(false)
|
|
92
|
+
}
|
|
93
|
+
)
|
|
94
|
+
})
|
|
95
|
+
})
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
jest.mock('./require-resolve.js', () => jest.fn())
|
|
2
|
+
|
|
3
|
+
const resolveModulePath = require('./resolve-module-path')
|
|
4
|
+
const requireResolve = require('./require-resolve')
|
|
5
|
+
|
|
6
|
+
describe('resolve module path utility', () => {
|
|
7
|
+
beforeEach(() => {
|
|
8
|
+
requireResolve.mockReset()
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
it('resolves module path by using requre.resolve in provided path when no aliases provided', () => {
|
|
12
|
+
const module = 'module'
|
|
13
|
+
const cwd = 'cwd'
|
|
14
|
+
const modulePath = 'module-path'
|
|
15
|
+
|
|
16
|
+
requireResolve.mockReturnValueOnce(modulePath)
|
|
17
|
+
|
|
18
|
+
const result = resolveModulePath(module, cwd)
|
|
19
|
+
|
|
20
|
+
expect(result).toBe(modulePath)
|
|
21
|
+
expect(requireResolve).toHaveBeenCalledWith(module, cwd)
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
it('returns the module path resolved according to the alias map', () => {
|
|
25
|
+
const module = '@alias/module'
|
|
26
|
+
const cwd = 'cwd'
|
|
27
|
+
const aliasModulePath = 'alias-module-path'
|
|
28
|
+
const aliasMap = {
|
|
29
|
+
'@alias': aliasModulePath,
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const result = resolveModulePath(module, cwd, aliasMap)
|
|
33
|
+
|
|
34
|
+
expect(result).toBe(`${aliasModulePath}/module`)
|
|
35
|
+
expect(requireResolve).not.toHaveBeenCalled()
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
it('resolves the module with the last matching alias', () => {
|
|
39
|
+
const module = '@alias/module'
|
|
40
|
+
const cwd = 'cwd'
|
|
41
|
+
const fristAliasModulePath = 'first-alias-module-path'
|
|
42
|
+
const secondAliasModulePath = 'second-alias-module-path'
|
|
43
|
+
const aliasMap = {
|
|
44
|
+
'@': fristAliasModulePath,
|
|
45
|
+
'@alias': secondAliasModulePath,
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const result = resolveModulePath(module, cwd, aliasMap)
|
|
49
|
+
|
|
50
|
+
expect(result).toBe(`${secondAliasModulePath}/module`)
|
|
51
|
+
expect(requireResolve).not.toHaveBeenCalled()
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
it('resolves module path by using requre.resolve if no aliases matching the module', () => {
|
|
55
|
+
const module = 'module'
|
|
56
|
+
const cwd = 'cwd'
|
|
57
|
+
const aliasMap = {
|
|
58
|
+
'other-module': 'some-path',
|
|
59
|
+
}
|
|
60
|
+
const modulePath = 'module-path'
|
|
61
|
+
|
|
62
|
+
requireResolve.mockReturnValueOnce(modulePath)
|
|
63
|
+
|
|
64
|
+
const result = resolveModulePath(module, cwd, aliasMap)
|
|
65
|
+
|
|
66
|
+
expect(result).toBe(modulePath)
|
|
67
|
+
expect(requireResolve).toHaveBeenCalledWith(module, cwd)
|
|
68
|
+
})
|
|
69
|
+
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toptal/eslint-plugin-davinci",
|
|
3
|
-
"version": "5.4.2
|
|
3
|
+
"version": "5.4.2",
|
|
4
4
|
"description": "davinci eslint rules",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -41,6 +41,5 @@
|
|
|
41
41
|
"require-json5": "^1.1.0",
|
|
42
42
|
"requireindex": "^1.2.0",
|
|
43
43
|
"resolve-ts-aliases": "^1.0.1"
|
|
44
|
-
}
|
|
45
|
-
"gitHead": "8169aa3bf223d6c1348d45f5ce4706768a091104"
|
|
44
|
+
}
|
|
46
45
|
}
|