Skip to content

Commit bdf735c

Browse files
committed
Add base, TypeScript, and Jest config
1 parent c159068 commit bdf735c

File tree

7 files changed

+389
-6
lines changed

7 files changed

+389
-6
lines changed

.eslintrc.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
root: true,
3+
extends: [
4+
'./config/index.js',
5+
'./config/nodejs.js',
6+
],
7+
}

config/index.js

Lines changed: 127 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,130 @@ module.exports = {
33
'es6': true,
44
'shared-node-browser': true,
55
},
6-
};
6+
rules: {
7+
'accessor-pairs': 2,
8+
'arrow-spacing': [2, { 'before': true, 'after': true }],
9+
'block-spacing': [2, 'always'],
10+
'brace-style': 2,
11+
'camelcase': [2, { 'properties': 'never', 'allow': ['^UNSAFE_'] }],
12+
'comma-dangle': [2, 'always-multiline'],
13+
'comma-spacing': [2, { 'before': false, 'after': true }],
14+
'comma-style': [2, 'last'],
15+
'constructor-super': 2,
16+
'curly': 2,
17+
'default-case': 2,
18+
'dot-location': [2, 'property'],
19+
'eol-last': 2,
20+
'eqeqeq': [2, 'allow-null'],
21+
'generator-star-spacing': [2, { 'before': true, 'after': true }],
22+
'handle-callback-err': [2, '^(err|error)$' ],
23+
'indent': [2, 2, { 'SwitchCase': 1 }],
24+
'jsx-quotes': [2, 'prefer-double'],
25+
'key-spacing': 2,
26+
'keyword-spacing': [2, { 'before': true, 'after': true }],
27+
'new-cap': [2, { 'newIsCap': true, 'capIsNew': false }],
28+
'new-parens': 2,
29+
'no-array-constructor': 2,
30+
'no-async-promise-executor': 2,
31+
'no-caller': 2,
32+
'no-class-assign': 2,
33+
'no-cond-assign': 2,
34+
'no-confusing-arrow': 2,
35+
'no-const-assign': 2,
36+
'no-control-regex': 2,
37+
'no-debugger': 2,
38+
'no-delete-var': 2,
39+
'no-dupe-args': 2,
40+
'no-dupe-class-members': 2,
41+
'no-dupe-keys': 2,
42+
'no-duplicate-case': 2,
43+
'no-duplicate-imports': 2,
44+
'no-empty-character-class': 2,
45+
'no-empty-pattern': 2,
46+
'no-eval': 2,
47+
'no-ex-assign': 2,
48+
'no-extend-native': 2,
49+
'no-extra-bind': 2,
50+
'no-extra-boolean-cast': 2,
51+
'no-extra-parens': [2, 'functions'],
52+
'no-fallthrough': 2,
53+
'no-floating-decimal': 2,
54+
'no-func-assign': 2,
55+
'no-implied-eval': 2,
56+
'no-inner-declarations': [2, 'functions'],
57+
'no-invalid-regexp': 2,
58+
'no-irregular-whitespace': 2,
59+
'no-iterator': 2,
60+
'no-label-var': 2,
61+
'no-labels': [2, { 'allowLoop': false, 'allowSwitch': false }],
62+
'no-lone-blocks': 2,
63+
'no-mixed-spaces-and-tabs': 2,
64+
'no-multi-spaces': 2,
65+
'no-multi-str': 2,
66+
'no-multiple-empty-lines': [2, { 'max': 2 }],
67+
'no-native-reassign': 2,
68+
'no-negated-in-lhs': 2,
69+
'no-new': 2,
70+
'no-new-func': 2,
71+
'no-new-object': 2,
72+
'no-new-require': 2,
73+
'no-new-symbol': 2,
74+
'no-new-wrappers': 2,
75+
'no-obj-calls': 2,
76+
'no-octal': 2,
77+
'no-octal-escape': 2,
78+
'no-path-concat': 2,
79+
'no-proto': 2,
80+
'no-redeclare': 2,
81+
'no-regex-spaces': 2,
82+
'no-restricted-globals': [2, 'event'],
83+
'no-return-assign': [2, 'except-parens'],
84+
'no-self-assign': 2,
85+
'no-self-compare': 2,
86+
'no-sequences': 2,
87+
'no-shadow-restricted-names': 2,
88+
'no-spaced-func': 2,
89+
'no-sparse-arrays': 2,
90+
'no-this-before-super': 2,
91+
'no-throw-literal': 2,
92+
'no-trailing-spaces': 2,
93+
'no-undef': 2,
94+
'no-undef-init': 2,
95+
'no-unexpected-multiline': 2,
96+
'no-unmodified-loop-condition': 2,
97+
'no-unneeded-ternary': [2, { 'defaultAssignment': false }],
98+
'no-unreachable': 2,
99+
'no-unsafe-finally': 2,
100+
'no-unused-expressions': [2, { 'allowShortCircuit': true, 'allowTernary': true }],
101+
'no-unused-vars': [2, { 'vars': 'all', 'args': 'all', 'argsIgnorePattern': '[_]+' }],
102+
'no-use-before-define': [2, { 'functions': false }],
103+
'no-useless-call': 2,
104+
'no-useless-computed-key': 2,
105+
'no-useless-constructor': 2,
106+
'no-useless-escape': 2,
107+
'no-var': 2,
108+
'no-whitespace-before-property': 2,
109+
'no-with': 2,
110+
'object-curly-spacing': [2, 'always'],
111+
'one-var': [2, { 'initialized': 'never' }],
112+
'operator-linebreak': [2, 'after', { 'overrides': { '?': 'ignore', ':': 'ignore' } }],
113+
'padded-blocks': 0,
114+
'prefer-const': 2,
115+
'quotes': [2, 'single', { 'avoidEscape': true, 'allowTemplateLiterals': true }],
116+
'semi': [2, 'never'],
117+
'semi-spacing': [2, { 'before': false, 'after': true }],
118+
'space-before-blocks': [2, 'always'],
119+
'space-before-function-paren': [2, 'always'],
120+
'space-in-parens': [2, 'never'],
121+
'space-infix-ops': 2,
122+
'space-unary-ops': [2, { 'words': true, 'nonwords': false }],
123+
'spaced-comment': [2, 'always', { 'markers': ['global', 'globals', 'eslint', 'eslint-disable', '*package', '!', ','], 'exceptions': ['=', '-'] } ],
124+
'strict': 0,
125+
'template-curly-spacing': [2, 'never'],
126+
'use-isnan': 2,
127+
'valid-typeof': 2,
128+
'wrap-iife': [2, 'any'],
129+
'yield-star-spacing': [2, 'both'],
130+
'yoda': [2, 'never'],
131+
},
132+
}

