Skip to content
This repository was archived by the owner on Mar 29, 2020. It is now read-only.

Commit ebcaac2

Browse files
committed
feat: remove overrides from jest and typescript configs
BREAKING CHANGE: jest and typescript configs will now need to be explicitly set up to apply only to certain files
1 parent c693d28 commit ebcaac2

File tree

3 files changed

+89
-84
lines changed

3 files changed

+89
-84
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,21 @@ module.exports = {
4949
};
5050
```
5151

52+
You can also use [ESLint@4 overrides](http://eslint.org/docs/user-guide/configuring#configuration-based-on-glob-patterns) to apply a config only to certain files. For example:
53+
54+
```js
55+
module.exports = {
56+
...
57+
overrides: [
58+
Object.assign(
59+
{
60+
files: ['**/__tests__/*-test.js', '**/__mocks__/*.js'],
61+
},
62+
require('eslint-config-anvilabs/jest')
63+
),
64+
],
65+
};
66+
5267
Available configs include:
5368

5469
- `'anvilabs/babel'` for usage with [babel transformations](https://github.com/babel/babel-eslint)

jest.js

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
module.exports = {
2-
overrides: [
3-
{
4-
plugins: ['jest'],
5-
files: '**/*-test.{js,ts}',
6-
env: {
7-
'jest/globals': true,
8-
},
9-
rules: {
10-
'jest/no-disabled-tests': 'warn',
11-
'jest/no-focused-tests': 'error',
12-
'jest/no-identical-title': 'error',
13-
'jest/valid-expect': 'error',
14-
},
15-
},
16-
],
2+
plugins: ['jest'],
3+
env: {
4+
'jest/globals': true,
5+
},
6+
rules: {
7+
'jest/no-disabled-tests': 'warn',
8+
'jest/no-focused-tests': 'error',
9+
'jest/no-identical-title': 'error',
10+
'jest/valid-expect': 'error',
11+
},
1712
};

typescript.js

Lines changed: 64 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,69 @@
11
module.exports = {
2-
overrides: [
3-
{
4-
files: '**/*.ts',
5-
plugins: ['typescript'],
6-
parser: 'typescript-eslint-parser',
7-
settings: {
8-
'import/resolver': {
9-
node: {
10-
extensions: ['.js', '.ts', '.json'],
11-
},
2+
plugins: ['typescript'],
3+
parser: 'typescript-eslint-parser',
4+
settings: {
5+
'import/resolver': {
6+
node: {
7+
extensions: ['.js', '.ts', '.json'],
8+
},
9+
},
10+
'import/extensions': ['.js', '.ts'],
11+
},
12+
rules: {
13+
'no-undef': 'off', // conflicts with typescript
14+
'no-unused-vars': 'off', // conflicts with typescript
15+
'no-useless-constructor': 'off', // conflicts with typescript
16+
'spaced-comment': [
17+
'error',
18+
'always',
19+
{
20+
line: {
21+
exceptions: ['-', '+'],
22+
markers: ['=', '!', '/'], // space here to support sprockets directives
23+
},
24+
block: {
25+
exceptions: ['-', '+'],
26+
markers: ['=', '!'], // space here to support sprockets directives
27+
balanced: true,
1228
},
13-
'import/extensions': ['.js', '.ts'],
1429
},
15-
rules: {
16-
'no-undef': 'off', // conflicts with typescript
17-
'no-unused-vars': 'off', // conflicts with typescript
18-
'no-useless-constructor': 'off', // conflicts with typescript
19-
'spaced-comment': [
20-
'error',
21-
'always',
22-
{
23-
line: {
24-
exceptions: ['-', '+'],
25-
markers: ['=', '!', '/'], // space here to support sprockets directives
26-
},
27-
block: {
28-
exceptions: ['-', '+'],
29-
markers: ['=', '!'], // space here to support sprockets directives
30-
balanced: true,
31-
},
32-
},
33-
],
34-
strict: 'off', // conflicts with typescript
35-
// https://github.com/benmosher/eslint-plugin-import
36-
'import/extensions': [
37-
'error',
38-
'always',
39-
{
40-
js: 'never',
41-
ts: 'never',
42-
},
43-
],
44-
'import/no-named-as-default-member': 'off', // conflicts with typescript
45-
'import/no-named-as-default': 'off', // conflicts with typescript
46-
// https://github.com/not-an-aardvark/eslint-plugin-prettier
47-
'prettier/prettier': [
48-
'error',
49-
{
50-
useTabs: false,
51-
printWidth: 80,
52-
tabWidth: 2,
53-
singleQuote: true,
54-
trailingComma: 'all',
55-
bracketSpacing: false,
56-
jsxBracketSameLine: false,
57-
parser: 'typescript',
58-
semi: true,
59-
},
60-
],
61-
// https://github.com/nzakas/eslint-plugin-typescript
62-
'typescript/explicit-member-accessibility': 'error',
63-
'typescript/interface-name-prefix': 'error',
64-
'typescript/no-angle-bracket-type-assertion': 'error',
65-
'typescript/no-explicit-any': 'error',
66-
'typescript/no-namespace': ['error', {allowDefinitionFiles: true}],
67-
'typescript/no-triple-slash-reference': 'error',
68-
'typescript/no-unused-vars': 'error',
69-
'typescript/prefer-namespace-keyword': 'error',
70-
'typescript/type-annotation-spacing': 'off',
30+
],
31+
strict: 'off', // conflicts with typescript
32+
// https://github.com/benmosher/eslint-plugin-import
33+
'import/extensions': [
34+
'error',
35+
'always',
36+
{
37+
js: 'never',
38+
ts: 'never',
7139
},
72-
},
73-
],
40+
],
41+
'import/no-named-as-default-member': 'off', // conflicts with typescript
42+
'import/no-named-as-default': 'off', // conflicts with typescript
43+
// https://github.com/not-an-aardvark/eslint-plugin-prettier
44+
'prettier/prettier': [
45+
'error',
46+
{
47+
useTabs: false,
48+
printWidth: 80,
49+
tabWidth: 2,
50+
singleQuote: true,
51+
trailingComma: 'all',
52+
bracketSpacing: false,
53+
jsxBracketSameLine: false,
54+
parser: 'typescript',
55+
semi: true,
56+
},
57+
],
58+
// https://github.com/nzakas/eslint-plugin-typescript
59+
'typescript/explicit-member-accessibility': 'error',
60+
'typescript/interface-name-prefix': 'error',
61+
'typescript/no-angle-bracket-type-assertion': 'error',
62+
'typescript/no-explicit-any': 'error',
63+
'typescript/no-namespace': ['error', {allowDefinitionFiles: true}],
64+
'typescript/no-triple-slash-reference': 'error',
65+
'typescript/no-unused-vars': 'error',
66+
'typescript/prefer-namespace-keyword': 'error',
67+
'typescript/type-annotation-spacing': 'off',
68+
},
7469
};

0 commit comments

Comments
 (0)