mirror of
https://github.com/hashicorp/vault.git
synced 2026-02-03 20:40:45 -05:00
Allow for console error and warn and fail for everything else. Remove disable rules for console. Co-authored-by: Angelo Cordon <angelo.cordon@hashicorp.com>
This commit is contained in:
parent
aa1349f5a5
commit
0d0a06c491
11 changed files with 39 additions and 26 deletions
|
|
@ -29,7 +29,7 @@ module.exports = {
|
|||
browser: true,
|
||||
},
|
||||
rules: {
|
||||
'no-console': 'error',
|
||||
'no-console': ['error', { allow: ['warn', 'error', 'info'] }],
|
||||
'prefer-const': ['error', { destructuring: 'all' }],
|
||||
'ember/no-mixins': 'warn',
|
||||
'ember/no-new-mixins': 'off', // should be warn but then every line of the mixin is green
|
||||
|
|
@ -42,6 +42,12 @@ module.exports = {
|
|||
'@typescript-eslint/no-unused-vars': ['error', { ignoreRestSiblings: true }],
|
||||
},
|
||||
overrides: [
|
||||
{
|
||||
files: ['scripts/generate-form-config.js'],
|
||||
rules: {
|
||||
'no-console': 'off',
|
||||
},
|
||||
},
|
||||
// node files
|
||||
{
|
||||
files: [
|
||||
|
|
|
|||
|
|
@ -66,7 +66,6 @@ export default class OpenApiForm<T extends object> extends Form<T> {
|
|||
);
|
||||
} else {
|
||||
// to aide in development log out an error to the console if the schema is not found
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(`OpenApiForm: Schema '${schemaKey}' not found in OpenAPI spec.`);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -184,8 +184,7 @@ export default Route.extend(ModelBoundaryRoute, ClusterRoute, {
|
|||
isEnterprise: Boolean(model.license),
|
||||
});
|
||||
} catch (e) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('unable to start analytics', e);
|
||||
console.error('unable to start analytics', e);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -27,8 +27,7 @@ export default class AnalyticsService extends Service {
|
|||
|
||||
private log(...args: unknown[]) {
|
||||
if (this.debug) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`[Analytics - ${this.provider.name}]`, ...args);
|
||||
console.info(`[Analytics - ${this.provider.name}]`, ...args);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -210,7 +210,7 @@ export default class ApiService extends Service {
|
|||
|
||||
// log out generic error for ease of debugging in dev env
|
||||
if (config.environment === 'development') {
|
||||
console.log('API Error:', e); // eslint-disable-line no-console
|
||||
console.error('API Error:', e);
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ export default class FlagsService extends Service {
|
|||
}
|
||||
} catch (error) {
|
||||
if (macroCondition(isDevelopingApp())) {
|
||||
console.error(error); // eslint-disable-line no-console
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -74,7 +74,7 @@ export default class FlagsService extends Service {
|
|||
return;
|
||||
} catch (error) {
|
||||
if (macroCondition(isDevelopingApp())) {
|
||||
console.error(error); // eslint-disable-line no-console
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@
|
|||
* SPDX-License-Identifier: BUSL-1.1
|
||||
*/
|
||||
|
||||
/* eslint-disable no-console */
|
||||
|
||||
import validators from 'vault/utils/forms/validators';
|
||||
import { get } from '@ember/object';
|
||||
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ export default class ReplicationDashboard extends Component {
|
|||
// when DR and Performance is enabled on the same cluster,
|
||||
// the states should always be the same
|
||||
// we are leaving this console log statement to be sure
|
||||
console.log('DR State: ', drState, 'Performance State: ', performanceState); // eslint-disable-line
|
||||
console.warn('DR State: ', drState, 'Performance State: ', performanceState);
|
||||
}
|
||||
|
||||
return drState;
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ export default class SyncSecretsDestinationsPageComponent extends Component<Args
|
|||
@action
|
||||
onModalError(errorMsg: string) {
|
||||
if (macroCondition(isDevelopingApp())) {
|
||||
console.error(errorMsg); // eslint-disable-line no-console
|
||||
console.error(errorMsg);
|
||||
}
|
||||
|
||||
const errors = [errorMsg];
|
||||
|
|
|
|||
|
|
@ -4,14 +4,11 @@
|
|||
*/
|
||||
|
||||
import { module, test } from 'qunit';
|
||||
|
||||
import sinon from 'sinon';
|
||||
|
||||
import { setupTest } from 'vault/tests/helpers';
|
||||
|
||||
class ProviderStub {
|
||||
name = 'testing';
|
||||
|
||||
start = sinon.stub();
|
||||
identify = sinon.stub();
|
||||
trackPageView = sinon.stub();
|
||||
|
|
@ -59,22 +56,37 @@ module('Unit | Service | analytics', function (hooks) {
|
|||
|
||||
module('#log', function (hooks) {
|
||||
hooks.beforeEach(function () {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log = sinon.stub(console, 'log');
|
||||
sinon.stub(console, 'info');
|
||||
});
|
||||
|
||||
hooks.afterEach(function () {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log.restore();
|
||||
console.info.restore();
|
||||
});
|
||||
|
||||
test('logging is not shown when inactive', function (assert) {
|
||||
test('logging does not show outside of dev environment', function (assert) {
|
||||
this.service.debug = false;
|
||||
// for the next few lines, console.log WILL NOT WORK AS EXPECTED
|
||||
this.service.trackPageView('a', null);
|
||||
this.service.trackPageView('test-route', { foo: 'bar' });
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
assert.true(console.log.notCalled, 'console.log is called');
|
||||
assert.true(console.info.notCalled, 'console.info is not called when debug is false');
|
||||
});
|
||||
|
||||
test('logging shows in dev environments with correct format', function (assert) {
|
||||
this.service.debug = true;
|
||||
this.service.trackPageView('test-route', { foo: 'bar' });
|
||||
|
||||
assert.true(
|
||||
console.info.calledOnceWith('[Analytics - dummy]', '$pageview', 'test-route', { foo: 'bar' }),
|
||||
'console.info is called once with correctly formatted message'
|
||||
);
|
||||
});
|
||||
|
||||
test('logging works for all public methods', function (assert) {
|
||||
this.service.debug = true;
|
||||
|
||||
this.service.identifyUser('user-123', { role: 'admin' });
|
||||
this.service.trackEvent('button-click', { location: 'sidebar' });
|
||||
|
||||
assert.strictEqual(console.info.callCount, 2, 'log is called for each public method');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -244,7 +244,7 @@ module('Unit | Service | api', function (hooks) {
|
|||
});
|
||||
|
||||
test('it should log out error in development environment', async function (assert) {
|
||||
const consoleStub = sinon.stub(console, 'log');
|
||||
const consoleStub = sinon.stub(console, 'error');
|
||||
sinon.stub(config, 'environment').value('development');
|
||||
const error = new Error('some js type error');
|
||||
await this.apiService.parseError(error);
|
||||
|
|
|
|||
Loading…
Reference in a new issue