Skip to content

Commit dd28963

Browse files
authored
refactor: reenabling no-this-alias and no-non-null-asserted-option-chain rules (#1307)
- **refactor: reenable no this alias rule** - **refactor(test): enabling no-non-null-asserted-option-chain** SDK-2233 SDK-2232 <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Low risk lint-driven refactor: behavior is unchanged aside from passing `this` directly and tightening test typing assumptions. > > **Overview** > Re-enables the TypeScript ESLint rules `@typescript-eslint/no-this-alias` and `@typescript-eslint/no-non-null-asserted-optional-chain` by removing their disables from `.eslintrc.js`. > > Updates affected code to comply: `BrowserTelemetryImpl` no longer aliases `this` before calling `makeInspectors`, and the prerequisite evaluator tests remove `?.` + `!` optional-chain assertions when accessing `testPayload.flags`. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit cd60b80. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent afbed0f commit dd28963

3 files changed

Lines changed: 5 additions & 8 deletions

File tree

.eslintrc.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ module.exports = {
3939
'@typescript-eslint/ban-ts-comment': 'off',
4040
'@typescript-eslint/ban-types': 'off',
4141
'@typescript-eslint/no-var-requires': 'off',
42-
'@typescript-eslint/no-non-null-asserted-optional-chain': 'off',
43-
'@typescript-eslint/no-this-alias': 'off',
4442
'@typescript-eslint/no-unused-vars': [
4543
'error',
4644
{ ignoreRestSiblings: true, argsIgnorePattern: '^_', varsIgnorePattern: '^__' },

packages/shared/sdk-server/__tests__/evaluation/Evaluator.prerequisite.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ describe('given a flag payload with prerequisites', () => {
131131

132132
it('can track prerequisites for a basic prereq', async () => {
133133
const res = await evaluator.evaluate(
134-
testPayload?.flags['has-prereq-depth-1']!,
134+
testPayload.flags['has-prereq-depth-1']!,
135135
Context.fromLDContext({ kind: 'user', key: 'bob' }),
136136
new EventFactory(true),
137137
);
@@ -143,7 +143,7 @@ describe('given a flag payload with prerequisites', () => {
143143

144144
it('can track prerequisites for a prereq of a prereq', async () => {
145145
const res = await evaluator.evaluate(
146-
testPayload?.flags['has-prereq-depth-2']!,
146+
testPayload.flags['has-prereq-depth-2']!,
147147
Context.fromLDContext({ kind: 'user', key: 'bob' }),
148148
new EventFactory(true),
149149
);
@@ -155,7 +155,7 @@ describe('given a flag payload with prerequisites', () => {
155155

156156
it('can track prerequisites for a flag with multiple prereqs with and without additional prereqs', async () => {
157157
const res = await evaluator.evaluate(
158-
testPayload?.flags['has-prereq-depth-3']!,
158+
testPayload.flags['has-prereq-depth-3']!,
159159
Context.fromLDContext({ kind: 'user', key: 'bob' }),
160160
new EventFactory(true),
161161
);
@@ -168,7 +168,7 @@ describe('given a flag payload with prerequisites', () => {
168168
it('has can handle a prerequisite failure', async () => {
169169
testPayload.flags['is-prereq'].on = false;
170170
const res = await evaluator.evaluate(
171-
testPayload?.flags['has-prereq-depth-3']!,
171+
testPayload.flags['has-prereq-depth-3']!,
172172
Context.fromLDContext({ kind: 'user', key: 'bob' }),
173173
new EventFactory(true),
174174
);

packages/telemetry/browser-telemetry/src/BrowserTelemetryImpl.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,8 @@ export default class BrowserTelemetryImpl implements BrowserTelemetry {
170170
collector.register(this as BrowserTelemetry, this._sessionId),
171171
);
172172

173-
const impl = this;
174173
const inspectors: BrowserTelemetryInspector[] = [];
175-
makeInspectors(_options, inspectors, impl);
174+
makeInspectors(_options, inspectors, this);
176175
this._inspectorInstances.push(...inspectors);
177176
}
178177

0 commit comments

Comments
 (0)