Skip to content

Commit 6b14e6f

Browse files
authored
Fe 294 v2.3 ngx jsonapi corregir los errores (#332)
1 parent d4f52cd commit 6b14e6f

35 files changed

+333
-269
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- run: yarn prettier-ts:show --list-different
1515
- run: yarn prettier-md:show --list-different
1616
- run: yarn prettier-scss:show --list-different
17-
# - run: yarn lint Descomentar en la tarea FE-294
17+
- run: yarn lint
1818
- save_cache:
1919
key: *cache_key
2020
paths:

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66

77
## [Unreleased]
88

9+
### Fixed
10+
11+
- Fixed error lint with eslint ([#332](https://github.com/reyesoft/ngx-jsonapi/pull/332))
12+
913
### Changed
1014

1115
- Migrated tslint to eslint. ([#331](https://github.com/reyesoft/ngx-jsonapi/pull/331))

src/cloned-document-resource.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export class ClonedDocumentResource {
6565
if (!this.resource_object.data.relationships || !this.parent_resource_object.data.relationships) {
6666
return this;
6767
}
68+
// eslint-disable-next-line no-restricted-syntax
6869
for (let relationship in this.resource_object.data.relationships) {
6970
if (
7071
isEqual(this.resource_object.data.relationships[relationship], this.parent_resource_object.data.relationships[relationship])
@@ -80,6 +81,7 @@ export class ClonedDocumentResource {
8081
if (!this.resource_object.data.attributes || !this.parent_resource_object.data.attributes) {
8182
return this;
8283
}
84+
// eslint-disable-next-line no-restricted-syntax
8385
for (let attribute in this.resource_object.data.attributes) {
8486
if (this.resource_object.data.attributes[attribute] === this.parent_resource_object.data.attributes[attribute]) {
8587
delete this.resource_object.data.attributes[attribute];

src/document-collection.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ export class RelatedDocumentCollection<R extends Resource = Resource> extends Do
5151
}
5252

5353
// convert and add new dataresoures to final collection
54-
let new_ids = {};
54+
let new_ids: any = {};
5555
this.data.length = 0;
5656
this.builded = data_collection.data && data_collection.data.length === 0;
5757
for (let dataresource of data_collection.data) {
5858
try {
59-
let res = this.getResourceOrFail(dataresource);
59+
let res: Resource = this.getResourceOrFail(dataresource);
6060
res.fill({ data: dataresource });
6161
new_ids[dataresource.id] = dataresource.id;
6262
(<Array<R>>this.data).push(<R>res);

src/document.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ interface IDocumentHasResource {
2020
data: Resource;
2121
content: 'resource';
2222
}
23-
export /* abstract */ class Document
24-
implements IDocumentData, IDocumentHasResources, IDocumentHasIds, IDocumentHasId, IDocumentHasResource {
23+
export class Document implements IDocumentData, IDocumentHasResources, IDocumentHasIds, IDocumentHasId, IDocumentHasResource {
2524
public data: any;
2625
public builded: boolean = false;
2726
public content: any;

src/jsonapi-config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ export class JsonapiConfig {
33
public params_separator?: string = '?';
44
public unify_concurrency?: boolean = true;
55
public cache_prerequests?: boolean = true;
6-
/* eslint-disable id-blacklist */
6+
/* eslint-disable */
77
public parameters?:
88
| {
99
page: {
@@ -17,5 +17,5 @@ export class JsonapiConfig {
1717
size: 'page[size]'
1818
}
1919
};
20-
/* eslint-enable id-blacklist */
20+
/* eslint-enable */
2121
}

src/resource.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ describe('resource', () => {
5151
let exec_spy: jasmine.Spy = spyOn(Core, 'exec').and.returnValue(of({ data: response }));
5252
await resource.save();
5353
resource.relationships = {};
54-
let expected_resource_in_save = {
54+
let expected_resource_in_save: any = {
5555
data: {
5656
type: 'tests',
5757
id: '1234',
@@ -291,7 +291,7 @@ describe('resource.toObject() method', () => {
291291
book.removeRelationship('author', '1');
292292
expect(book.relationships.author.data).toBeNull();
293293

294-
let book_object = book.toObject();
294+
let book_object: IDocumentResource = book.toObject();
295295
expect(book_object.data.relationships?.author.data).toBeNull();
296296
expect(book_object.included).toBeFalsy();
297297
});

src/resource.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ export class Resource implements ICacheable {
360360
});
361361
}
362362

363-
public setCacheLastUpdate(value = Date.now()): void {
363+
public setCacheLastUpdate(value: number = Date.now()): void {
364364
this.cache_last_update = value;
365365
}
366366
}

src/service.spec.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,7 @@ describe('service.all() and next service.get()', () => {
766766
map(emit => {
767767
expect(http_request_spy).not.toHaveBeenCalled();
768768
expect(emit.relationships.author.data.attributes.name).toBeTruthy();
769+
769770
return { loaded: emit.loaded, source: emit.source };
770771
}),
771772
toArray()
@@ -796,8 +797,8 @@ describe('service.all() and next service.get()', () => {
796797
let book: Book = await booksService.get('1', { include: ['author'] }).toPromise();
797798
expect(book.id).toBe('1');
798799
test_response_subject.complete();
799-
800-
let books_api = TestFactory.getCollectionDocumentData(Book, 1, ['author']);
800+
// eslint-disable-next-line
801+
let books_api: IDocumentData<Resource> = TestFactory.getCollectionDocumentData(Book, 1, ['author']);
801802
books_api.data[0].id = '1';
802803
test_response_subject = new BehaviorSubject(new HttpResponse());
803804
test_response_subject.next(new HttpResponse({ body: books_api }));
@@ -812,6 +813,7 @@ describe('service.all() and next service.get()', () => {
812813
if (emit.loaded) {
813814
expect(emit.data[0].relationships.author.data.attributes.name).toBeTruthy();
814815
}
816+
815817
return { loaded: emit.loaded, source: emit.source };
816818
}),
817819
toArray()
@@ -995,6 +997,7 @@ describe('service.get()', () => {
995997
let emits: Array<{
996998
loaded: boolean;
997999
source: SourceType;
1000+
// eslint-disable-next-line max-lines
9981001
}> = await booksService
9991002
.get('1', { ttl: 1000, include: ['author'] })
10001003
.pipe(
@@ -1251,7 +1254,7 @@ describe('service.get()', () => {
12511254
test_response_subject.next(new HttpResponse({ body: body_resource }));
12521255

12531256
book.ttl = 0;
1254-
let json_ripper = new JsonRipper();
1257+
let json_ripper: JsonRipper = new JsonRipper();
12551258
json_ripper.saveResource(book);
12561259
let cachememory: CacheMemory = CacheMemory.getInstance();
12571260
cachememory.removeResource('books', '1'); // kill only memory cache

src/service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ export class Service<R extends Resource = Resource> {
266266
path.applyParams(this, builded_params);
267267

268268
let temporary_collection: DocumentCollection<R> = this.getOrCreateCollection(path);
269+
// eslint-disable-next-line id-blacklist
269270
temporary_collection.page.number = builded_params.page.number * 1;
270271

271272
let subject: BehaviorSubject<DocumentCollection<R>> = new BehaviorSubject<DocumentCollection<R>>(temporary_collection);
@@ -344,11 +345,10 @@ export class Service<R extends Resource = Resource> {
344345
success => {
345346
// this create a new ID for every resource (for caching proposes)
346347
// for example, two URL return same objects but with different attributes
347-
// tslint:disable-next-line:deprecation
348348
if (params.cachehash) {
349349
Object.keys(success.data).forEach((key): void => {
350350
let resource: any = success.data[key];
351-
// eslint-disable-next-line deprecation
351+
// eslint-disable-next-line
352352
resource.id = resource.id + params.cachehash;
353353
});
354354
}

0 commit comments

Comments
 (0)