Lints test/utils (#1575)

* rename model tests

* rename util tests

* turn off `any` complaints in linter

* other linter changes

* fix xrp <-> drops methods

* lint generateAddress

* fix rest of tests
This commit is contained in:
Mayukha Vadari
2021-09-01 14:15:49 -04:00
parent b53bc2bc97
commit 91cc9e0461
27 changed files with 129 additions and 123 deletions

View File

@@ -2,98 +2,105 @@ module.exports = {
root: true,
// Make ESLint compatible with TypeScript
parser: '@typescript-eslint/parser',
parser: "@typescript-eslint/parser",
parserOptions: {
// Enable linting rules with type information from our tsconfig
tsconfigRootDir: __dirname,
project: ['./tsconfig.eslint.json'],
project: ["./tsconfig.eslint.json"],
// Allow the use of imports / ES modules
sourceType: 'module',
sourceType: "module",
ecmaFeatures: {
// Enable global strict mode
impliedStrict: true
}
impliedStrict: true,
},
},
// Specify global variables that are predefined
env: {
node: true, // Enable node global variables & Node.js scoping
es2020: true // Add all ECMAScript 2020 globals and automatically set the ecmaVersion parser option to ES2020
es2020: true, // Add all ECMAScript 2020 globals and automatically set the ecmaVersion parser option to ES2020
},
plugins: [],
extends: ['@xrplf/eslint-config/base', 'plugin:mocha/recommended'],
extends: ["@xrplf/eslint-config/base", "plugin:mocha/recommended"],
rules: {
// Certain rippled APIs require snake_case naming
'@typescript-eslint/naming-convention': [
'error',
"@typescript-eslint/naming-convention": [
"error",
{
selector: 'interface',
format: ['PascalCase']
selector: "interface",
format: ["PascalCase"],
},
{
selector: 'interface',
format: ['snake_case']
}
selector: "interface",
format: ["snake_case"],
},
],
// Ignore type imports when counting dependencies.
'import/max-dependencies': [
'error',
"import/max-dependencies": [
"error",
{
max: 5,
ignoreTypeImports: true
}
ignoreTypeImports: true,
},
],
// Removes comments and blank lines from the max-line rules
'max-lines-per-function': [
'warn',
"max-lines-per-function": [
"warn",
{
max: 50,
skipBlankLines: true,
skipComments: true
}
skipComments: true,
},
],
'max-lines': [
'warn',
"max-lines": [
"warn",
{
max: 250,
skipBlankLines: true,
skipComments: true
}
]
skipComments: true,
},
],
},
overrides: [
{
files: ['test/**/*.ts'],
files: ["test/**/*.ts"],
rules: {
// Removed the max for test files and test helper files, since tests usually need to import more things
'import/max-dependencies': 'off',
"import/max-dependencies": "off",
// describe blocks count as a function in Mocha tests, and can be insanely long
'max-lines-per-function': 'off',
"max-lines-per-function": "off",
// Tests can be very long turns off max-line count
'max-lines': 'off',
"max-lines": "off",
// We have lots of statements in tests
'max-statements': 'off',
"max-statements": "off",
// We have lots of magic numbers in tests
'no-magic-number': 'off'
}
"no-magic-number": "off",
"@typescript-eslint/no-magic-numbers": "off",
// We need to test things without type guards sometimes
"@typescript-eslint/no-unsafe-assignment": "off",
// We need to mess with internal things to generate certain testing situations
"@typescript-eslint/no-unsafe-member-access": "off",
},
},
{
files: ['.eslintrc.js', 'jest.config.js'],
files: [".eslintrc.js", "jest.config.js"],
rules: {
// Removed no-commonjs requirement as eslint must be in common js format
'import/no-commonjs': 'off',
"import/no-commonjs": "off",
// Removed this as eslint prevents us from doing this differently
'import/unambiguous': 'off'
}
}
]
}
"import/unambiguous": "off",
},
},
],
};