Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: import eslint rules from eslint-config-loopback #3043

Merged
merged 1 commit into from
Jun 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/cli/test/integration/lib/project-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module.exports = function(projGenerator, props, projectType) {

describe('_setupGenerator', () => {
describe('args validation', () => {
it('errors out if validation fails', () => {
it('errors out if validation fails for an argument value', () => {
const result = testUtils
.executeGenerator(projGenerator)
.withArguments(['fooBar']);
Expand All @@ -45,7 +45,7 @@ module.exports = function(projGenerator, props, projectType) {
);
});

it('errors out if validation fails', () => {
it('errors out if validation fails for an option value', () => {
const result = testUtils
.executeGenerator(projGenerator)
.withOptions({name: 'fooBar'})
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/test/unit/utils.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ describe('Utils', () => {
);
});

it('returns string for an array check with a number', () => {
it('returns string for an array check with an object', () => {
expect(utils.validateStringObject('array')({})).to.be.eql(
'The value must be a stringified array',
);
Expand All @@ -374,7 +374,7 @@ describe('Utils', () => {
expect(utils.validateStringObject('object')('{}')).to.be.True();
});

it('returns string for an array check with an object', () => {
it('returns string for an array check with an object-like string', () => {
expect(utils.validateStringObject('array')('{}')).to.be.eql(
'The value must be a stringified array',
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ describe('Context bindings - Injecting dependencies of classes', () => {
expect(store.locations).to.eql(['San Francisco', 'San Jose']);
});

it('injects values by tag asynchronously', async () => {
it('reports correct resolution path when injecting values by tag', async () => {
class Store {
constructor(@inject.tag('store:location') public locations: string[]) {}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe('BindingComparator', () => {
assertOrder('validator1', 'validator2', 'metrics', 'logger1');
});

it('sorts by binding order without phase tags', () => {
it('sorts by binding order without phase tags (for symbol tags)', () => {
/**
* Phases
* - '': validator1 // not part of ['log', 'auth']
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/__tests__/unit/application.unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ describe('Application', () => {
expect(binding.tagNames).to.containEql('foo');
});

it('binds providers from a component', () => {
it('honors tags when binding providers from a component', () => {
@bind({tags: ['foo']})
class MyProvider implements Provider<string> {
value() {
Expand Down
9 changes: 9 additions & 0 deletions packages/eslint-config/eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ module.exports = {
// TypeScript allows the same name for namespace and function
'no-redeclare': 'off',

/**
* Rules imported from eslint-config-loopback
*/
'mocha/handle-done-callback': 'error',
'mocha/no-exclusive-tests': 'error',
'mocha/no-identical-title': 'error',
'mocha/no-nested-tests': 'error',
'no-array-constructor': 'error',

/**
* TypeScript specific rules
* See https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin#supported-rules
Expand Down
30 changes: 20 additions & 10 deletions packages/rest/src/__tests__/unit/rest.component.unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,21 @@ import {aRestServerConfig} from '../helpers';
const SequenceActions = RestBindings.SequenceActions;
describe('RestComponent', () => {
describe('Providers', () => {
describe('Default implementations are bound', () => {
describe('Default implementation', () => {
let app: Application;
let comp: Component;

const EXPECTED_KEYS = [
RestBindings.SequenceActions.LOG_ERROR.key,
RestBindings.SequenceActions.FIND_ROUTE.key,
RestBindings.SequenceActions.INVOKE_METHOD.key,
RestBindings.SequenceActions.REJECT.key,
RestBindings.BIND_ELEMENT.key,
RestBindings.GET_FROM_CONTEXT.key,
RestBindings.SequenceActions.PARSE_PARAMS.key,
RestBindings.SequenceActions.SEND.key,
];

before(async () => {
app = new Application();
app.component(RestComponent);
Expand All @@ -42,16 +53,15 @@ describe('RestComponent', () => {
comp = await app.get<Component>('components.RestComponent');
});

it('', async () => {
for (const key in comp.providers || {}) {
it(key, async () => {
const result = await app.get(key);
const expected: Provider<BoundValue> = new comp.providers![key]();
expect(result).to.deepEqual(expected.value());
});
}
});
for (const key of EXPECTED_KEYS) {
it(`binds ${key}`, async () => {
const result = await app.get(key);
const expected: Provider<BoundValue> = new comp.providers![key]();
expect(result).to.deepEqual(expected.value());
});
}
});

describe('LOG_ERROR', () => {
it('matches expected argument signature', async () => {
const app = new Application();
Expand Down