1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-22 19:26:13 +02:00
metamask-extension/.eslintrc.js
Daniel e7d7d24d83
Reduce calls of the /featureFlag API (#10859)
* Remove periodic calls to the /featureFlag API

* Always show the Swap button on the main page

* Check if the Swaps feature is enabled, show loading animation while waiting

* Reuse an existing useEffect call

* Use ‘isFeatureFlagLoaded’ in React’s state, resolve lint issues

* Add a watch mode for Jest testing

* Add unit tests for Swaps: fetchSwapsLiveness, add /ducks/swaps into Jest testing

* Remove Swaps Jest tests from Mocha’s ESLint rules

* Ignore Swaps Jest tests while running Mocha, update paths

* Increase test coverage to the current max

* Fix ESLint issues for Swaps

* Enable the Swaps feature by default and after state reset, remove loading screen before seeing Swaps

* Update Jest config, fix tests

* Update Jest coverage threshold to the current maximum

* Update ESLint rule in jest.config.js

* Disable the “Review Swap” button if the feature flag hasn’t loaded yet

* Update jest threshold
2021-04-14 04:46:27 -02:30

158 lines
3.6 KiB
JavaScript

module.exports = {
root: true,
parser: '@babel/eslint-parser',
parserOptions: {
sourceType: 'module',
ecmaVersion: 2017,
ecmaFeatures: {
experimentalObjectRestSpread: true,
impliedStrict: true,
modules: true,
blockBindings: true,
arrowFunctions: true,
objectLiteralShorthandMethods: true,
objectLiteralShorthandProperties: true,
templateStrings: true,
classes: true,
jsx: true,
},
},
ignorePatterns: [
'!.eslintrc.js',
'node_modules/**',
'dist/**',
'builds/**',
'test-*/**',
'docs/**',
'coverage/',
'jest-coverage/',
'development/chromereload.js',
'app/vendor/**',
'test/e2e/send-eth-with-private-key-test/**',
'nyc_output/**',
'.vscode/**',
'lavamoat/*/policy.json',
],
extends: [
'@metamask/eslint-config',
'@metamask/eslint-config-nodejs',
'prettier',
],
plugins: ['@babel', 'import', 'prettier'],
globals: {
document: 'readonly',
window: 'readonly',
},
rules: {
'default-param-last': 'off',
'prefer-object-spread': 'error',
'require-atomic-updates': 'off',
'import/no-unassigned-import': 'off',
'no-invalid-this': 'off',
'@babel/no-invalid-this': 'error',
// Prettier handles this
'@babel/semi': 'off',
'node/no-process-env': 'off',
// TODO: re-enable these rules
'node/no-sync': 'off',
'node/no-unpublished-import': 'off',
'node/no-unpublished-require': 'off',
},
overrides: [
{
files: ['ui/**/*.js', 'test/lib/render-helpers.js'],
plugins: ['react'],
extends: ['plugin:react/recommended', 'plugin:react-hooks/recommended'],
rules: {
'react/no-unused-prop-types': 'error',
'react/no-unused-state': 'error',
'react/jsx-boolean-value': 'error',
'react/jsx-curly-brace-presence': [
'error',
{ props: 'never', children: 'never' },
],
'react/no-deprecated': 'error',
'react/default-props-match-prop-types': 'error',
'react/jsx-no-duplicate-props': 'error',
},
},
{
files: ['test/e2e/**/*.spec.js'],
extends: ['@metamask/eslint-config-mocha'],
rules: {
'mocha/no-hooks-for-single-case': 'off',
'mocha/no-setup-in-describe': 'off',
},
},
{
files: ['app/scripts/migrations/*.js', '*.stories.js'],
rules: {
'import/no-anonymous-default-export': ['error', { allowObject: true }],
},
},
{
files: ['app/scripts/migrations/*.js'],
rules: {
'node/global-require': 'off',
},
},
{
files: ['**/*.test.js'],
excludedFiles: ['ui/app/**/swaps/**/*.test.js'],
extends: ['@metamask/eslint-config-mocha'],
rules: {
'mocha/no-setup-in-describe': 'off',
},
},
{
files: ['ui/app/**/swaps/**/*.test.js'],
extends: ['@metamask/eslint-config-jest'],
},
{
files: [
'development/**/*.js',
'test/e2e/benchmark.js',
'test/helpers/setup-helper.js',
],
rules: {
'node/no-process-exit': 'off',
'node/shebang': 'off',
},
},
{
files: [
'.eslintrc.js',
'babel.config.js',
'nyc.config.js',
'stylelint.config.js',
'app/scripts/runLockdown.js',
'development/**/*.js',
'test/e2e/**/*.js',
'test/lib/wait-until-called.js',
'test/env.js',
'test/setup.js',
'jest.config.js',
],
parserOptions: {
sourceType: 'script',
},
},
],
settings: {
react: {
version: 'detect',
},
},
};