Skip to content

Commit b570537

Browse files
committed
Merge remote-tracking branch 'origin/main' into alpha
2 parents c0b01b0 + 137dc26 commit b570537

13 files changed

+118
-84
lines changed

.eslint-doc-generatorrc.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const prettier = require('prettier');
2+
const prettierConfig = require('./.prettierrc.js');
3+
4+
/** @type {import('eslint-doc-generator').GenerateOptions} */
5+
const config = {
6+
postprocess: (content) =>
7+
prettier.format(content, { ...prettierConfig, parser: 'markdown' }),
8+
};
9+
10+
module.exports = config;

.eslintrc.js

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
module.exports = {
2+
root: true,
3+
extends: [
4+
'kentcdodds',
5+
'plugin:jest/recommended',
6+
'plugin:jest-formatting/recommended',
7+
'prettier',
8+
],
9+
rules: {
10+
// Base
11+
'max-lines-per-function': 'off',
12+
'no-restricted-imports': [
13+
'error',
14+
{
15+
patterns: [
16+
{
17+
group: ['@typescript-eslint/utils/dist/*'],
18+
message: 'Import from `@typescript-eslint/utils` instead.',
19+
},
20+
],
21+
},
22+
],
23+
24+
// Import
25+
'import/order': [
26+
'warn',
27+
{
28+
groups: ['builtin', 'external', 'parent', 'sibling', 'index'],
29+
'newlines-between': 'always',
30+
alphabetize: {
31+
order: 'asc',
32+
caseInsensitive: false,
33+
},
34+
},
35+
],
36+
},
37+
overrides: [
38+
{
39+
// TypeScript
40+
files: ['**/*.ts?(x)'],
41+
parser: '@typescript-eslint/parser',
42+
parserOptions: {
43+
tsconfigRootDir: __dirname,
44+
project: ['./tsconfig.eslint.json'],
45+
},
46+
extends: [
47+
'plugin:@typescript-eslint/recommended',
48+
'plugin:@typescript-eslint/recommended-requiring-type-checking',
49+
],
50+
rules: {
51+
'@typescript-eslint/explicit-function-return-type': 'off',
52+
'@typescript-eslint/no-unused-vars': [
53+
'warn',
54+
{ argsIgnorePattern: '^_' },
55+
],
56+
'@typescript-eslint/no-use-before-define': 'off',
57+
},
58+
},
59+
],
60+
};

.eslintrc.json

Lines changed: 0 additions & 57 deletions
This file was deleted.

.github/workflows/pipeline.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@ name: Pipeline
33
on:
44
push:
55
branches:
6-
# semantic-release valid branches, excluding all-contributors
6+
# semantic-release valid branches
77
- '+([0-9])?(.{+([0-9]),x}).x'
88
- 'main'
99
- 'next'
1010
- 'next-major'
1111
- 'beta'
1212
- 'alpha'
13-
- '!all-contributors/**'
1413
pull_request:
1514
types: [opened, synchronize]
1615

@@ -46,15 +45,16 @@ jobs:
4645
run: npm run format:check
4746

4847
- name: Check autogenerated docs
49-
run: npm run docs:gen && npm run format && git diff --exit-code
48+
run: npm run generate-all && git diff --exit-code
5049

5150
tests:
5251
name: Tests (Node v${{ matrix.node }} - ESLint v${{ matrix.eslint }})
5352
runs-on: ubuntu-latest
5453

5554
strategy:
5655
matrix:
57-
node: [12.22.0, 12, 14.17.0, 14, '16.0', 16, '18.0', 18]
56+
# The .x indicates "the most recent one"
57+
node: [19.x, 18.x, 17.x, 16.x, 14.x, 14.17.0, 12.x, 12.22.0]
5858
eslint: [7.5, 7, 8]
5959

6060
steps:

