2017-01-11 00:28:22 +03:00
|
|
|
module.exports = {
|
2020-02-04 12:37:00 +03:00
|
|
|
root: true,
|
2017-10-01 08:06:06 +03:00
|
|
|
env: {
|
|
|
|
node: true,
|
|
|
|
},
|
2021-08-18 08:46:56 +03:00
|
|
|
plugins: ['@renovate'],
|
2019-07-08 16:58:12 +03:00
|
|
|
extends: [
|
2021-11-08 16:03:55 +03:00
|
|
|
'eslint:recommended',
|
2020-03-02 14:06:16 +03:00
|
|
|
'plugin:import/errors',
|
|
|
|
'plugin:import/warnings',
|
|
|
|
'plugin:import/typescript',
|
2020-05-18 15:33:44 +03:00
|
|
|
'plugin:jest/recommended',
|
|
|
|
'plugin:jest/style',
|
2020-02-12 12:22:38 +03:00
|
|
|
// https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin/src/configs
|
2020-02-04 12:37:00 +03:00
|
|
|
'plugin:@typescript-eslint/recommended',
|
2020-02-05 21:17:20 +03:00
|
|
|
'plugin:@typescript-eslint/recommended-requiring-type-checking',
|
2020-02-04 12:37:00 +03:00
|
|
|
'plugin:promise/recommended',
|
2019-07-08 16:58:12 +03:00
|
|
|
'prettier',
|
|
|
|
],
|
2019-04-26 13:59:51 +03:00
|
|
|
parserOptions: {
|
2019-05-21 18:23:30 +03:00
|
|
|
ecmaVersion: 9,
|
2020-02-04 12:37:00 +03:00
|
|
|
tsconfigRootDir: __dirname,
|
2020-03-24 09:17:59 +03:00
|
|
|
project: ['./tsconfig.lint.json'],
|
2020-03-06 11:31:47 +03:00
|
|
|
extraFileExtensions: ['.mjs'],
|
2019-04-26 13:59:51 +03:00
|
|
|
},
|
2017-10-01 08:06:06 +03:00
|
|
|
rules: {
|
2020-02-04 12:37:00 +03:00
|
|
|
/*
|
|
|
|
* checks done by typescript.
|
|
|
|
*
|
|
|
|
* https://github.com/typescript-eslint/typescript-eslint/blob/master/docs/getting-started/linting/FAQ.md#eslint-plugin-import
|
2021-12-22 16:31:14 +03:00
|
|
|
* required for esm check
|
2020-02-04 12:37:00 +03:00
|
|
|
*/
|
2021-12-22 16:31:14 +03:00
|
|
|
'import/default': 2,
|
|
|
|
'import/named': 2,
|
|
|
|
'import/namespace': 2,
|
2020-02-04 12:37:00 +03:00
|
|
|
'import/no-named-as-default-member': 0,
|
2021-11-09 09:30:22 +03:00
|
|
|
'import/prefer-default-export': 0, // no benefit
|
2020-02-04 12:37:00 +03:00
|
|
|
|
|
|
|
// other rules
|
2021-11-09 09:37:22 +03:00
|
|
|
'consistent-return': 'error',
|
2021-11-09 10:02:59 +03:00
|
|
|
eqeqeq: 'error',
|
2021-11-09 09:48:31 +03:00
|
|
|
'no-console': 'error',
|
2021-03-04 08:21:55 +03:00
|
|
|
'no-negated-condition': 'error',
|
2021-11-09 09:30:22 +03:00
|
|
|
'no-param-reassign': 'error',
|
2021-11-09 09:50:25 +03:00
|
|
|
'no-template-curly-in-string': 'error',
|
2020-05-01 19:03:48 +03:00
|
|
|
'sort-imports': [
|
|
|
|
'error',
|
|
|
|
{
|
|
|
|
ignoreCase: false,
|
|
|
|
ignoreDeclarationSort: true, // conflicts with our other import ordering rules
|
|
|
|
ignoreMemberSort: false,
|
|
|
|
memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
|
|
|
|
},
|
|
|
|
],
|
2021-08-13 09:23:35 +03:00
|
|
|
|
|
|
|
// mdast is a types only package `@types/mdast`
|
|
|
|
'import/no-unresolved': ['error', { ignore: ['^mdast$'] }],
|
2020-05-01 19:03:48 +03:00
|
|
|
'import/order': [
|
|
|
|
'error',
|
|
|
|
{
|
|
|
|
alphabetize: {
|
|
|
|
order: 'asc',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
|
2021-06-16 10:13:33 +03:00
|
|
|
// disallow direct `nock` module usage as it causes memory issues.
|
|
|
|
'no-restricted-imports': [2, { paths: ['nock'] }],
|
|
|
|
|
2020-10-20 09:49:28 +03:00
|
|
|
// Makes no sense to allow type inference for expression parameters, but require typing the response
|
2020-02-04 12:37:00 +03:00
|
|
|
'@typescript-eslint/explicit-function-return-type': [
|
|
|
|
'error',
|
|
|
|
{ allowExpressions: true, allowTypedFunctionExpressions: true },
|
|
|
|
],
|
2019-11-26 18:13:07 +03:00
|
|
|
|
2019-07-08 16:58:12 +03:00
|
|
|
// TODO: fix lint
|
|
|
|
'@typescript-eslint/no-explicit-any': 0,
|
2020-09-24 10:13:31 +03:00
|
|
|
'@typescript-eslint/no-non-null-assertion': 2,
|
2019-07-17 11:14:56 +03:00
|
|
|
'@typescript-eslint/no-unused-vars': [
|
2020-02-04 12:37:00 +03:00
|
|
|
2,
|
2019-07-17 11:14:56 +03:00
|
|
|
{
|
|
|
|
vars: 'all',
|
|
|
|
args: 'none',
|
|
|
|
ignoreRestSiblings: false,
|
2019-07-08 16:58:12 +03:00
|
|
|
},
|
2020-08-10 17:18:08 +03:00
|
|
|
],
|
2020-08-31 14:13:02 +03:00
|
|
|
'@typescript-eslint/prefer-optional-chain': 2,
|
2020-07-18 09:42:32 +03:00
|
|
|
'@typescript-eslint/prefer-nullish-coalescing': 2,
|
2020-03-17 14:15:22 +03:00
|
|
|
curly: [2, 'all'],
|
2020-07-22 08:45:57 +03:00
|
|
|
'require-await': 2,
|
2020-08-10 17:18:08 +03:00
|
|
|
// next 2 rules disabled due to https://github.com/microsoft/TypeScript/issues/20024
|
|
|
|
'@typescript-eslint/no-unsafe-assignment': 0,
|
|
|
|
'@typescript-eslint/no-unsafe-member-access': 0,
|
|
|
|
|
|
|
|
// TODO: fix me
|
|
|
|
'@typescript-eslint/no-unsafe-return': 0,
|
|
|
|
'@typescript-eslint/no-unsafe-call': 0,
|
2021-11-08 15:37:14 +03:00
|
|
|
'@typescript-eslint/no-unsafe-argument': 0, // thousands of errors :-/
|
2020-08-10 17:18:08 +03:00
|
|
|
|
|
|
|
'@typescript-eslint/restrict-template-expressions': [
|
|
|
|
1,
|
|
|
|
{ allowNumber: true, allowBoolean: true },
|
|
|
|
],
|
2020-08-31 14:13:02 +03:00
|
|
|
'@typescript-eslint/restrict-plus-operands': 2,
|
2020-08-10 17:18:08 +03:00
|
|
|
|
2021-11-08 16:03:55 +03:00
|
|
|
'@typescript-eslint/naming-convention': [
|
|
|
|
2,
|
|
|
|
{
|
|
|
|
selector: 'enumMember',
|
|
|
|
format: ['PascalCase'],
|
|
|
|
},
|
|
|
|
],
|
2020-08-10 17:18:08 +03:00
|
|
|
|
2020-08-31 14:13:02 +03:00
|
|
|
'@typescript-eslint/unbound-method': 2,
|
|
|
|
'@typescript-eslint/ban-types': 2,
|
2021-08-18 08:46:56 +03:00
|
|
|
'@renovate/jest-root-describe': 2,
|
2019-07-17 11:14:56 +03:00
|
|
|
},
|
2020-03-02 14:06:16 +03:00
|
|
|
settings: {
|
2020-08-19 07:46:00 +03:00
|
|
|
'import/parsers': {
|
|
|
|
'@typescript-eslint/parser': ['.ts'],
|
|
|
|
},
|
2020-03-02 14:06:16 +03:00
|
|
|
},
|
2019-11-20 10:55:53 +03:00
|
|
|
overrides: [
|
2021-12-22 16:31:14 +03:00
|
|
|
{
|
|
|
|
// files to check, so no `--ext` is required
|
|
|
|
files: ['**/*.{js,mjs,cjs,ts}'],
|
|
|
|
},
|
2019-11-20 10:55:53 +03:00
|
|
|
{
|
2020-09-07 10:54:07 +03:00
|
|
|
files: ['**/*.spec.ts', 'test/**'],
|
2020-02-04 12:37:00 +03:00
|
|
|
env: {
|
|
|
|
jest: true,
|
|
|
|
},
|
2019-11-20 10:55:53 +03:00
|
|
|
rules: {
|
2021-11-09 09:50:25 +03:00
|
|
|
'no-template-curly-in-string': 0,
|
2020-02-04 12:37:00 +03:00
|
|
|
'prefer-destructuring': 0,
|
|
|
|
'prefer-promise-reject-errors': 0,
|
|
|
|
'import/no-dynamic-require': 0,
|
|
|
|
'global-require': 0,
|
|
|
|
|
2019-11-20 10:55:53 +03:00
|
|
|
'@typescript-eslint/no-var-requires': 0,
|
2020-02-04 12:37:00 +03:00
|
|
|
'@typescript-eslint/no-object-literal-type-assertion': 0,
|
2019-11-20 10:55:53 +03:00
|
|
|
'@typescript-eslint/explicit-function-return-type': 0,
|
2020-02-05 21:17:20 +03:00
|
|
|
'@typescript-eslint/unbound-method': 0,
|
2020-09-07 10:54:07 +03:00
|
|
|
|
|
|
|
'jest/valid-title': [0, { ignoreTypeOfDescribeName: true }],
|
2021-06-07 19:28:05 +03:00
|
|
|
'max-classes-per-file': 0,
|
|
|
|
'class-methods-use-this': 0,
|
2019-11-20 10:55:53 +03:00
|
|
|
},
|
|
|
|
},
|
2020-03-11 12:11:01 +03:00
|
|
|
{
|
2021-12-22 16:31:14 +03:00
|
|
|
files: ['**/*.{js,mjs,cjs}'],
|
2020-03-11 12:11:01 +03:00
|
|
|
|
|
|
|
rules: {
|
|
|
|
'@typescript-eslint/explicit-function-return-type': 0,
|
2020-08-19 07:46:00 +03:00
|
|
|
'@typescript-eslint/explicit-module-boundary-types': 0,
|
|
|
|
'@typescript-eslint/restrict-template-expressions': 0,
|
2020-03-11 12:11:01 +03:00
|
|
|
},
|
|
|
|
},
|
2021-08-27 16:58:50 +03:00
|
|
|
{
|
2021-12-22 16:31:14 +03:00
|
|
|
files: ['tools/**/*.{ts,js,mjs,cjs}'],
|
2021-08-27 16:58:50 +03:00
|
|
|
env: {
|
|
|
|
node: true,
|
|
|
|
},
|
|
|
|
rules: {
|
|
|
|
'import/no-extraneous-dependencies': [
|
|
|
|
'error',
|
|
|
|
{ devDependencies: true },
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2021-12-22 16:31:14 +03:00
|
|
|
files: ['tools/**/*.{js,cjs}', 'bin/*.{js,cjs}'],
|
2021-08-27 16:58:50 +03:00
|
|
|
rules: {
|
|
|
|
// need commonjs
|
|
|
|
'@typescript-eslint/no-var-requires': 'off',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
files: ['*.mjs'],
|
|
|
|
rules: {
|
|
|
|
// esm always requires extensions
|
|
|
|
'import/extensions': 0,
|
|
|
|
},
|
|
|
|
},
|
2019-11-20 10:55:53 +03:00
|
|
|
],
|
2017-01-11 00:28:22 +03:00
|
|
|
};
|