Skip to content

Commit

Permalink
Separate strict from loose-mode in tests/main eslintrc
Browse files Browse the repository at this point in the history
  • Loading branch information
gitKrystan committed Nov 20, 2023
1 parent b0113ad commit 86ec920
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 22 deletions.
21 changes: 21 additions & 0 deletions tests/main/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,28 @@ module.exports = {
overrides: [
node.config(),
node.defaults(),
typescript.defaults(),
// files converted to strict must pass these rules before they can be removed from
// the files list here
// see https://github.com/emberjs/data/issues/6233#issuecomment-849279594
typescript.defaults({
files: [
'./tests/helpers/accessors.ts',
'./tests/integration/identifiers/configuration-test.ts',
'./tests/integration/identifiers/lid-reflection-test.ts',
'./tests/integration/identifiers/new-records-test.ts',
'./tests/integration/identifiers/polymorphic-scenarios-test.ts',
'./tests/integration/identifiers/record-identifier-for-test.ts',
'./tests/integration/identifiers/scenarios-test.ts',
'./tests/integration/model-errors-test.ts',
'./tests/integration/record-data/record-data-errors-test.ts',
'./tests/integration/record-data/record-data-state-test.ts',
'./tests/integration/record-data/record-data-test.ts',
'./tests/integration/record-data/store-wrapper-test.ts',
'./tests/integration/relationships/rollback-test.ts',
'./tests/integration/request-state-service-test.ts',
'./tests/unit/custom-class-support/custom-class-model-test.ts',
],
rules: {
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
Expand Down
42 changes: 20 additions & 22 deletions tests/main/tests/integration/identifiers/scenarios-test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import EmberObject, { set } from '@ember/object';

import { module, test } from 'qunit';
Expand All @@ -16,12 +15,7 @@ import {
setIdentifierUpdateMethod,
} from '@ember-data/store';
import type { GenerationMethod, ResourceData } from '@ember-data/store/-types/q/identifier';
import type {
Identifier,
IdentifierBucket,
StableIdentifier,
StableRecordIdentifier,
} from '@warp-drive/core-types/identifier';
import type { IdentifierBucket, StableIdentifier, StableRecordIdentifier } from '@warp-drive/core-types/identifier';

function isNonEmptyString(str: unknown): str is string {
return typeof str === 'string' && str.length > 0;
Expand All @@ -35,17 +29,14 @@ module('Integration | Identifiers - scenarios', function (hooks) {
setupTest(hooks);

module('Secondary Cache based on an attribute', function (innerHooks) {
const calls = {
findRecord: 0,
queryRecord: 0,
};
let calls;
let isQuery = false;
let secondaryCache: {
id: { [key: string]: string };
username: { [key: string]: string };
};
class TestSerializer extends EmberObject {
normalizeResponse(_, __, payload: unknown) {
normalizeResponse(_, __, payload) {
return payload;
}
}
Expand Down Expand Up @@ -93,10 +84,15 @@ module('Integration | Identifiers - scenarios', function (hooks) {
owner.register('serializer:application', TestSerializer);
owner.register('model:user', User);

calls = {
findRecord: 0,
queryRecord: 0,
};

let localIdInc = 9000;
secondaryCache = {
id: Object.create(null) as Record<string, string>,
username: Object.create(null) as Record<string, string>,
id: Object.create(null),
username: Object.create(null),
};
const generationMethod: GenerationMethod = (resource: unknown, bucket: IdentifierBucket) => {
if (bucket !== 'record') {
Expand Down Expand Up @@ -246,14 +242,11 @@ module('Integration | Identifiers - scenarios', function (hooks) {
});

module('Secondary Cache using an attribute as an alternate id', function (innerHooks) {
const calls = {
findRecord: 0,
queryRecord: 0,
};
let calls;
let isQuery = false;
let secondaryCache: { [key: string]: string };
class TestSerializer extends EmberObject {
normalizeResponse(_, __, payload: unknown) {
normalizeResponse(_, __, payload) {
return payload;
}
}
Expand Down Expand Up @@ -301,8 +294,13 @@ module('Integration | Identifiers - scenarios', function (hooks) {
owner.register('serializer:application', TestSerializer);
owner.register('model:user', User);

calls = {
findRecord: 0,
queryRecord: 0,
};

let localIdInc = 9000;
secondaryCache = Object.create(null) as Record<string, string>;
secondaryCache = Object.create(null);

function lidForUser(resource: ResourceData | { type: string }): string {
if ('type' in resource && resource.type === 'user') {
Expand Down Expand Up @@ -661,7 +659,7 @@ module('Integration | Identifiers - scenarios', function (hooks) {
});
};

function updateUsernameCache(identifier: Identifier, oldUsername: string, newUsername: string) {
function updateUsernameCache(identifier, oldUsername, newUsername) {
if (secondaryCache[oldUsername] !== identifier.lid) {
throw new Error(`Incorrect username update`);
}
Expand All @@ -670,7 +668,7 @@ module('Integration | Identifiers - scenarios', function (hooks) {
}
secondaryCache[newUsername] = identifier.lid;
}
function commitUsernameUpdate(identifier: Identifier, oldUsername: string, newUsername: string) {
function commitUsernameUpdate(identifier, oldUsername, newUsername) {
if (secondaryCache[oldUsername] === identifier.lid) {
delete secondaryCache[oldUsername];
}
Expand Down

0 comments on commit 86ec920

Please sign in to comment.