Skip to content

Commit

Permalink
Add tests configs
Browse files Browse the repository at this point in the history
  • Loading branch information
Arlevoy committed Jan 13, 2025
1 parent 155cda3 commit ffd9f62
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 64 deletions.
10 changes: 8 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": { "source.fixAll": true },
"editor.codeActionsOnSave": {
"source.fixAll": "explicit"
},
"eslint.workingDirectories": ["example-app", "packages/eslint-plugin"],
"markdownlint.customRules": [
"./markdown-lint-custom-rules/no-relative-links.js"
]
],
"eslint.useFlatConfig": true,
"eslint.options": {
"overrideConfigFile": "./eslint.config.js"
}
}
1 change: 1 addition & 0 deletions example-app/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module.exports = [
...pluginBam.configs.recommended,
...pluginBam.configs.a11y,
...pluginBam.configs.import,
...pluginBam.configs.tests,
{
rules: {
"@bam.tech/require-named-effect": "error",
Expand Down
2 changes: 1 addition & 1 deletion example-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"eslint-plugin-react-native": "^5.0.0",
"eslint-plugin-react-native-a11y": "^3.3.0",
"eslint-plugin-simple-import-sort": "^12.0.0",
"eslint-plugin-testing-library": "^6.0.1",
"eslint-plugin-testing-library": "^7.1.1",
"eslint-plugin-unused-imports": "^3.0.0",
"globals": "^15.14.0",
"jest": "^29.5.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin/lib/configs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { testsConfig } from "./tests";

export default {
recommended: recommendedConfig,
tests: testsConfig,
a11y: a11yconfig,
import: importConfig,
tests: testsConfig,
};
2 changes: 2 additions & 0 deletions packages/eslint-plugin/lib/configs/recommended.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import reactHookPlugin from "eslint-plugin-react-hooks";
import { noDifferentDisplaynameRule } from "../rules/no-different-displayname";
import { requireNamedEffectRule } from "../rules/require-named-effect";
import { preferUserEventRule } from "../rules/prefer-user-event";
import { awaitUserEventRule } from "../rules/await-user-event";
const eslintPluginPrettierRecommended = require("eslint-plugin-prettier/recommended");

// @TODO Add the @bam.tech/import plugins
Expand Down Expand Up @@ -53,6 +54,7 @@ export const recommendedConfig = tseslint.config(
"no-different-displayname": noDifferentDisplaynameRule,
"require-named-effect": requireNamedEffectRule,
"prefer-user-event": preferUserEventRule,
"await-user-event": awaitUserEventRule,
},
},
},
Expand Down
100 changes: 55 additions & 45 deletions packages/eslint-plugin/lib/configs/tests.ts
Original file line number Diff line number Diff line change
@@ -1,47 +1,57 @@
import { defineConfig } from "eslint-define-config";
import { defineFlatConfig } from "eslint-define-config";
import jestPlugin from "eslint-plugin-jest";
import testingLibrary from "eslint-plugin-testing-library";
import { awaitUserEventRule } from "../rules/await-user-event";

export const testsConfig = defineConfig({
env: {
"jest/globals": true,
export const testsConfig = defineFlatConfig([
{
languageOptions: {
globals: {
"jest/globals": true,
},
},
plugins: {
jest: jestPlugin,
"testing-library": testingLibrary,
},
rules: {
// Setting the recommended rules manually, because we don't want warnings, only errors
"jest/no-alias-methods": "error", // STYLE
"jest/no-commented-out-tests": "error",
"jest/no-conditional-expect": "error",
"jest/no-conditional-in-test": "error",
"jest/no-deprecated-functions": "error",
"jest/no-disabled-tests": "error",
"jest/no-done-callback": "error",
"jest/no-export": "error",
"jest/no-focused-tests": "error",
"jest/no-identical-title": "error",
"jest/no-mocks-import": "error",
"jest/no-standalone-expect": "error",
"jest/no-test-prefixes": "error", // STYLE - force it.skip over xtest
"jest/no-test-return-statement": "error",
"jest/prefer-to-have-length": "error", // STYLE
"jest/valid-describe-callback": "error",
"jest/valid-expect": "error",
"jest/valid-expect-in-promise": "error",
"jest/valid-title": ["error", { disallowedWords: ["should"] }], // STYLE
"jest/padding-around-all": "error", // STYLE
"testing-library/await-async-queries": "error",
"testing-library/no-manual-cleanup": "error",
"testing-library/no-container": "error",
"testing-library/no-await-sync-queries": "error",
"testing-library/no-await-sync-events": "error",
"testing-library/no-debugging-utils": "error",
"testing-library/await-async-utils": "error",
"testing-library/no-promise-in-fire-event": "error",
"testing-library/no-render-in-lifecycle": "error",
"testing-library/no-unnecessary-act": "error",
"testing-library/no-wait-for-multiple-assertions": "error",
"testing-library/prefer-explicit-assert": "error",
"testing-library/prefer-presence-queries": "error",
"testing-library/no-wait-for-side-effects": "error",
"testing-library/prefer-screen-queries": "error",
"@bam.tech/await-user-event": "error",
},
},
plugins: ["jest", "testing-library"],
rules: {
// Setting the recommended rules manually, because we don't want warnings, only errors
"jest/no-alias-methods": "error", // STYLE
"jest/no-commented-out-tests": "error",
"jest/no-conditional-expect": "error",
"jest/no-conditional-in-test": "error",
"jest/no-deprecated-functions": "error",
"jest/no-disabled-tests": "error",
"jest/no-done-callback": "error",
"jest/no-export": "error",
"jest/no-focused-tests": "error",
"jest/no-identical-title": "error",
"jest/no-mocks-import": "error",
"jest/no-standalone-expect": "error",
"jest/no-test-prefixes": "error", // STYLE - force it.skip over xtest
"jest/no-test-return-statement": "error",
"jest/prefer-to-have-length": "error", // STYLE
"jest/valid-describe-callback": "error",
"jest/valid-expect": "error",
"jest/valid-expect-in-promise": "error",
"jest/valid-title": ["error", { disallowedWords: ["should"] }], // STYLE
"jest/padding-around-all": "error", // STYLE
"testing-library/await-async-queries": "error",
"testing-library/no-manual-cleanup": "error",
"testing-library/no-container": "error",
"testing-library/no-await-sync-queries": "error",
"testing-library/no-await-sync-events": "error",
"testing-library/no-debugging-utils": "error",
"testing-library/await-async-utils": "error",
"testing-library/no-promise-in-fire-event": "error",
"testing-library/no-render-in-lifecycle": "error",
"testing-library/no-unnecessary-act": "error",
"testing-library/no-wait-for-multiple-assertions": "error",
"testing-library/prefer-explicit-assert": "error",
"testing-library/prefer-presence-queries": "error",
"testing-library/no-wait-for-side-effects": "error",
"testing-library/prefer-screen-queries": "error",
"@bam.tech/await-user-event": "error",
},
});
]);
4 changes: 2 additions & 2 deletions packages/eslint-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"eslint-plugin-react-native": "^5.0.0",
"eslint-plugin-react-native-a11y": "^3.3.0",
"eslint-plugin-simple-import-sort": "^12.0.0",
"eslint-plugin-testing-library": "^6.0.1",
"eslint-plugin-testing-library": "^7.1.1",
"eslint-plugin-unused-imports": "^3.0.0",
"prettier": "^3.0.0"
},
Expand All @@ -65,7 +65,7 @@
"eslint-plugin-react-native": "^4.0.0",
"eslint-plugin-react-native-a11y": "^3.3.0",
"eslint-plugin-simple-import-sort": "^12.0.0",
"eslint-plugin-testing-library": "6.0.1",
"eslint-plugin-testing-library": "7.1.1",
"eslint-plugin-unused-imports": "^3.0.0",
"jest": "^29.7.0",
"npm-run-all": "^4.1.5",
Expand Down
27 changes: 14 additions & 13 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1698,7 +1698,7 @@ __metadata:
eslint-plugin-react-native: "npm:^4.0.0"
eslint-plugin-react-native-a11y: "npm:^3.3.0"
eslint-plugin-simple-import-sort: "npm:^12.0.0"
eslint-plugin-testing-library: "npm:6.0.1"
eslint-plugin-testing-library: "npm:7.1.1"
eslint-plugin-unused-imports: "npm:^3.0.0"
jest: "npm:^29.7.0"
npm-run-all: "npm:^4.1.5"
Expand All @@ -1720,7 +1720,7 @@ __metadata:
eslint-plugin-react-native: ^5.0.0
eslint-plugin-react-native-a11y: ^3.3.0
eslint-plugin-simple-import-sort: ^12.0.0
eslint-plugin-testing-library: ^6.0.1
eslint-plugin-testing-library: ^7.1.1
eslint-plugin-unused-imports: ^3.0.0
prettier: ^3.0.0
languageName: unknown
Expand All @@ -1744,7 +1744,7 @@ __metadata:
eslint-plugin-react-native: ^5.0.0
eslint-plugin-react-native-a11y: ^3.3.0
eslint-plugin-simple-import-sort: ^12.0.0
eslint-plugin-testing-library: ^6.0.1
eslint-plugin-testing-library: ^7.1.1
eslint-plugin-unused-imports: ^3.0.0
prettier: ^3.0.0
languageName: node
Expand Down Expand Up @@ -4062,7 +4062,7 @@ __metadata:
languageName: node
linkType: hard

"@typescript-eslint/scope-manager@npm:8.19.1":
"@typescript-eslint/scope-manager@npm:8.19.1, @typescript-eslint/scope-manager@npm:^8.15.0":
version: 8.19.1
resolution: "@typescript-eslint/scope-manager@npm:8.19.1"
dependencies:
Expand Down Expand Up @@ -4197,7 +4197,7 @@ __metadata:
languageName: node
linkType: hard

"@typescript-eslint/utils@npm:8.19.1, @typescript-eslint/utils@npm:^6.0.0 || ^7.0.0 || ^8.0.0":
"@typescript-eslint/utils@npm:8.19.1, @typescript-eslint/utils@npm:^6.0.0 || ^7.0.0 || ^8.0.0, @typescript-eslint/utils@npm:^8.15.0":
version: 8.19.1
resolution: "@typescript-eslint/utils@npm:8.19.1"
dependencies:
Expand All @@ -4212,7 +4212,7 @@ __metadata:
languageName: node
linkType: hard

"@typescript-eslint/utils@npm:^5.38.1, @typescript-eslint/utils@npm:^5.58.0":
"@typescript-eslint/utils@npm:^5.38.1":
version: 5.62.0
resolution: "@typescript-eslint/utils@npm:5.62.0"
dependencies:
Expand Down Expand Up @@ -7097,14 +7097,15 @@ __metadata:
languageName: node
linkType: hard

"eslint-plugin-testing-library@npm:6.0.1, eslint-plugin-testing-library@npm:^6.0.1":
version: 6.0.1
resolution: "eslint-plugin-testing-library@npm:6.0.1"
"eslint-plugin-testing-library@npm:7.1.1, eslint-plugin-testing-library@npm:^7.1.1":
version: 7.1.1
resolution: "eslint-plugin-testing-library@npm:7.1.1"
dependencies:
"@typescript-eslint/utils": "npm:^5.58.0"
"@typescript-eslint/scope-manager": "npm:^8.15.0"
"@typescript-eslint/utils": "npm:^8.15.0"
peerDependencies:
eslint: ^7.5.0 || ^8.0.0
checksum: 10c0/cfa84f4fcc4efe8d46ea5a85d10d30c98adf33e0cfc7e6cec927ef3cc4a3887ddeb652b541df0677bbce26b03c169fbe6f2c0dcc6d3ee2e4e20d1dac37a8221c
eslint: ^8.57.0 || ^9.0.0
checksum: 10c0/648a7dd07ec3f26388eaad89e72ae74441f0e27e337cca7ca10ca55a4ff0437aa6303df5d9f37aeb90aaadd287c536696a7d11f14d1431bb8ae4fabad8c2744e
languageName: node
linkType: hard

Expand Down Expand Up @@ -7336,7 +7337,7 @@ __metadata:
eslint-plugin-react-native: "npm:^5.0.0"
eslint-plugin-react-native-a11y: "npm:^3.3.0"
eslint-plugin-simple-import-sort: "npm:^12.0.0"
eslint-plugin-testing-library: "npm:^6.0.1"
eslint-plugin-testing-library: "npm:^7.1.1"
eslint-plugin-unused-imports: "npm:^3.0.0"
expo: "npm:^49.0.0"
globals: "npm:^15.14.0"
Expand Down

0 comments on commit ffd9f62

Please sign in to comment.