Skip to content

Commit

Permalink
fixed no-unchecked-record-access rule (microsoft#23463)
Browse files Browse the repository at this point in the history
Fixing no-unchecked-record-access for false positives array access that
came up while applying this rule to the repo

[AB#26470](https://dev.azure.com/fluidframework/235294da-091d-4c29-84fc-cdfc3d90890b/_workitems/edit/26470)
  • Loading branch information
RishhiB authored Jan 7, 2025
1 parent 838c87b commit b21fdfb
Show file tree
Hide file tree
Showing 5 changed files with 221 additions and 187 deletions.
78 changes: 40 additions & 38 deletions common/build/eslint-plugin-fluid/DEV.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,39 @@ This guide outlines the steps required to add new ESLint rules, update dependenc
### 1. Add New Rule to `eslint-plugin-fluid` (PR 1)

1. **Create the Rule**: Write the new rule following best practices for ESLint. If you need guidance, refer to [ESLint's rule documentation](https://eslint.org/docs/latest/developer-guide/working-with-rules).
- [List of Custom Rules](https://github.com/microsoft/FluidFramework/tree/main/common/build/eslint-plugin-fluid/src/rules)

- [List of Custom Rules](https://github.com/microsoft/FluidFramework/tree/main/common/build/eslint-plugin-fluid/src/rules)

2. **Testing**: Ensure the rule is thoroughly tested. Tests help validate that the rule behaves as expected across various code scenarios.

Directory structure:

```plaintext
eslint-plugin-fluid/
├── src
│ └── rules/ <!-- Contains the ESLint rule implementations -->
│ ├── rule-one.js
│ └── rule-two.js
├── test/
│ ├── example/ <!-- Example mock files to test each rule in isolation -->
│ │ ├── rule-one/
│ │ │ ├── mockFileOne.js
│ │ │ └── mockFileTwo.js
│ │ └── rule-two/
│ │ ├── mockFileOne.js
│ │ └── mockFileTwo.js
│ ├── rule-one/ <!-- Test suite for rule-one -->
│ │ └── rule-one.test.js
│ └── rule-two/ <!-- Test suite for rule-two -->
│ └── rule-two.test.js
```
Directory structure:

```plaintext
eslint-plugin-fluid/
├── src
│ └── rules/ <!-- Contains the ESLint rule implementations -->
│ ├── rule-one.js
│ └── rule-two.js
├── test/
│ ├── example/ <!-- Example mock files to test each rule in isolation -->
│ │ ├── rule-one/
│ │ │ ├── mockFileOne.js
│ │ │ └── mockFileTwo.js
│ │ └── rule-two/
│ │ ├── mockFileOne.js
│ │ └── mockFileTwo.js
│ ├── rule-one/ <!-- Test suite for rule-one -->
│ │ └── rule-one.test.js
│ └── rule-two/ <!-- Test suite for rule-two -->
│ └── rule-two.test.js
```
3. **Update Changelog**: Record the new rule in the `CHANGELOG.md` file of the `@fluid-internal/eslint-plugin-fluid` package. This provides visibility into what was added for future reference.
4. **Version Bump**: Update the version of `eslint-plugin-fluid` in its `package.json` following the [semantic versioning guidelines](https://semver.org/):
- **Patch** version for fixes (backward-compatible)
- **Minor** version for new rules (backward-compatible)
- **Major** version for breaking changes
- **Patch** version for fixes (backward-compatible)
- **Minor** version for new rules (backward-compatible)
- **Major** version for breaking changes
### 2. Publish New Version of `eslint-plugin-fluid`
Expand All @@ -55,25 +56,26 @@ In `@fluidframework/eslint-config-fluid`, update the version of `@fluid-internal
### 4. Add New Rule to the Appropriate Config
Depending on the scope of the rule, add it to one of the following configurations (NOTE: `recommended.js` extends `minimal-deprecated.js`, and `strict.js` extends `recommended.js`):
- `minimal-deprecated.js`
- `recommended.js`
- `strict.js`
- `minimal-deprecated.js`
- `recommended.js`
- `strict.js`
1. **Update Changelog**: Record the change in `eslint-config-fluid`'s `CHANGELOG.md`.
2. **Version Bump**: Update the version of `eslint-config-fluid` in its `package.json`.
3. **Fix Violations in the Repo**:
- Install the local version of `eslint-config-fluid` across relevant release groups.
- Run the linter to identify and fix any violations locally.
- To simplify integration, add the following to the `pnpmOverrides` section of the relevant `package.json` files (make sure *NOT* to check `pnpmOverrides` change in):
```json
{
"pnpmOverrides": {
"@fluidframework/eslint-config-fluid": "file:<relative-path-to-eslint-config-fluid-package>"
}
}
```
- Install the local version of `eslint-config-fluid` across relevant release groups.
- Run the linter to identify and fix any violations locally.
- To simplify integration, add the following to the `pnpmOverrides` section of the relevant `package.json` files (make sure _NOT_ to check `pnpmOverrides` change in):
```json
{
"pnpmOverrides": {
"@fluidframework/eslint-config-fluid": "file:<relative-path-to-eslint-config-fluid-package>"
}
}
```
### 5. Publish New Version of `eslint-config-fluid`
Expand Down
3 changes: 1 addition & 2 deletions common/build/eslint-plugin-fluid/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fluid-internal/eslint-plugin-fluid",
"version": "0.1.3",
"version": "0.1.4",
"description": "Custom ESLint rules for the Fluid Framework",
"homepage": "https://fluidframework.com",
"repository": {
Expand Down Expand Up @@ -31,7 +31,6 @@
"@fluidframework/build-common": "^2.0.3",
"eslint": "^8.57.0",
"mocha": "^10.4.0",

"mocha-multi-reporters": "^1.5.1",
"prettier": "~3.2.5",
"rimraf": "^5.0.7",
Expand Down
Loading

0 comments on commit b21fdfb

Please sign in to comment.