config/jest.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
module.exports = {
2+
plugins: [
3+
'jest',
4+
],
5+
env: {
6+
'jest/globals': true,
7+
},
8+
rules: {
9+
'jest/consistent-test-it': [2, { 'fn': 'it' }],
10+
'jest/expect-expect': 2,
11+
'jest/lowercase-name': 2,
12+
'jest/no-alias-methods': 0,
13+
'jest/no-commented-out-tests': 2,
14+
'jest/no-disabled-tests': 2,
15+
'jest/no-duplicate-hooks': 2,
16+
'jest/no-expect-resolves': 2,
17+
'jest/no-export': 2,
18+
'jest/no-focused-tests': 2,
19+
'jest/no-hooks': 0,
20+
'jest/no-identical-title': 2,
21+
'jest/no-if': 2,
22+
'jest/no-jasmine-globals': 2,
23+
'jest/no-jest-import': 2,
24+
'jest/no-large-snapshots': 0,
25+
'jest/no-mocks-import': 2,
26+
'jest/no-standalone-expect': 2,
27+
'jest/no-test-callback': 2,
28+
'jest/no-test-prefixes': 2,
29+
'jest/no-test-return-statement': 2,
30+
'jest/no-truthy-falsy': 2,
31+
'jest/no-try-expect': 2,
32+
'jest/prefer-called-with': 0,
33+
'jest/prefer-expect-assertions': 0,
34+
'jest/prefer-hooks-on-top': 2,
35+
'jest/prefer-inline-snapshots': 0,
36+
'jest/prefer-spy-on': 2,
37+
'jest/prefer-strict-equal': 2,
38+
'jest/prefer-to-be-null': 2,
39+
'jest/prefer-to-be-undefined': 2,
40+
'jest/prefer-to-contain': 2,
41+
'jest/prefer-to-have-length': 2,
42+
'jest/prefer-todo': 2,
43+
'jest/require-top-level-describe': 2,
44+
'jest/require-to-throw-message': 2,
45+
'jest/valid-describe': 2,
46+
'jest/valid-expect-in-promise': 2,
47+
'jest/valid-expect': [2, { 'alwaysAwait': true }],
48+
'jest/valid-title': 2,
49+
},
50+
}

