Skip to content

Commit da3ceb4

Browse files
author
James Fox
authored
chore (ESLint): Add no-shadow rule to error (#35)
* add no-shadow rule to error * fix existing violations of no-shadow
1 parent ea5d086 commit da3ceb4

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

.eslintrc.js

+1
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,6 @@ module.exports = {
2626
'@typescript-eslint/ban-ts-ignore': 'off',
2727
'@typescript-eslint/camelcase': 'off',
2828
'@typescript-eslint/no-empty-function': 'off',
29+
'no-shadow': 'error',
2930
},
3031
};

src/Feature.spec.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { OptimizelyFeature } from './Feature';
2626
describe('<OptimizelyFeature>', () => {
2727
let resolver: any;
2828
let optimizelyMock: ReactSDKClient;
29-
const isEnabled = true;
29+
const isEnabledMock = true;
3030
const featureVariables = {
3131
foo: 'bar',
3232
};
@@ -42,7 +42,7 @@ describe('<OptimizelyFeature>', () => {
4242
optimizelyMock = ({
4343
onReady: jest.fn().mockImplementation(config => onReadyPromise),
4444
getFeatureVariables: jest.fn().mockImplementation(() => featureVariables),
45-
isFeatureEnabled: jest.fn().mockImplementation(() => isEnabled),
45+
isFeatureEnabled: jest.fn().mockImplementation(() => isEnabledMock),
4646
onUserUpdate: jest.fn().mockImplementation(handler => () => {}),
4747
notificationCenter: {
4848
addNotificationListener: jest.fn().mockImplementation((type, handler) => {}),

src/Provider.tsx

+6-6
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616
import * as React from 'react';
17-
import * as optimizely from '@optimizely/optimizely-sdk';
17+
import { UserAttributes } from '@optimizely/optimizely-sdk';
1818
import { getLogger } from '@optimizely/js-sdk-logging';
1919

2020
import { OptimizelyContextProvider } from './Context';
@@ -25,7 +25,7 @@ const logger = getLogger('<OptimizelyProvider>');
2525

2626
type UserInfo = {
2727
id: string;
28-
attributes?: optimizely.UserAttributes;
28+
attributes?: UserAttributes;
2929
};
3030

3131
interface OptimizelyProviderProps {
@@ -34,7 +34,7 @@ interface OptimizelyProviderProps {
3434
isServerSide?: boolean;
3535
user?: Promise<UserInfo> | UserInfo;
3636
userId?: string;
37-
userAttributes?: optimizely.UserAttributes;
37+
userAttributes?: UserAttributes;
3838
}
3939

4040
interface OptimizelyProviderState {
@@ -50,13 +50,13 @@ export class OptimizelyProvider extends React.Component<OptimizelyProviderProps,
5050
// check if user id/attributes are provided as props and set them ReactSDKClient
5151
let finalUser: {
5252
id: string;
53-
attributes: optimizely.UserAttributes;
53+
attributes: UserAttributes;
5454
} | null = null;
5555

5656
if (user) {
5757
if ('then' in user) {
58-
user.then(user => {
59-
optimizely.setUser(user);
58+
user.then((res: UserInfo) => {
59+
optimizely.setUser(res);
6060
});
6161
} else {
6262
finalUser = {

0 commit comments

Comments
 (0)