2017-01-10 21:28:22 +00:00
|
|
|
module.exports = {
|
2020-02-04 09:37:00 +00:00
|
|
|
root: true,
|
2017-10-01 05:06:06 +00:00
|
|
|
env: {
|
|
|
|
node: true,
|
|
|
|
},
|
2022-04-12 14:49:49 +00:00
|
|
|
plugins: ['@renovate', 'typescript-enum', 'jest-formatting'],
|
2019-07-08 13:58:12 +00:00
|
|
|
extends: [
|
2021-11-08 13:03:55 +00:00
|
|
|
'eslint:recommended',
|
2020-03-02 11:06:16 +00:00
|
|
|
'plugin:import/errors',
|
|
|
|
'plugin:import/warnings',
|
|
|
|
'plugin:import/typescript',
|
2020-05-18 12:33:44 +00:00
|
|
|
'plugin:jest/recommended',
|
|
|
|
'plugin:jest/style',
|
2020-02-12 09:22:38 +00:00
|
|
|
// https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin/src/configs
|
2020-02-04 09:37:00 +00:00
|
|
|
'plugin:@typescript-eslint/recommended',
|
2020-02-05 18:17:20 +00:00
|
|
|
'plugin:@typescript-eslint/recommended-requiring-type-checking',
|
2020-02-04 09:37:00 +00:00
|
|
|
'plugin:promise/recommended',
|
2022-04-12 14:49:49 +00:00
|
|
|
'plugin:jest-formatting/recommended',
|
2019-07-08 13:58:12 +00:00
|
|
|
'prettier',
|
|
|
|
],
|
2019-04-26 10:59:51 +00:00
|
|
|
parserOptions: {
|
2019-05-21 15:23:30 +00:00
|
|
|
ecmaVersion: 9,
|
2020-02-04 09:37:00 +00:00
|
|
|
tsconfigRootDir: __dirname,
|
2020-03-24 06:17:59 +00:00
|
|
|
project: ['./tsconfig.lint.json'],
|
2020-03-06 08:31:47 +00:00
|
|
|
extraFileExtensions: ['.mjs'],
|
2019-04-26 10:59:51 +00:00
|
|
|
},
|
2017-10-01 05:06:06 +00:00
|
|
|
rules: {
|
2020-02-04 09:37:00 +00: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 13:31:14 +00:00
|
|
|
* required for esm check
|
2020-02-04 09:37:00 +00:00
|
|
|
*/
|
2021-12-22 13:31:14 +00:00
|
|
|
'import/default': 2,
|
|
|
|
'import/named': 2,
|
|
|
|
'import/namespace': 2,
|
2020-02-04 09:37:00 +00:00
|
|
|
'import/no-named-as-default-member': 0,
|
2022-01-19 12:45:11 +00:00
|
|
|
'import/no-extraneous-dependencies': [
|
|
|
|
'error',
|
|
|
|
{ devDependencies: ['test/**/*', '**/*.spec.ts'] },
|
|
|
|
],
|
2021-11-09 06:30:22 +00:00
|
|
|
'import/prefer-default-export': 0, // no benefit
|
2020-02-04 09:37:00 +00:00
|
|
|
|
|
|
|
// other rules
|
2021-11-09 06:37:22 +00:00
|
|
|
'consistent-return': 'error',
|
2021-11-09 07:02:59 +00:00
|
|
|
eqeqeq: 'error',
|
2021-11-09 06:48:31 +00:00
|
|
|
'no-console': 'error',
|
2021-03-04 05:21:55 +00:00
|
|
|
'no-negated-condition': 'error',
|
2021-11-09 06:30:22 +00:00
|
|
|
'no-param-reassign': 'error',
|
2021-11-09 06:50:25 +00:00
|
|
|
'no-template-curly-in-string': 'error',
|
2020-05-01 16:03:48 +00: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 06:23:35 +00:00
|
|
|
|
|
|
|
// mdast is a types only package `@types/mdast`
|
|
|
|
'import/no-unresolved': ['error', { ignore: ['^mdast$'] }],
|
2020-05-01 16:03:48 +00:00
|
|
|
'import/order': [
|
|
|
|
'error',
|
|
|
|
{
|
|
|
|
alphabetize: {
|
|
|
|
order: 'asc',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
|
2021-06-16 07:13:33 +00:00
|
|
|
// disallow direct `nock` module usage as it causes memory issues.
|
2022-01-13 05:45:50 +00:00
|
|
|
// disallow `parse-link-header` to allow override ENV https://github.com/thlorenz/parse-link-header#environmental-variables
|
2022-04-22 04:24:01 +00:00
|
|
|
'no-restricted-imports': [
|
|
|
|
2,
|
|
|
|
{ paths: ['nock', 'parse-link-header', 'path'] },
|
|
|
|
],
|
2021-06-16 07:13:33 +00:00
|
|
|
|
2020-10-20 06:49:28 +00:00
|
|
|
// Makes no sense to allow type inference for expression parameters, but require typing the response
|
2020-02-04 09:37:00 +00:00
|
|
|
'@typescript-eslint/explicit-function-return-type': [
|
|
|
|
'error',
|
|
|
|
{ allowExpressions: true, allowTypedFunctionExpressions: true },
|
|
|
|
],
|
2019-11-26 15:13:07 +00:00
|
|
|
|
2019-07-08 13:58:12 +00:00
|
|
|
// TODO: fix lint
|
|
|
|
'@typescript-eslint/no-explicit-any': 0,
|
2022-04-16 06:32:17 +00:00
|
|
|
// TODO: https://github.com/renovatebot/renovate/issues/7154
|
|
|
|
'@typescript-eslint/no-non-null-assertion': 0,
|
2019-07-17 08:14:56 +00:00
|
|
|
'@typescript-eslint/no-unused-vars': [
|
2020-02-04 09:37:00 +00:00
|
|
|
2,
|
2019-07-17 08:14:56 +00:00
|
|
|
{
|
|
|
|
vars: 'all',
|
|
|
|
args: 'none',
|
|
|
|
ignoreRestSiblings: false,
|
2019-07-08 13:58:12 +00:00
|
|
|
},
|
2020-08-10 14:18:08 +00:00
|
|
|
],
|
2020-08-31 11:13:02 +00:00
|
|
|
'@typescript-eslint/prefer-optional-chain': 2,
|
2022-06-21 11:00:21 +00:00
|
|
|
'@typescript-eslint/prefer-nullish-coalescing': 1, // TODO: Temporary (#7154)
|
2020-03-17 11:15:22 +00:00
|
|
|
curly: [2, 'all'],
|
2020-07-22 05:45:57 +00:00
|
|
|
'require-await': 2,
|
2020-08-10 14:18:08 +00: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 12:37:14 +00:00
|
|
|
'@typescript-eslint/no-unsafe-argument': 0, // thousands of errors :-/
|
2020-08-10 14:18:08 +00:00
|
|
|
|
|
|
|
'@typescript-eslint/restrict-template-expressions': [
|
|
|
|
1,
|
|
|
|
{ allowNumber: true, allowBoolean: true },
|
|
|
|
],
|
2020-08-31 11:13:02 +00:00
|
|
|
'@typescript-eslint/restrict-plus-operands': 2,
|
2020-08-10 14:18:08 +00:00
|
|
|
|
2021-11-08 13:03:55 +00:00
|
|
|
'@typescript-eslint/naming-convention': [
|
|
|
|
2,
|
|
|
|
{
|
|
|
|
selector: 'enumMember',
|
|
|
|
format: ['PascalCase'],
|
|
|
|
},
|
|
|
|
],
|
2020-08-10 14:18:08 +00:00
|
|
|
|
2020-08-31 11:13:02 +00:00
|
|
|
'@typescript-eslint/unbound-method': 2,
|
|
|
|
'@typescript-eslint/ban-types': 2,
|
2021-08-18 05:46:56 +00:00
|
|
|
'@renovate/jest-root-describe': 2,
|
2022-01-21 14:33:23 +00:00
|
|
|
|
|
|
|
'typescript-enum/no-const-enum': 2,
|
|
|
|
'typescript-enum/no-enum': 2,
|
2019-07-17 08:14:56 +00:00
|
|
|
},
|
2020-03-02 11:06:16 +00:00
|
|
|
settings: {
|
2020-08-19 04:46:00 +00:00
|
|
|
'import/parsers': {
|
|
|
|
'@typescript-eslint/parser': ['.ts'],
|
|
|
|
},
|
2022-01-27 11:22:48 +00:00
|
|
|
'import/resolver': {
|
|
|
|
typescript: {
|
|
|
|
alwaysTryTypes: true, // always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/unist`
|
|
|
|
project: 'tsconfig.lint.json',
|
|
|
|
},
|
|
|
|
},
|
2020-03-02 11:06:16 +00:00
|
|
|
},
|
2019-11-20 07:55:53 +00:00
|
|
|
overrides: [
|
2021-12-22 13:31:14 +00:00
|
|
|
{
|
|
|
|
// files to check, so no `--ext` is required
|
|
|
|
files: ['**/*.{js,mjs,cjs,ts}'],
|
|
|
|
},
|
2019-11-20 07:55:53 +00:00
|
|
|
{
|
2020-09-07 07:54:07 +00:00
|
|
|
files: ['**/*.spec.ts', 'test/**'],
|
2020-02-04 09:37:00 +00:00
|
|
|
env: {
|
|
|
|
jest: true,
|
|
|
|
},
|
2019-11-20 07:55:53 +00:00
|
|
|
rules: {
|
2021-11-09 06:50:25 +00:00
|
|
|
'no-template-curly-in-string': 0,
|
2020-02-04 09:37:00 +00:00
|
|
|
'prefer-destructuring': 0,
|
|
|
|
'prefer-promise-reject-errors': 0,
|
|
|
|
'import/no-dynamic-require': 0,
|
|
|
|
'global-require': 0,
|
|
|
|
|
2019-11-20 07:55:53 +00:00
|
|
|
'@typescript-eslint/no-var-requires': 0,
|
2020-02-04 09:37:00 +00:00
|
|
|
'@typescript-eslint/no-object-literal-type-assertion': 0,
|
2019-11-20 07:55:53 +00:00
|
|
|
'@typescript-eslint/explicit-function-return-type': 0,
|
2020-02-05 18:17:20 +00:00
|
|
|
'@typescript-eslint/unbound-method': 0,
|
2020-09-07 07:54:07 +00:00
|
|
|
|
|
|
|
'jest/valid-title': [0, { ignoreTypeOfDescribeName: true }],
|
2021-06-07 16:28:05 +00:00
|
|
|
'max-classes-per-file': 0,
|
|
|
|
'class-methods-use-this': 0,
|
2019-11-20 07:55:53 +00:00
|
|
|
},
|
|
|
|
},
|
2020-03-11 09:11:01 +00:00
|
|
|
{
|
2021-12-22 13:31:14 +00:00
|
|
|
files: ['**/*.{js,mjs,cjs}'],
|
2020-03-11 09:11:01 +00:00
|
|
|
|
|
|
|
rules: {
|
|
|
|
'@typescript-eslint/explicit-function-return-type': 0,
|
2020-08-19 04:46:00 +00:00
|
|
|
'@typescript-eslint/explicit-module-boundary-types': 0,
|
|
|
|
'@typescript-eslint/restrict-template-expressions': 0,
|
2020-03-11 09:11:01 +00:00
|
|
|
},
|
|
|
|
},
|
2021-08-27 13:58:50 +00:00
|
|
|
{
|
2021-12-22 13:31:14 +00:00
|
|
|
files: ['tools/**/*.{ts,js,mjs,cjs}'],
|
2021-08-27 13:58:50 +00:00
|
|
|
env: {
|
|
|
|
node: true,
|
|
|
|
},
|
|
|
|
rules: {
|
|
|
|
'import/no-extraneous-dependencies': [
|
|
|
|
'error',
|
|
|
|
{ devDependencies: true },
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2021-12-22 13:31:14 +00:00
|
|
|
files: ['tools/**/*.{js,cjs}', 'bin/*.{js,cjs}'],
|
2021-08-27 13:58:50 +00:00
|
|
|
rules: {
|
|
|
|
// need commonjs
|
|
|
|
'@typescript-eslint/no-var-requires': 'off',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
files: ['*.mjs'],
|
|
|
|
rules: {
|
|
|
|
// esm always requires extensions
|
|
|
|
'import/extensions': 0,
|
|
|
|
},
|
|
|
|
},
|
2019-11-20 07:55:53 +00:00
|
|
|
],
|
2017-01-10 21:28:22 +00:00
|
|
|
};
|