.github/workflows/smoke-test.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,23 @@ jobs:
1111
test:
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: actions/checkout@v3
15-
- uses: actions/setup-node@v3
14+
- name: Checkout
15+
uses: actions/checkout@v3
16+
17+
- name: Use Node
18+
uses: actions/setup-node@v3
1619
with:
1720
node-version-file: '.nvmrc'
18-
cache: 'npm'
21+
1922
- run: |
2023
npm install
2124
npm run build
25+
2226
- run: npm link
2327
working-directory: ./dist
28+
2429
- run: npm link eslint-plugin-testing-library
30+
2531
- uses: AriPerkkio/eslint-remote-tester-run-action@v3
2632
with:
2733
issue-title: 'Results of weekly scheduled smoke test'

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
package-lock=false
22
auto-install-peers=true
3+
enable-pre-post-scripts=true

CONTRIBUTING.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ The following will be run on every commit:
3838
- Check all tests are passing
3939
- Check commit message is following [Conventional Commit specification](https://www.conventionalcommits.org/en/v1.0.0/)
4040
41-
If you ever need to update a snapshot, you can run `npm run test:update`
42-
4341
## Rule naming conventions
4442
4543
Based on [ESLint's Rule Naming Conventions](https://eslint.org/docs/developer-guide/working-with-rules#rule-naming-conventions), you must follow these rules:
@@ -65,7 +63,7 @@ each rule has three files named with its identifier (e.g. `no-debugging-utils`):
6563
6664
Additionally, you need to do a couple of extra things:
6765
68-
- Run `npm run generate:rules-list` to include your rule in the "Supported Rules" table within the [README.md](./README.md)
66+
- Run `npm run generate:rules-doc` to include your rule in the "Supported Rules" table within the [README.md](./README.md)
6967
7068
### Custom rule creator
7169

lib/rules/no-await-sync-events.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,16 @@ export default createTestingLibraryRule<Options, MessageIds>({
151151
return;
152152
}
153153

154+
const eventModuleName = getPropertyIdentifierNode(node)?.name;
155+
const eventFullName = eventModuleName
156+
? `${eventModuleName}.${simulateEventFunctionName}`
157+
: simulateEventFunctionName;
158+
154159
context.report({
155160
node,
156161
messageId: 'noAwaitSyncEvents',
157162
data: {
158-
name: `${
159-
getPropertyIdentifierNode(node)?.name
160-
}.${simulateEventFunctionName}`,
163+
name: eventFullName,
161164
},
162165
});
163166
},

lib/rules/no-dom-import.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,22 @@ const DOM_TESTING_LIBRARY_MODULES = [
1212
'@testing-library/dom',
1313
];
1414

15-
const correctModuleNameByFramework = {
15+
const CORRECT_MODULE_NAME_BY_FRAMEWORK: Record<
16+
'angular' | 'marko' | string,
17+
string | undefined
18+
> = {
1619
angular: '@testing-library/angular', // ATL is *always* called `@testing-library/angular`
1720
marko: '@marko/testing-library', // Marko TL is called `@marko/testing-library`
1821
};
19-
const getCorrectModuleName = (moduleName: string, framework: string): string =>
20-
correctModuleNameByFramework[framework] ||
21-
moduleName.replace('dom', framework);
22+
const getCorrectModuleName = (
23+
moduleName: string,
24+
framework: string
25+
): string => {
26+
return (
27+
CORRECT_MODULE_NAME_BY_FRAMEWORK[framework] ??
28+
moduleName.replace('dom', framework)
29+
);
30+
};
2231

2332
export default createTestingLibraryRule<Options, MessageIds>({
2433
name: RULE_NAME,

lib/rules/no-wait-for-snapshot.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ export default createTestingLibraryRule<Options, MessageIds>({
6868
}
6969

7070
return {
71-
[`Identifier[name=${SNAPSHOT_REGEXP}]`](node: TSESTree.Identifier) {
71+
[`Identifier[name=${String(SNAPSHOT_REGEXP)}]`](
72+
node: TSESTree.Identifier
73+
) {
7274
const closestAsyncUtil = getClosestAsyncUtil(node);
7375
if (closestAsyncUtil === null) {
7476
return;

0 commit comments

Comments
 (0)