@toptal/davinci-syntax 11.0.1 → 11.1.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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Change Log
2
2
 
3
+ ## 11.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#1072](https://github.com/toptal/davinci/pull/1072) [`0b93a80c`](https://github.com/toptal/davinci/commit/0b93a80c005d723503cb9dd3520505a450dc0d0b) Thanks [@MrBra1nwash](https://github.com/MrBra1nwash)! - [SP-1771] Add import/no-relative-packages rule
8
+
9
+ ## 11.0.2
10
+
11
+ ### Patch Changes
12
+
13
+ - [#1073](https://github.com/toptal/davinci/pull/1073) [`33a4dbbb`](https://github.com/toptal/davinci/commit/33a4dbbba010af7d5c8712dd7ce65f9e0bcafb13) Thanks [@denieler](https://github.com/denieler)! - Disable `no-empty-first-line` rule due to issues with weird looking styles for styled components styles.
14
+
3
15
  ## 11.0.1
4
16
 
5
17
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toptal/davinci-syntax",
3
- "version": "11.0.1",
3
+ "version": "11.1.0",
4
4
  "description": "Lint and prettier support",
5
5
  "publishConfig": {
6
6
  "access": "public"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toptal/davinci-syntax",
3
- "version": "11.0.1",
3
+ "version": "11.1.0",
4
4
  "description": "Lint and prettier support",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -184,6 +184,9 @@ exports[`eslint config verifies eslint rules are not updated silently 1`] = `
184
184
  'import/no-extraneous-dependencies': [
185
185
  'error',
186
186
  ],
187
+ 'import/no-relative-packages': [
188
+ 'warn',
189
+ ],
187
190
  '@typescript-eslint/array-type': [
188
191
  'error',
189
192
  {
@@ -0,0 +1,2 @@
1
+ export default 'bar'
2
+ export const foo = () => 'foo'
@@ -0,0 +1 @@
1
+ export default () => {}
@@ -0,0 +1,4 @@
1
+ {
2
+ "description": "Unnamed package",
3
+ "main": "index.js"
4
+ }
@@ -0,0 +1 @@
1
+ export default () => {}
@@ -0,0 +1,5 @@
1
+ {
2
+ "name": "package-named",
3
+ "description": "Standard, named package",
4
+ "main": "index.js"
5
+ }
@@ -0,0 +1 @@
1
+ export default () => {}
@@ -0,0 +1,5 @@
1
+ {
2
+ "name": "@scope/package-named",
3
+ "description": "Scoped, named package",
4
+ "main": "index.js"
5
+ }
@@ -3,8 +3,8 @@ import { ESLint, Linter } from 'eslint'
3
3
  import json5 from 'json5'
4
4
 
5
5
  const getConfig = () => {
6
- const pathToEslintrc = path.join(__dirname, '../src/configs/.eslintrc')
7
-
6
+ const pathToEslintrc = path.join(__dirname, '../../src/configs/.eslintrc')
7
+
8
8
  return new ESLint({
9
9
  useEslintrc: false, // don't use any other eslintrc files (higher in the folder tree)
10
10
  overrideConfigFile: pathToEslintrc // use this exact eslintrc file
@@ -0,0 +1,102 @@
1
+ import { RuleTester } from 'eslint'
2
+ import path from 'path'
3
+ import rule from 'eslint-plugin-import/lib/rules/no-relative-packages'
4
+
5
+ const testFilePath = relativePath =>
6
+ path.join(__dirname, '/eslint-package-structure', relativePath)
7
+
8
+ const FILENAME = testFilePath('foo.js')
9
+
10
+ const testRule = options => ({
11
+ filename: FILENAME,
12
+ parserOptions: {
13
+ sourceType: 'module',
14
+ ecmaVersion: 9,
15
+ ...options.parserOptions
16
+ },
17
+ ...options
18
+ })
19
+
20
+ const ruleTester = new RuleTester()
21
+
22
+ ruleTester.run('no-relative-packages', rule, {
23
+ valid: [
24
+ testRule({
25
+ code: 'import foo from "./index.js"',
26
+ filename: testFilePath('./package/index.js')
27
+ }),
28
+ /**
29
+ * Unfortunately, this case is considered valid for the rule,
30
+ * but we cannot influence this. This case should be considered invalid.
31
+ *
32
+ * testRule({
33
+ * code: 'import bar from "../bar"',
34
+ * filename: testFilePath('./package/index.js')
35
+ * }),
36
+ */
37
+ testRule({
38
+ code: 'import { foo } from "a"',
39
+ filename: testFilePath('./package-named/index.js')
40
+ }),
41
+ testRule({
42
+ code: 'const bar = require("../bar.js")',
43
+ filename: testFilePath('./package/index.js')
44
+ }),
45
+ testRule({
46
+ code: 'import "package"',
47
+ filename: testFilePath('./package/index.js')
48
+ }),
49
+ testRule({
50
+ code: 'require("../bar.js")',
51
+ filename: testFilePath('./package/index.js')
52
+ })
53
+ ],
54
+ invalid: [
55
+ testRule({
56
+ code: 'import foo from "./package-named"',
57
+ filename: testFilePath('./bar.js'),
58
+ errors: [
59
+ {
60
+ message:
61
+ 'Relative import from another package is not allowed. Use `package-named` instead of `./package-named`',
62
+ line: 1,
63
+ column: 17
64
+ }
65
+ ]
66
+ }),
67
+ testRule({
68
+ code: 'import foo from "../package-named"',
69
+ filename: testFilePath('./package/index.js'),
70
+ errors: [
71
+ {
72
+ message:
73
+ 'Relative import from another package is not allowed. Use `package-named` instead of `../package-named`',
74
+ line: 1,
75
+ column: 17
76
+ }
77
+ ]
78
+ }),
79
+ testRule({
80
+ code: 'import foo from "../package-scoped"',
81
+ filename: testFilePath('./package/index.js'),
82
+ errors: [
83
+ {
84
+ message: `Relative import from another package is not allowed. Use \`@scope/package-named\` instead of \`../package-scoped\``,
85
+ line: 1,
86
+ column: 17
87
+ }
88
+ ]
89
+ }),
90
+ testRule({
91
+ code: 'import bar from "../bar"',
92
+ filename: testFilePath('./package-named/index.js'),
93
+ errors: [
94
+ {
95
+ message: `Relative import from another package is not allowed. Use \`@toptal/davinci-syntax/src/__test__/eslint-package-structure/bar\` instead of \`../bar\``,
96
+ line: 1,
97
+ column: 17
98
+ }
99
+ ]
100
+ })
101
+ ]
102
+ })
@@ -175,6 +175,7 @@
175
175
  ["@toptal/picasso-shared", "@toptal/picasso-shared/**/*"]
176
176
  ],
177
177
  "import/no-extraneous-dependencies": "error",
178
+ "import/no-relative-packages": "warn",
178
179
  // typescript
179
180
  "@typescript-eslint/array-type": [
180
181
  "error",
@@ -11,6 +11,7 @@
11
11
  "ignoreKeywords": ["dummyValue"]
12
12
  }
13
13
  ],
14
- "string-quotes": "single"
14
+ "string-quotes": "single",
15
+ "no-empty-first-line": null
15
16
  }
16
17
  }