Skip to content

Commit 7134b42

Browse files
AG-12669 - Deprecate getInfiniteRowCount (#84)
1 parent 21d5aef commit 7134b42

File tree

18 files changed

+230
-0
lines changed

18 files changed

+230
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# `transform-grid-api-methods-v32-2`
2+
3+
> _Transform deprecated Grid API method invocations_
4+
5+
See the [`transform-grid-api-methods`](../../plugins/transform-grid-api-methods/) plugin for usage instructions.
6+
7+
## Common tasks
8+
9+
### Add a test case
10+
11+
Create a new unit test scenario for this transform:
12+
13+
```
14+
pnpm run task:create-test --type transform --target transform-grid-api-methods-v32-2
15+
```
16+
17+
### Add a new rule
18+
19+
Replacement rules are specified in [`replacements.ts`](./replacements.ts)
20+
21+
### Add to a codemod release
22+
23+
Add this source code transformation to a codemod release:
24+
25+
```
26+
pnpm run task:include-transform --transform transform-grid-api-methods-v32-2
27+
```
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { createGrid } from '@ag-grid-community/core';
2+
3+
const gridApi = createGrid(document.body, {
4+
columnDefs: [],
5+
rowData: [],
6+
});
7+
8+
gridApi.getInfiniteRowCount();
9+
gridApi?.getInfiniteRowCount();
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { createGrid } from '@ag-grid-community/core';
2+
3+
const gridApi = createGrid(document.body, {
4+
columnDefs: [],
5+
rowData: [],
6+
});
7+
8+
gridApi.getDisplayedRowCount();
9+
gridApi?.getDisplayedRowCount();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"scenario": {
3+
"input": "input.js",
4+
"output": "output.js"
5+
}
6+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// @ts-nocheck
2+
import { createGrid } from '@ag-grid-community/core';
3+
4+
const gridApi = createGrid(document.body, {
5+
columnDefs: [],
6+
rowData: [],
7+
});
8+
9+
gridApi.getInfiniteRowCount();
10+
gridApi?.getInfiniteRowCount();
11+
gridApi!.getInfiniteRowCount();
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// @ts-nocheck
2+
import { createGrid } from '@ag-grid-community/core';
3+
4+
const gridApi = createGrid(document.body, {
5+
columnDefs: [],
6+
rowData: [],
7+
});
8+
9+
gridApi.getDisplayedRowCount();
10+
gridApi?.getDisplayedRowCount();
11+
gridApi!.getDisplayedRowCount();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"scenario": {
3+
"input": "input.ts",
4+
"output": "output.ts"
5+
}
6+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from './transform-grid-api-methods-v32-2';
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { type TransformManifest } from '@ag-grid-devtools/types';
2+
3+
const manifest: TransformManifest = {
4+
name: 'Transform Grid API methods v32.2',
5+
description: 'Transform deprecated Grid API method invocations',
6+
};
7+
8+
export default manifest;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { ast, matchNode, pattern as p, replace, template } from '@ag-grid-devtools/ast';
2+
import {
3+
type GridApiDeprecation,
4+
type GridApiReplacement,
5+
} from '../../plugins/transform-grid-api-methods';
6+
7+
export const replacements: Array<GridApiReplacement> = [
8+
...['', '?', '!'].map((apiOptionalChaining) =>
9+
replace(
10+
matchNode(({ api }) => ast.expression`${api}${apiOptionalChaining}.getInfiniteRowCount()`, {
11+
api: p.expression(),
12+
}),
13+
template(({ api }) => {
14+
return ast.expression`${api}${apiOptionalChaining}.getDisplayedRowCount()`;
15+
}),
16+
),
17+
),
18+
];
19+
20+
export const deprecations: Array<GridApiDeprecation> = [];

0 commit comments

Comments
 (0)