@tinkoff/eslint-config 5.2.0 → 5.2.1
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 +8 -0
- package/README.md +92 -96
- package/app.js +2 -6
- package/errors/index.js +16 -13
- package/index.js +24 -14
- package/internal/base.js +89 -78
- package/internal/import.js +40 -31
- package/internal/prettier.js +16 -3
- package/internal/promise.js +11 -8
- package/internal/sort-class-members.js +57 -54
- package/internal/test-files.js +14 -16
- package/internal/typescript.js +170 -157
- package/jest.js +18 -17
- package/lib.js +11 -10
- package/package.json +26 -14
- package/test/import/import-happy.test.js +15 -11
- package/test/import/import-unhappy.test.js +15 -11
- package/test/index.test.js +26 -26
|
@@ -1,27 +1,31 @@
|
|
|
1
1
|
import { ESLint } from 'eslint';
|
|
2
2
|
import path from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
import importConfig from '../../internal/import.js';
|
|
5
|
+
|
|
6
|
+
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
|
3
7
|
|
|
4
8
|
describe('import / happy path', () => {
|
|
5
9
|
const cli = new ESLint({
|
|
6
10
|
cwd: path.join(__dirname, '..'),
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
overrideConfigFile: true,
|
|
12
|
+
overrideConfig: [
|
|
13
|
+
...importConfig,
|
|
14
|
+
{
|
|
15
|
+
languageOptions: {
|
|
16
|
+
sourceType: 'module',
|
|
17
|
+
ecmaVersion: 2015,
|
|
18
|
+
},
|
|
15
19
|
},
|
|
16
|
-
|
|
20
|
+
],
|
|
17
21
|
});
|
|
18
22
|
|
|
19
23
|
it('happy', async () => {
|
|
20
|
-
const
|
|
24
|
+
const formatter = await cli.loadFormatter('codeframe');
|
|
21
25
|
const results = await cli.lintFiles([
|
|
22
26
|
path.join(__dirname, './__fixtures__/import-happy.fixture.js'),
|
|
23
27
|
]);
|
|
24
28
|
|
|
25
|
-
expect(
|
|
29
|
+
expect(formatter.format(results)).toMatchSnapshot();
|
|
26
30
|
});
|
|
27
31
|
});
|
|
@@ -1,27 +1,31 @@
|
|
|
1
1
|
import { ESLint } from 'eslint';
|
|
2
2
|
import path from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
import importConfig from '../../internal/import.js';
|
|
5
|
+
|
|
6
|
+
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
|
3
7
|
|
|
4
8
|
describe('import / unhappy path', () => {
|
|
5
9
|
const cli = new ESLint({
|
|
6
10
|
cwd: path.join(__dirname, '..'),
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
overrideConfigFile: true,
|
|
12
|
+
overrideConfig: [
|
|
13
|
+
...importConfig,
|
|
14
|
+
{
|
|
15
|
+
languageOptions: {
|
|
16
|
+
sourceType: 'module',
|
|
17
|
+
ecmaVersion: 2015,
|
|
18
|
+
},
|
|
15
19
|
},
|
|
16
|
-
|
|
20
|
+
],
|
|
17
21
|
});
|
|
18
22
|
|
|
19
23
|
it('unhappy', async () => {
|
|
20
|
-
const
|
|
24
|
+
const formatter = await cli.loadFormatter('codeframe');
|
|
21
25
|
const results = await cli.lintFiles([
|
|
22
26
|
path.join(__dirname, './__fixtures__/import-unhappy.fixture.js'),
|
|
23
27
|
]);
|
|
24
28
|
|
|
25
|
-
expect(
|
|
29
|
+
expect(formatter.format(results)).toMatchSnapshot();
|
|
26
30
|
});
|
|
27
31
|
});
|
package/test/index.test.js
CHANGED
|
@@ -1,52 +1,52 @@
|
|
|
1
1
|
import { ESLint } from 'eslint';
|
|
2
2
|
import path from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
import appConfig from '../app.js';
|
|
5
|
+
import libConfig from '../lib.js';
|
|
6
|
+
import jestConfig from '../jest.js';
|
|
7
|
+
|
|
8
|
+
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
|
3
9
|
|
|
4
10
|
describe('@tinkoff/eslint-config', () => {
|
|
5
|
-
it('app config working', () => {
|
|
11
|
+
it('app config working', async () => {
|
|
6
12
|
const cli = new ESLint({
|
|
7
|
-
|
|
13
|
+
overrideConfigFile: true,
|
|
14
|
+
overrideConfig: appConfig,
|
|
8
15
|
cwd: path.join(__dirname, '..'),
|
|
9
|
-
baseConfig: {
|
|
10
|
-
extends: ['./app'],
|
|
11
|
-
},
|
|
12
16
|
});
|
|
13
17
|
|
|
14
|
-
expect(
|
|
15
|
-
expect(
|
|
18
|
+
await expect(cli.lintText(`const foo = 'bar';`)).resolves.toBeDefined();
|
|
19
|
+
await expect(
|
|
16
20
|
cli.lintText(`const foo = 'bar';`, { filePath: 'index.ts' })
|
|
17
|
-
).
|
|
21
|
+
).resolves.toBeDefined();
|
|
18
22
|
});
|
|
19
23
|
|
|
20
|
-
it('lib config working', () => {
|
|
24
|
+
it('lib config working', async () => {
|
|
21
25
|
const cli = new ESLint({
|
|
22
|
-
|
|
26
|
+
overrideConfigFile: true,
|
|
27
|
+
overrideConfig: libConfig,
|
|
23
28
|
cwd: path.join(__dirname, '..'),
|
|
24
|
-
baseConfig: {
|
|
25
|
-
extends: ['./lib'],
|
|
26
|
-
},
|
|
27
29
|
});
|
|
28
30
|
|
|
29
|
-
expect(
|
|
30
|
-
expect(
|
|
31
|
+
await expect(cli.lintText(`const foo = 'bar';`)).resolves.toBeDefined();
|
|
32
|
+
await expect(
|
|
31
33
|
cli.lintText(`const foo = 'bar';`, { filePath: 'index.ts' })
|
|
32
|
-
).
|
|
34
|
+
).resolves.toBeDefined();
|
|
33
35
|
});
|
|
34
36
|
|
|
35
|
-
it('jest config working', () => {
|
|
37
|
+
it('jest config working', async () => {
|
|
36
38
|
const cli = new ESLint({
|
|
37
|
-
|
|
39
|
+
overrideConfigFile: true,
|
|
40
|
+
overrideConfig: jestConfig,
|
|
38
41
|
cwd: path.join(__dirname, '..'),
|
|
39
|
-
baseConfig: {
|
|
40
|
-
extends: ['./jest'],
|
|
41
|
-
},
|
|
42
42
|
});
|
|
43
43
|
|
|
44
|
-
expect(
|
|
45
|
-
expect(
|
|
44
|
+
await expect(cli.lintText(`const foo = 'bar';`)).resolves.toBeDefined();
|
|
45
|
+
await expect(
|
|
46
46
|
cli.lintText(`const foo = 'bar';`, { filePath: 'index.ts' })
|
|
47
|
-
).
|
|
48
|
-
expect(
|
|
47
|
+
).resolves.toBeDefined();
|
|
48
|
+
await expect(
|
|
49
49
|
cli.lintText(`const foo = 'bar';`, { filePath: 'index.spec.ts' })
|
|
50
|
-
).
|
|
50
|
+
).resolves.toBeDefined();
|
|
51
51
|
});
|
|
52
52
|
});
|