Skip to content

Commit 8039c49

Browse files
committed
Merge branch 'feat-add-autofix-for-await-async-utils' of github.com-personal:neriyarden/eslint-plugin-testing-library into feat-add-autofix-for-await-async-utils
2 parents 131e636 + a48bcc2 commit 8039c49

36 files changed

+10692
-5543
lines changed

.all-contributorsrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,8 @@
413413
"contributions": [
414414
"code",
415415
"doc",
416-
"test"
416+
"test",
417+
"maintenance"
417418
]
418419
},
419420
{

.editorconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# EditorConfig helps developers define and maintain consistent
2+
# coding styles between different editors and IDEs
3+
# editorconfig.org
4+
5+
root = true
6+
7+
[*]
8+
end_of_line = lf
9+
charset = utf-8
10+
trim_trailing_whitespace = true
11+
insert_final_newline = true
12+
indent_style = tab

.github/workflows/release.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ concurrency:
1515
group: release
1616
cancel-in-progress: false
1717

18+
permissions:
19+
contents: write # to be able to publish a GitHub release
20+
id-token: write # to enable use of OIDC for npm provenance
21+
issues: write # to be able to comment on released issues
22+
pull-requests: write # to be able to comment on released pull requests
23+
1824
jobs:
1925
publish:
2026
name: Publish NPM package
@@ -28,16 +34,18 @@ jobs:
2834
- name: Set up Node
2935
uses: actions/setup-node@v4
3036
with:
37+
cache: npm
3138
node-version-file: '.nvmrc'
3239

3340
- name: Install dependencies
34-
uses: bahmutov/npm-install@v1
41+
run: npm install
3542

3643
- name: Build package
3744
run: npm run build
3845

3946
- name: Release new version
47+
run: npx semantic-release
4048
env:
4149
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50+
NPM_CONFIG_PROVENANCE: true
4251
NPM_TOKEN: ${{ secrets.NPM_AUTOMATION_TOKEN }}
43-
run: npx semantic-release

.github/workflows/verifications.yml

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,34 +19,54 @@ jobs:
1919
- name: Set up Node
2020
uses: actions/setup-node@v4
2121
with:
22+
cache: npm
2223
node-version-file: '.nvmrc'
2324

2425
- name: Install dependencies
25-
uses: bahmutov/npm-install@v1
26+
run: npm install
2627

2728
- name: Run script
2829
run: npm run ${{ matrix.validation-script }}
2930

3031
tests:
3132
name: Tests (Node v${{ matrix.node }} - ESLint v${{ matrix.eslint }})
3233
runs-on: ubuntu-latest
34+
timeout-minutes: 3
3335
strategy:
3436
fail-fast: false
3537
matrix:
36-
# The .x indicates "the most recent one"
37-
node: [19.x, 18.x, 17.x, 16.x, 14.x, 14.17.0, 12.x, 12.22.0]
38-
eslint: [7.5, 7, 8]
38+
node: [12.22.0, 12, 14.17.0, 14, 16, 17, 18, 19, 20, 22]
39+
eslint: [7.5, 7, 8, 9]
40+
exclude:
41+
# eslint@9 doesn't support < Node v18
42+
- node: 17
43+
eslint: 9
44+
- node: 16
45+
eslint: 9
46+
- node: 14
47+
eslint: 9
48+
- node: 14.17.0
49+
eslint: 9
50+
- node: 12
51+
eslint: 9
52+
- node: 12.22.0
53+
eslint: 9
3954
steps:
4055
- name: Checkout
4156
uses: actions/checkout@v4
4257

4358
- name: Set up Node
4459
uses: actions/setup-node@v4
4560
with:
61+
cache: npm
4662
node-version: ${{ matrix.node }}
4763

4864
- name: Install dependencies
49-
uses: bahmutov/npm-install@v1
65+
run: npm install
66+
67+
# see https://github.com/npm/cli/issues/7349
68+
- if: ${{ matrix.eslint == 9 }}
69+
run: npm un @typescript-eslint/eslint-plugin eslint-plugin-jest eslint-doc-generator
5070

5171
- name: Install ESLint v${{ matrix.eslint }}
5272
run: npm install --no-save --force eslint@${{ matrix.eslint }}

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
16
1+
20

.prettierignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
dist
2+
node_modules
3+
coverage
4+
.all-contributorsrc

.prettierrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
module.exports = {
2+
trailingComma: 'es5',
23
singleQuote: true,
34
useTabs: true,
45
};

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
482482
<tr>
483483
<td align="center" valign="top" width="14.28%"><a href="https://github.com/ph-fritsche"><img src="https://avatars.githubusercontent.com/u/39068198?v=4?s=100" width="100px;" alt="Philipp Fritsche"/><br /><sub><b>Philipp Fritsche</b></sub></a><br /><a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=ph-fritsche" title="Code">💻</a></td>
484484
<td align="center" valign="top" width="14.28%"><a href="http://zaicevas.me"><img src="https://avatars.githubusercontent.com/u/34719980?v=4?s=100" width="100px;" alt="Tomas Zaicevas"/><br /><sub><b>Tomas Zaicevas</b></sub></a><br /><a href="https://github.com/testing-library/eslint-plugin-testing-library/issues?q=author%3Azaicevas" title="Bug reports">🐛</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=zaicevas" title="Code">💻</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=zaicevas" title="Tests">⚠️</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=zaicevas" title="Documentation">📖</a></td>
485-
<td align="center" valign="top" width="14.28%"><a href="https://github.com/G-Rath"><img src="https://avatars.githubusercontent.com/u/3151613?v=4?s=100" width="100px;" alt="Gareth Jones"/><br /><sub><b>Gareth Jones</b></sub></a><br /><a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=G-Rath" title="Code">💻</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=G-Rath" title="Documentation">📖</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=G-Rath" title="Tests">⚠️</a></td>
485+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/G-Rath"><img src="https://avatars.githubusercontent.com/u/3151613?v=4?s=100" width="100px;" alt="Gareth Jones"/><br /><sub><b>Gareth Jones</b></sub></a><br /><a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=G-Rath" title="Code">💻</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=G-Rath" title="Documentation">📖</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=G-Rath" title="Tests">⚠️</a> <a href="#maintenance-G-Rath" title="Maintenance">🚧</a></td>
486486
<td align="center" valign="top" width="14.28%"><a href="https://github.com/HonkingGoose"><img src="https://avatars.githubusercontent.com/u/34918129?v=4?s=100" width="100px;" alt="HonkingGoose"/><br /><sub><b>HonkingGoose</b></sub></a><br /><a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=HonkingGoose" title="Documentation">📖</a> <a href="#maintenance-HonkingGoose" title="Maintenance">🚧</a></td>
487487
<td align="center" valign="top" width="14.28%"><a href="http://everlong.org/"><img src="https://avatars.githubusercontent.com/u/454175?v=4?s=100" width="100px;" alt="Julien Wajsberg"/><br /><sub><b>Julien Wajsberg</b></sub></a><br /><a href="https://github.com/testing-library/eslint-plugin-testing-library/issues?q=author%3Ajulienw" title="Bug reports">🐛</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=julienw" title="Code">💻</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=julienw" title="Tests">⚠️</a></td>
488488
<td align="center" valign="top" width="14.28%"><a href="https://www.linkedin.com/in/maratdyatko/"><img src="https://avatars.githubusercontent.com/u/31615495?v=4?s=100" width="100px;" alt="Marat Dyatko"/><br /><sub><b>Marat Dyatko</b></sub></a><br /><a href="https://github.com/testing-library/eslint-plugin-testing-library/issues?q=author%3Adyatko" title="Bug reports">🐛</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=dyatko" title="Code">💻</a></td>

lib/node-utils/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import {
66
TSESTree,
77
} from '@typescript-eslint/utils';
88

9+
import { getDeclaredVariables, getScope } from '../utils';
10+
911
import {
1012
isArrayExpression,
1113
isArrowFunctionExpression,
@@ -287,7 +289,7 @@ export function getVariableReferences(
287289
): TSESLint.Scope.Reference[] {
288290
if (ASTUtils.isVariableDeclarator(node)) {
289291
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
290-
return context.getDeclaredVariables(node)[0]?.references?.slice(1) ?? [];
292+
return getDeclaredVariables(context, node)[0]?.references?.slice(1) ?? [];
291293
}
292294

293295
return [];
@@ -305,7 +307,7 @@ export function getInnermostFunctionScope(
305307
asyncQueryNode: TSESTree.Identifier
306308
): InnermostFunctionScope | null {
307309
const innermostScope = ASTUtils.getInnermostScope(
308-
context.getScope(),
310+
getScope(context, asyncQueryNode),
309311
asyncQueryNode
310312
);
311313

lib/rules/consistent-data-testid.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { createTestingLibraryRule } from '../create-testing-library-rule';
22
import { isJSXAttribute, isLiteral } from '../node-utils';
3+
import { getFilename } from '../utils';
34

45
export const RULE_NAME = 'consistent-data-testid';
56
export type MessageIds =
@@ -77,11 +78,10 @@ export default createTestingLibraryRule<Options, MessageIds>({
7778
},
7879

7980
create: (context, [options]) => {
80-
const { getFilename } = context;
8181
const { testIdPattern, testIdAttribute: attr, customMessage } = options;
8282

8383
function getFileNameData() {
84-
const splitPath = getFilename().split('/');
84+
const splitPath = getFilename(context).split('/');
8585
const fileNameWithExtension = splitPath.pop() ?? '';
8686
if (
8787
fileNameWithExtension.includes('[') ||

0 commit comments

Comments
 (0)