config/nodejs.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
env: {
3+
node: true,
4+
},
5+
}

config/typescript.js

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
module.exports = {
2+
root: true,
3+
parser: '@typescript-eslint/parser',
4+
plugins: [
5+
'@typescript-eslint',
6+
],
7+
extends: [
8+
'eslint:recommended',
9+
'plugin:@typescript-eslint/eslint-recommended',
10+
'plugin:@typescript-eslint/recommended',
11+
],
12+
rules: {
13+
// Rules from @typescript-eslint/eslint-plugin
14+
'@typescript-eslint/array-type': 2,
15+
'@typescript-eslint/consistent-type-definitions': [2, 'type'],
16+
'@typescript-eslint/no-explicit-any': 0,
17+
'@typescript-eslint/prefer-for-of': 0,
18+
'@typescript-eslint/prefer-function-type': 2,
19+
'@typescript-eslint/prefer-optional-chain': 2,
20+
'@typescript-eslint/triple-slash-reference': 2,
21+
'@typescript-eslint/type-annotation-spacing': 2,
22+
'@typescript-eslint/typedef': 0,
23+
'@typescript-eslint/unified-signatures': 2,
24+
25+
// "Extension Rules" from @typescript-eslint/eslint-plugin
26+
'@typescript-eslint/brace-style': 2,
27+
'brace-style': 0,
28+
29+
'@typescript-eslint/default-param-last': 2,
30+
'default-param-last': 0,
31+
32+
'@typescript-eslint/func-call-spacing': 2,
33+
'func-call-spacing': 0,
34+
35+
'@typescript-eslint/indent': [2, 2, { 'SwitchCase': 1 }],
36+
'indent': 0,
37+
38+
'@typescript-eslint/no-array-constructor': 2,
39+
'no-array-constructor': 0,
40+
41+
'@typescript-eslint/no-empty-function': 2,
42+
'no-empty-function': 0,
43+
44+
'@typescript-eslint/no-extra-parens': 0,
45+
'no-extra-parens': 0,
46+
47+
'@typescript-eslint/no-extra-semi': 2,
48+
'no-extra-semi': 0,
49+
50+
'@typescript-eslint/no-magic-numbers': 0,
51+
'no-magic-numbers': 0,
52+
53+
'@typescript-eslint/no-unused-expressions': [2, { 'allowShortCircuit': true, 'allowTernary': true }],
54+
'no-unused-expressions': 0,
55+
56+
'@typescript-eslint/no-unused-vars': [2, { 'vars': 'all', 'args': 'all', 'argsIgnorePattern': '[_]+' }],
57+
'no-unused-vars': 0,
58+
59+
'@typescript-eslint/no-use-before-define': [2, { 'functions': false }],
60+
'no-use-before-define': 0,
61+
62+
'@typescript-eslint/no-useless-constructor': 2,
63+
'no-useless-constructor': 0,
64+
65+
'@typescript-eslint/quotes': [2, 'single', { 'avoidEscape': true, 'allowTemplateLiterals': true }],
66+
'quotes': 0,
67+
68+
'@typescript-eslint/semi': [2, 'always'],
69+
'semi': 0,
70+
71+
'@typescript-eslint/space-before-function-paren': [2, 'always'],
72+
'space-before-function-paren': 0,
73+
},
74+
}

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
},
2222
"homepage": "https://github.com/MetaMask/eslint-config#readme",
2323
"devDependencies": {
24-
"eslint": "^6.8.0"
24+
"@typescript-eslint/eslint-plugin": "^2.17.0",
25+
"@typescript-eslint/parser": "^2.17.0",
26+
"eslint": "^6.8.0",
27+
"eslint-plugin-jest": "^23.6.0",
28+
"typescript": "^3.7.5"
2529
}
2630
}

0 commit comments

Comments
 (0)