Skip to content

Commit

Permalink
feat: add common exclusions (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
dcroote authored Jul 18, 2024
1 parent 540f71a commit f98f26b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,11 @@ module.exports = {
extends: ['plugin:jest/recommended', 'plugin:jest-formatting/recommended'],
rules: {
'jest/max-expects': 'off', // Limiting expect statements is beneficial, but enforcing a strict count can be restrictive.
'jest/no-hooks': [
'error', // We advocate for setup functions over beforeXXX hooks. However, afterXyz hooks are sometimes indispensable, like for resetting Jest timers. See: https://kentcdodds.com/blog/avoid-nesting-when-youre-testing#inline-it.
{
allow: ['afterEach', 'afterAll'],
},
],
'jest/no-hooks': 'off', // Would be time consuming to implement in existing repos.
'jest/prefer-each': 'off', // We find traditional for-loops more readable in certain contexts.
'jest/prefer-expect-assertions': 'off', // While useful, enforcing this can lead to verbose tests.
'jest/prefer-importing-jest-globals': 'off', // This would be very bothersome for existing repos.
'jest/prefer-todo': 'off',
'jest/require-top-level-describe': 'off', // Multiple top-level describe blocks or tests can be acceptable.
'jest/valid-title': 'off', // This restriction can prevent using titles like "<function-name>.name".
'prefer-lowercase-title': 'off', // Sometimes we want to start the test with a capital letter and some words are all uppercase (e.g. AWS).,
Expand Down
9 changes: 9 additions & 0 deletions src/universal.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,11 @@ module.exports = {
'unicorn/no-nested-ternary': 'off', // This rule is smarter than the standard ESLint rule, but conflicts with prettier so it needs to be turned off. Nested ternaries are very unreadable so it's OK if all of them are flagged.
'unicorn/no-null': 'off', // We use both null and undefined for representing three state objects. We could use a string union instead, but using combination of null and undefined is less verbose.
'unicorn/no-object-as-default-parameter': 'off', // Too restrictive. TypeScript can ensure that the default value matches the type.
'unicorn/no-process-exit': 'off',
'unicorn/no-useless-undefined': ['error', { checkArguments: false }], // We need to disable "checkArguments", because if a function expects a value of type "T | undefined" the undefined value needs to be passed explicitly.
'unicorn/prefer-module': 'off', // We use CJS for configuration files and tests. There is no rush to migrate to ESM and the configuration files are probably not yet ready for ESM yet.
'unicorn/prefer-string-raw': 'off', // We commonly escape \ in strings.
'unicorn/prefer-top-level-await': 'off',
'unicorn/prevent-abbreviations': 'off', // This rule reports many false positives and leads to more verbose code.

/* Rule overrides for "import" plugin */
Expand All @@ -129,11 +131,13 @@ module.exports = {
fixStyle: 'inline-type-imports',
},
],
'@typescript-eslint/consistent-return': 'off', // Does not play with no useless undefined when function return type is "T | undefined" and does not have a fixer.
'@typescript-eslint/explicit-function-return-type': 'off', // Prefer inferring types to explicit annotations.
'@typescript-eslint/explicit-module-boundary-types': 'off', // We export lot of functions in order to test them. Typing them all is not a good idea.
'@typescript-eslint/indent': 'off', // Conflicts with prettier.
'@typescript-eslint/init-declarations': 'off', // Too restrictive, TS is able to infer if value is initialized or not. This pattern does not work with declaring a variable and then initializing it conditionally (or later).
'@typescript-eslint/lines-around-comment': 'off', // Do not agree with this rule.
'@typescript-eslint/max-params': 'off',
'@typescript-eslint/member-delimiter-style': 'off', // Conflicts with prettier.
'@typescript-eslint/member-ordering': 'off', // Does not have a fixer. Also, sometimes it's beneficial to group related members together.
'@typescript-eslint/naming-convention': 'off',
Expand All @@ -143,6 +147,7 @@ module.exports = {
ignoreArrowShorthand: true, // See: https://typescript-eslint.io/rules/no-confusing-void-expression/#ignorearrowshorthand.
},
],
'@typescript-eslint/no-dynamic-delete': 'off',
'@typescript-eslint/no-empty-function': 'off', // Too restrictive, often false yields to more verbose code.
'@typescript-eslint/no-explicit-any': 'off', // Using "any" is sometimes necessary.
'@typescript-eslint/no-extra-parens': 'off', // Conflicts with prettier.
Expand All @@ -168,6 +173,7 @@ module.exports = {
'@typescript-eslint/no-unsafe-return': 'off', // Too restrictive, often false yields to more verbose code.
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_', vars: 'all' }],
'@typescript-eslint/no-use-before-define': 'off', // Too restrictive, does not have a fixer and is not important.
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/object-curly-spacing': 'off', // Conflicts with prettier.
'@typescript-eslint/prefer-nullish-coalescing': [
'error',
Expand All @@ -181,6 +187,7 @@ module.exports = {
'@typescript-eslint/space-before-function-paren': 'off', // Conflicts with prettier.
'@typescript-eslint/strict-boolean-expressions': 'off', // While the rule is reasonable, it is often convenient and intended to just check whether the value is not null or undefined. Enabling this rule would make the code more verbose. See: https://typescript-eslint.io/rules/strict-boolean-expressions/
'@typescript-eslint/unbound-method': 'off', // Reports issues for common patterns in tests (e.g. "expect(logger.warn)..."). Often the issue yields false positives.
'@typescript-eslint/use-unknown-in-catch-callback-variable': 'off',

/* Rule overrides for "functional" plugin */
'functional/no-classes': 'error', // Functions are all we need.
Expand All @@ -191,7 +198,9 @@ module.exports = {
/* Overrides for "lodash" plugin */
'lodash/import-scope': ['error', 'member'], // We prefer member imports in node.js code. This is not recommended for FE projects, because lodash can't be tree shaken (written in CJS not ESM). This rule should be overridden for FE projects (and we do so in React ruleset).
'lodash/path-style': 'off', // Can potentially trigger TS errors. Both variants have use cases when they are more readable.
'lodash/prefer-immutable-method': 'off',
'lodash/prefer-lodash-method': 'off', // Disagree with this rule. Using the native method is often simpler.
'lodash/prop-shorthand': 'off',

/* Rule overrides for other plugins and rules */
// This rule unfortunately does not detect deprecated properties. See:
Expand Down

0 comments on commit f98f26b

Please sign in to comment.