Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
root: true,
extends: [
'./config/index.js',
'./config/nodejs.js',
],
}
128 changes: 127 additions & 1 deletion config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,130 @@ module.exports = {
'es6': true,
'shared-node-browser': true,
},
};
rules: {
'accessor-pairs': 'error',
'arrow-spacing': ['error', { 'before': true, 'after': true }],
'block-spacing': ['error', 'always'],
'brace-style': 'error',
'camelcase': ['error', { 'properties': 'never', 'allow': ['^UNSAFE_'] }],
'comma-dangle': ['error', 'always-multiline'],
'comma-spacing': ['error', { 'before': false, 'after': true }],
'comma-style': ['error', 'last'],
'constructor-super': 'error',
'curly': 'error',
'default-case': 'error',
'dot-location': ['error', 'property'],
'eol-last': 'error',
'eqeqeq': ['error', 'allow-null'],
'generator-star-spacing': ['error', { 'before': true, 'after': true }],
'handle-callback-err': ['error', '^(err|error)$' ],
'indent': ['error', 2, { 'SwitchCase': 1 }],
'jsx-quotes': ['error', 'prefer-double'],
'key-spacing': 'error',
'keyword-spacing': ['error', { 'before': true, 'after': true }],
'new-cap': ['error', { 'newIsCap': true, 'capIsNew': false }],
'new-parens': 'error',
'no-array-constructor': 'error',
'no-async-promise-executor': 'error',
'no-caller': 'error',
'no-class-assign': 'error',
'no-cond-assign': 'error',
'no-confusing-arrow': 'error',
'no-const-assign': 'error',
'no-control-regex': 'error',
'no-debugger': 'error',
'no-delete-var': 'error',
'no-dupe-args': 'error',
'no-dupe-class-members': 'error',
'no-dupe-keys': 'error',
'no-duplicate-case': 'error',
'no-duplicate-imports': 'error',
'no-empty-character-class': 'error',
'no-empty-pattern': 'error',
'no-eval': 'error',
'no-ex-assign': 'error',
'no-extend-native': 'error',
'no-extra-bind': 'error',
'no-extra-boolean-cast': 'error',
'no-extra-parens': ['error', 'functions'],
'no-fallthrough': 'error',
'no-floating-decimal': 'error',
'no-func-assign': 'error',
'no-implied-eval': 'error',
'no-inner-declarations': ['error', 'functions'],
'no-invalid-regexp': 'error',
'no-irregular-whitespace': 'error',
'no-iterator': 'error',
'no-label-var': 'error',
'no-labels': ['error', { 'allowLoop': false, 'allowSwitch': false }],
'no-lone-blocks': 'error',
'no-mixed-spaces-and-tabs': 'error',
'no-multi-spaces': 'error',
'no-multi-str': 'error',
'no-multiple-empty-lines': ['error', { 'max': 2 }],
'no-native-reassign': 'error',
'no-negated-in-lhs': 'error',
'no-new': 'error',
'no-new-func': 'error',
'no-new-object': 'error',
'no-new-require': 'error',
'no-new-symbol': 'error',
'no-new-wrappers': 'error',
'no-obj-calls': 'error',
'no-octal': 'error',
'no-octal-escape': 'error',
'no-path-concat': 'error',
'no-proto': 'error',
'no-redeclare': 'error',
'no-regex-spaces': 'error',
'no-restricted-globals': ['error', 'event'],
'no-return-assign': ['error', 'except-parens'],
'no-self-assign': 'error',
'no-self-compare': 'error',
'no-sequences': 'error',
'no-shadow-restricted-names': 'error',
'no-spaced-func': 'error',
'no-sparse-arrays': 'error',
'no-this-before-super': 'error',
'no-throw-literal': 'error',
'no-trailing-spaces': 'error',
'no-undef': 'error',
'no-undef-init': 'error',
'no-unexpected-multiline': 'error',
'no-unmodified-loop-condition': 'error',
'no-unneeded-ternary': ['error', { 'defaultAssignment': false }],
'no-unreachable': 'error',
'no-unsafe-finally': 'error',
'no-unused-expressions': ['error', { 'allowShortCircuit': true, 'allowTernary': true }],
'no-unused-vars': ['error', { 'vars': 'all', 'args': 'all', 'argsIgnorePattern': '[_]+' }],
'no-use-before-define': ['error', { 'functions': false }],
'no-useless-call': 'error',
'no-useless-computed-key': 'error',
'no-useless-constructor': 'error',
'no-useless-escape': 'error',
'no-var': 'error',
'no-whitespace-before-property': 'error',
'no-with': 'error',
'object-curly-spacing': ['error', 'always'],
'one-var': ['error', { 'initialized': 'never' }],
'operator-linebreak': ['error', 'after', { 'overrides': { '?': 'ignore', ':': 'ignore' } }],
'padded-blocks': 'off',
'prefer-const': 'error',
'quotes': ['error', 'single', { 'avoidEscape': true, 'allowTemplateLiterals': true }],
'semi': ['error', 'never'],
'semi-spacing': ['error', { 'before': false, 'after': true }],
'space-before-blocks': ['error', 'always'],
'space-before-function-paren': ['error', 'always'],
'space-in-parens': ['error', 'never'],
'space-infix-ops': 'error',
'space-unary-ops': ['error', { 'words': true, 'nonwords': false }],
'spaced-comment': ['error', 'always', { 'markers': ['global', 'globals', 'eslint', 'eslint-disable', '*package', '!', ','], 'exceptions': ['=', '-'] } ],
'strict': 'off',
'template-curly-spacing': ['error', 'never'],
'use-isnan': 'error',
'valid-typeof': 'error',
'wrap-iife': ['error', 'any'],
'yield-star-spacing': ['error', 'both'],
'yoda': ['error', 'never'],
},
}
50 changes: 50 additions & 0 deletions config/jest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
module.exports = {
plugins: [
'jest',
],
env: {
'jest/globals': true,
},
rules: {
'jest/consistent-test-it': ['error', { 'fn': 'it' }],
'jest/expect-expect': 'error',
'jest/lowercase-name': 'error',
'jest/no-alias-methods': 'error',
'jest/no-commented-out-tests': 'error',
'jest/no-disabled-tests': 'error',
'jest/no-duplicate-hooks': 'error',
'jest/no-expect-resolves': 'error',
'jest/no-export': 'error',
'jest/no-focused-tests': 'error',
'jest/no-hooks': 'off',
'jest/no-identical-title': 'error',
'jest/no-if': 'error',
'jest/no-jasmine-globals': 'error',
'jest/no-jest-import': 'error',
'jest/no-large-snapshots': 'off',
'jest/no-mocks-import': 'error',
'jest/no-standalone-expect': 'error',
'jest/no-test-callback': 'error',
'jest/no-test-prefixes': 'error',
'jest/no-test-return-statement': 'error',
'jest/no-truthy-falsy': 'error',
'jest/no-try-expect': 'error',
'jest/prefer-called-with': 'off',
'jest/prefer-expect-assertions': 'off',
'jest/prefer-hooks-on-top': 'error',
'jest/prefer-inline-snapshots': 'off',
'jest/prefer-spy-on': 'error',
'jest/prefer-strict-equal': 'error',
'jest/prefer-to-be-null': 'error',
'jest/prefer-to-be-undefined': 'error',
'jest/prefer-to-contain': 'error',
'jest/prefer-to-have-length': 'error',
'jest/prefer-todo': 'error',
'jest/require-top-level-describe': 'error',
'jest/require-to-throw-message': 'error',
'jest/valid-describe': 'error',
'jest/valid-expect-in-promise': 'error',
'jest/valid-expect': ['error', { 'alwaysAwait': true }],
'jest/valid-title': 'error',
},
}
5 changes: 5 additions & 0 deletions config/nodejs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
env: {
node: true,
},
}
74 changes: 74 additions & 0 deletions config/typescript.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
plugins: [
'@typescript-eslint',
],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
],
rules: {
// Rules from @typescript-eslint/eslint-plugin
'@typescript-eslint/array-type': 'error',
'@typescript-eslint/consistent-type-definitions': ['error', 'type'],
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/prefer-for-of': 'error',
'@typescript-eslint/prefer-function-type': 'error',
'@typescript-eslint/prefer-optional-chain': 'error',
'@typescript-eslint/triple-slash-reference': 'error',
'@typescript-eslint/type-annotation-spacing': 'error',
'@typescript-eslint/typedef': 'off',
'@typescript-eslint/unified-signatures': 'error',

// "Extension Rules" from @typescript-eslint/eslint-plugin
'@typescript-eslint/brace-style': 'error',
'brace-style': 'off',

'@typescript-eslint/default-param-last': 'error',
'default-param-last': 'off',

'@typescript-eslint/func-call-spacing': 'error',
'func-call-spacing': 'off',

'@typescript-eslint/indent': ['error', 2, { 'SwitchCase': 1 }],
'indent': 'off',

'@typescript-eslint/no-array-constructor': 'error',
'no-array-constructor': 'off',

'@typescript-eslint/no-empty-function': 'error',
'no-empty-function': 'off',

'@typescript-eslint/no-extra-parens': 'error',
'no-extra-parens': 'off',

'@typescript-eslint/no-extra-semi': 'error',
'no-extra-semi': 'off',

'@typescript-eslint/no-magic-numbers': 'off',
'no-magic-numbers': 'off',

'@typescript-eslint/no-unused-expressions': ['error', { 'allowShortCircuit': true, 'allowTernary': true }],
'no-unused-expressions': 'off',

'@typescript-eslint/no-unused-vars': ['error', { 'vars': 'all', 'args': 'all', 'argsIgnorePattern': '[_]+' }],
'no-unused-vars': 'off',

'@typescript-eslint/no-use-before-define': ['error', { 'functions': false }],
'no-use-before-define': 'off',

'@typescript-eslint/no-useless-constructor': 'error',
'no-useless-constructor': 'off',

'@typescript-eslint/quotes': ['error', 'single', { 'avoidEscape': true, 'allowTemplateLiterals': true }],
'quotes': 'off',

'@typescript-eslint/semi': ['error', 'always'],
'semi': 'off',

'@typescript-eslint/space-before-function-paren': ['error', 'always'],
'space-before-function-paren': 'off',
},
}
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"access": "public"
},
"scripts": {
"test": "echo \"Error: no test specified\""
"test": "eslint ."
},
"repository": {
"type": "git",
Expand All @@ -21,6 +21,10 @@
},
"homepage": "https://github.com/MetaMask/eslint-config#readme",
"devDependencies": {
"eslint": "^6.8.0"
"@typescript-eslint/eslint-plugin": "^2.17.0",
"@typescript-eslint/parser": "^2.17.0",
"eslint": "^6.8.0",
"eslint-plugin-jest": "^23.6.0",
"typescript": "^3.7.5"
}
}
Loading