Skip to content

Commit

Permalink
chore: fix lint
Browse files Browse the repository at this point in the history
Signed-off-by: Francisco Buceta <frbuceta@gmail.com>
  • Loading branch information
frbuceta committed Mar 31, 2022
1 parent 114be88 commit 47f1d62
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 45 deletions.
18 changes: 8 additions & 10 deletions .github/workflows/continuous-integration.yml
Expand Up @@ -2,9 +2,11 @@ name: Continuous Integration

on:
push:
branches: [master]
branches:
- master
pull_request:
branches: [master]
branches:
- master
schedule:
- cron: '0 2 * * 1' # At 02:00 on Monday

Expand Down Expand Up @@ -39,11 +41,9 @@ jobs:
- name: Bootstrap project
run: |
npm ci --ignore-scripts
npm run postinstall
npx lerna bootstrap
- name: Build project
run: |
npm run clean
npm run build
run: npm run build
- uses: Yuri6037/Action-FakeTTY@v1.1
- name: Run tests
run: faketty npm test --ignore-scripts
Expand Down Expand Up @@ -94,9 +94,7 @@ jobs:
- name: Bootstrap project
run: |
npm ci --ignore-scripts
npm run postinstall
- name: Build project
run: npm run build
npx lerna bootstrap
- name: Verify code linting
run: npm run lint
- name: Verify package metadata
Expand Down Expand Up @@ -131,7 +129,7 @@ jobs:
- name: Bootstrap project
run: |
npm ci --ignore-scripts
npm run postinstall
npx lerna bootstrap
- name: Build project
run: npm run build
- name: Verify doc changes
Expand Down
8 changes: 4 additions & 4 deletions extensions/socketio/src/socketio.server.ts
Expand Up @@ -152,9 +152,9 @@ export class SocketIoServer extends Context {
this.app.bind(getNamespaceKeyForName(meta.name)).to(nsp);
}

nsp.on('connection', socket =>
this.createSocketHandler(controllerClass)(socket),
);
nsp.on('connection', async socket => {
await this.createSocketHandler(controllerClass)(socket);
});
return nsp;
}

Expand All @@ -164,7 +164,7 @@ export class SocketIoServer extends Context {
*/
private createSocketHandler(
controllerClass: Constructor<object>,
): (socket: Socket) => void {
): (socket: Socket) => Promise<void> {
return async socket => {
debug(
'SocketIo connected: id=%s namespace=%s',
Expand Down
Expand Up @@ -52,7 +52,7 @@ describe('booter-lb3app', () => {
},
});

const schemas = (spec.components ?? {}).schemas ?? {};
const schemas = spec.components?.schemas ?? {};
expect(schemas._new_CoffeeShop)
.to.have.property('properties')
.eql({
Expand All @@ -68,7 +68,7 @@ describe('booter-lb3app', () => {

it('includes the target model as a property of the source model in a relation', async () => {
const spec = await app.restServer.getApiSpec();
const schemas = (spec.components ?? {}).schemas ?? {};
const schemas = spec.components?.schemas ?? {};

expect(schemas.CoffeeShop)
.to.have.property('properties')
Expand Down
31 changes: 10 additions & 21 deletions packages/eslint-config/eslintrc.js
Expand Up @@ -3,7 +3,7 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

const fs = require('fs');
const fs = require('node:fs');

/**
* Default ESLint configuration for LoopBack
Expand Down Expand Up @@ -162,20 +162,14 @@ module.exports = {
{
selector: 'variable',
format: null,
filter: {
regex: '^_$',
match: true,
},
filter: '^_$',
},

// For mixin functions
{
selector: 'function',
format: ['PascalCase'],
filter: {
regex: 'Mixin$',
match: true,
},
filter: 'Mixin$',
},

{
Expand All @@ -184,18 +178,6 @@ module.exports = {
leadingUnderscore: 'allow',
},

// For members such as `Content-Type` or `application/json` or `200`
{
selector: 'memberLike',
format: null,
filter: {
// you can expand this regex as you find more cases that require
// quoting that you want to allow
regex: '[0-9-/ ]',
match: true,
},
},

// For enum members
{
selector: 'enumMember',
Expand Down Expand Up @@ -243,6 +225,13 @@ module.exports = {
selector: 'typeLike',
format: ['PascalCase'],
},

{
selector: 'objectLiteralProperty',
format: null,
// filter: '^([2-5]{1}[0-9]{2})$|[-/ ]',
modifiers: ['requiresQuotes'],
},
],
},

Expand Down
1 change: 1 addition & 0 deletions packages/express/src/__tests__/acceptance/test-helpers.ts
Expand Up @@ -62,6 +62,7 @@ export class TestHelper {
}
}
const binding = this.app.controller(MyController);

const handler: ExpressRequestHandler = async (req, res, next) => {
try {
const controller = await this.app.get<MyController>(binding.key);
Expand Down
2 changes: 1 addition & 1 deletion packages/monorepo/lib/config-lerna-scopes.js
Expand Up @@ -14,7 +14,7 @@ const {getPackages, runMain} = require('./script-util');

module.exports = {
rules: {
// https://github.com/marionebl/commitlint/blob/master/docs/reference-rules.md
// eslint-disable-next-line @typescript-eslint/naming-convention
'scope-enum': async ctx => [2, 'always', await getPackageNames(ctx)],
},
};
Expand Down
Expand Up @@ -313,7 +313,7 @@ describe('controller spec', () => {
$ref: '#/components/schemas/Todo',
});

const globalSchemas = (spec.components ?? {}).schemas;
const globalSchemas = spec.components?.schemas;
expect(globalSchemas).to.deepEqual({
Todo: {
title: 'Todo',
Expand Down Expand Up @@ -362,7 +362,7 @@ describe('controller spec', () => {
$ref: '#/definitions/Todo',
});

const globalSchemas = (spec.components ?? {}).schemas;
const globalSchemas = spec.components?.schemas;
expect(globalSchemas).to.deepEqual({
Todo: {
title: 'Todo',
Expand Down Expand Up @@ -462,7 +462,7 @@ describe('controller spec', () => {
}

const spec = getControllerSpec(MyController);
const globalSchemas = (spec.components ?? {}).schemas;
const globalSchemas = spec.components?.schemas;
expect(globalSchemas).to.be.undefined();
});

Expand Down Expand Up @@ -533,7 +533,7 @@ describe('controller spec', () => {
},
});

const globalSchemas = (spec.components ?? {}).schemas;
const globalSchemas = spec.components?.schemas;
expect(globalSchemas).to.deepEqual({
Todo: {
title: 'Todo',
Expand Down Expand Up @@ -593,7 +593,7 @@ describe('controller spec', () => {
$ref: '#/components/schemas/Todo',
});

const globalSchemas = (spec.components ?? {}).schemas;
const globalSchemas = spec.components?.schemas;
expect(globalSchemas).to.deepEqual({
Todo: {
title: 'Todo',
Expand Down Expand Up @@ -861,7 +861,7 @@ describe('controller spec', () => {
$ref: '#/components/schemas/MyModel',
});

const globalSchemas = (spec.components ?? {}).schemas;
const globalSchemas = spec.components?.schemas;
expect(globalSchemas).to.deepEqual({
MyModel: {
title: 'MyModel',
Expand Down
2 changes: 1 addition & 1 deletion packages/rest-crud/src/crud-rest.controller.ts
Expand Up @@ -280,7 +280,7 @@ function getIdSchema<T extends Entity>(
const modelSchema = jsonToSchemaObject(
getJsonSchema(modelCtor),
) as SchemaObject;
return (modelSchema.properties ?? {})[idProp] as SchemaObject;
return modelSchema.properties?.[idProp] as SchemaObject;
}

// Temporary implementation of a short-hand version of `@requestBody`
Expand Down

0 comments on commit 47f1d62

Please sign in to comment.