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

Framework: Upgrade ESLint no-console to error #9039

Merged
merged 1 commit into from
Nov 1, 2016
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
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ module.exports = {
'keyword-spacing': 1,
'max-len': [ 1, { code: 140 } ],
'new-cap': [ 1, { capIsNew: false, newIsCap: true } ],
'no-console': 1,
'no-else-return': 1,
'no-extra-semi': 1,
'no-lonely-if': 1,
Expand Down
7 changes: 0 additions & 7 deletions client/components/count/test/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* External dependencies
*/
var expect = require( 'chai' ).expect,
sinon = require( 'sinon' ),
useMockery = require( 'test/helpers/use-mockery' );

describe( 'Count', function() {
Expand Down Expand Up @@ -78,10 +77,4 @@ describe( 'Count', function() {

expect( result.props.children ).to.equal( '3' );
} );

it( 'should warn when passing something that is not a number', sinon.test( function() {
this.stub( console, 'error' );
renderer.render( <Count count={ "17" } /> );
expect( console.error ).to.have.been.called;
} ) );
} );
15 changes: 13 additions & 2 deletions client/devdocs/docs-example/util.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
/* eslint-disable no-console */

/**
* External dependencies
*/
import debug from 'debug';

/**
* Module variables
*/
const log = debug( 'calypso:docs-example:util' );

const getComponentName = docsExample => {
if ( ! docsExample ) {
Expand All @@ -17,7 +28,7 @@ const getComponentName = docsExample => {

const slugToCamelCase = name => {
if ( ! name ) {
console.warn( 'name is not defined' );
log( 'name is not defined' );
return console.trace();
}

Expand All @@ -28,7 +39,7 @@ const slugToCamelCase = name => {

const camelCaseToSlug = name => {
if ( ! name ) {
console.warn( 'name is not defined' );
log( 'name is not defined' );
return console.trace();
}

Expand Down
29 changes: 20 additions & 9 deletions client/devdocs/main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/
var React = require( 'react' ),
isFunction = require( 'lodash/isFunction' );
import debug from 'debug';

/**
* Internal dependencies
Expand All @@ -12,15 +13,25 @@ var DocService = require( './service' ),
Main = require( 'components/main' ),
SearchCard = require( 'components/search-card' );

/**
* Constants
*/

var DEFAULT_FILES = [
'docs/guide/index.md',
'README.md',
'.github/CONTRIBUTING.md',
'docs/coding-guidelines.md',
'docs/coding-guidelines/javascript.md',
'docs/coding-guidelines/css.md',
'docs/coding-guidelines/html.md'
];
'docs/guide/index.md',
'README.md',
'.github/CONTRIBUTING.md',
'docs/coding-guidelines.md',
'docs/coding-guidelines/javascript.md',
'docs/coding-guidelines/css.md',
'docs/coding-guidelines/html.md'
];

/**
* Module variables
*/

const log = debug( 'calypso:devdocs' );

module.exports = React.createClass( {
displayName: 'Devdocs',
Expand Down Expand Up @@ -93,7 +104,7 @@ module.exports = React.createClass( {
}
DocService.search( term, function( err, results ) {
if ( err ) {
console.log( err );
log( 'search error: %o', err );
}

this.setState( {
Expand Down
8 changes: 7 additions & 1 deletion client/layout/error.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,19 @@ var ReactDom = require( 'react-dom' ),
assign = require( 'lodash/assign' ),
url = require( 'url' ),
qs = require( 'querystring' );
import debug from 'debug';

/**
* Internal dependencies
*/
var analytics = require( 'lib/analytics' ),
EmptyContent = require( 'components/empty-content' );

/**
* Module variables
*/
const log = debug( 'calypso:layout' );

var LoadingError = React.createClass( {

statics: {
Expand All @@ -34,7 +40,7 @@ var LoadingError = React.createClass( {
},

show: function( chunkName ) {
console.error( 'Chunk %s could not be loaded', chunkName );
log( 'Chunk %s could not be loaded', chunkName );
analytics.mc.bumpStat( 'calypso_chunk_error', chunkName );
ReactDom.render(
React.createElement( LoadingError, {} ),
Expand Down
24 changes: 22 additions & 2 deletions client/lib/catch-js-errors/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,28 @@
/**
* External dependencies
*/
import TraceKit from 'tracekit';
import debug from 'debug';

// Interval for error reports so we don't flood te endpoint. More frequent reports get throttled.
/**
* Module variables
*/

/**
* Interval for error reports so we don't flood te endpoint. More frequent
* reports get throttled.
*
* @type {Number}
*/
const REPORT_INTERVAL = 60000;

/**
* Debug logger
*
* @type {Function}
*/
const log = debug( 'calypso:error-logger' );

export default class ErrorLogger {
constructor() {
this.diagnosticData = {
Expand Down Expand Up @@ -79,7 +99,7 @@ export default class ErrorLogger {
this.saveDiagnosticData( diagnosticReducer() );
} catch ( e ) {
this.saveDiagnosticData( { diagnosticError: e.message } );
console.warn( 'diagnostic', this.diagnosticData );
log( 'diagnostic: %o', this.diagnosticData );
}
} );

Expand Down
18 changes: 9 additions & 9 deletions client/lib/create-selector/test/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable no-console */

/**
* External dependencies
*/
Expand All @@ -9,28 +11,26 @@ import sinon from 'sinon';
* Internal dependencies
*/
import createSelector from '../';
import { useSandbox } from 'test/helpers/use-sinon';

describe( 'index', () => {
let selector, getSitePosts;

before( () => {
selector = sinon.spy( ( state, siteId ) => {
useSandbox( ( sandbox ) => {
sandbox.stub( console, 'warn' );
selector = sandbox.spy( ( state, siteId ) => {
return filter( state.posts, { site_ID: siteId } );
} );
} );

before( () => {
getSitePosts = createSelector( selector, ( state ) => state.posts );
sinon.stub( console, 'warn' );
} );

beforeEach( () => {
console.warn.reset();
selector.reset();
getSitePosts.memoizedSelector.cache.clear();
} );

after( () => {
console.warn.restore();
} );

it( 'should expose its memoized function', () => {
expect( getSitePosts.memoizedSelector ).to.be.a( 'function' );
} );
Expand Down
2 changes: 2 additions & 0 deletions client/lib/css-hot-reload/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable no-console */

/**
* External dependencies
*/
Expand Down
10 changes: 8 additions & 2 deletions client/lib/localforage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@
*/
import localforage from 'localforage';
import reduce from 'lodash/reduce';
import debug from 'debug';

/**
* Internal dependencies
*/
import localforageBypass from './localforage-bypass';

/**
* Module variables
*/
const log = debug( 'calypso:localforage' );

const config = {
name: 'calypso',
storeName: 'calypso_store',
Expand All @@ -29,7 +35,7 @@ const localForagePromise = localforage.defineDriver( localforageBypass )
_ready = true;
return localforage;
} )
.catch( ( error ) => console.error( 'Configuring localforage: %s', error ) );
.catch( ( error ) => log( 'Configuring localforage: %s', error ) );

// Wraps a function to run after waiting until a promise has resolved.
// The promise should contain the original object for context.
Expand Down Expand Up @@ -58,7 +64,7 @@ const localForageProxy = reduce(

localForageProxy.bypass = () => {
if ( _ready ) {
console.error( 'Cannot bypass localforage after initialization' );
log( 'Cannot bypass localforage after initialization' );
} else {
config.driver = [ localforageBypass._driver ];
}
Expand Down
9 changes: 3 additions & 6 deletions client/lib/plugins/test/mocks/wpcom.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,17 @@ var pluginsInstallCalls = 0,
},

siteMock = {
plugin: function( pluginId ) {
console.log( 'Create %s plugin', pluginId );
plugin: function() {
return pluginMock;
},

wpcomPlugin: function( pluginId ) {
console.log( 'Create %s wpcom plugin', pluginId );
wpcomPlugin: function() {
return wpcomPluginMock;
}
},

mock = {
site: function( siteId ) {
console.log( 'Create %s site', siteId );
site: function() {
return siteMock;
},

Expand Down
7 changes: 5 additions & 2 deletions client/lib/service-worker/service-worker.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/* eslint-disable no-console */

/**
* This file is served as-is as /service-worker.js
**/
* WARNING: DO NOT USE ES2015+ OR COMMONJS. This file is served as-is and isn't
* transpiled by Babel or bundled by Webpack.
*/

/* eslint-disable */
'use strict';
Expand Down
1 change: 1 addition & 0 deletions client/lib/warn/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/** @ssr-ready **/
/* eslint-disable no-console */

/**
* Internal Dependencies
Expand Down
5 changes: 5 additions & 0 deletions client/lib/wrap-es6-functions/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/* eslint-disable no-console */

/**
* External dependencies
*/
import partial from 'lodash/partial';
import isFunction from 'lodash/isFunction';

Expand Down
5 changes: 0 additions & 5 deletions client/state/comments/test/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,6 @@ describe( 'utils', () => {

const isListsEqual = actualDatesList.equals( sortedDatesList );

if ( ! isListsEqual ) {
// hint what are the nodes involved
console.error( 'Bad child nodes', childNodesList );
}

expect( isListsEqual ).to.be.true;

if ( isListsEqual ) {
Expand Down
1 change: 0 additions & 1 deletion client/state/geo/test/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ describe( 'reducer', () => {
const state = geo( original, { type: DESERIALIZE } );

expect( state ).to.be.null;
expect( console.warn ).to.have.been.called; // eslint-disable-line no-console
} );
} );
} );
1 change: 0 additions & 1 deletion client/state/page-templates/test/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ describe( 'reducer', () => {
const state = items( original, { type: DESERIALIZE } );

expect( state ).to.eql( {} );
expect( console.warn ).to.have.been.calledTwice; // eslint-disable-line no-console
} );
} );
} );
1 change: 0 additions & 1 deletion client/state/post-types/test/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ describe( 'reducer', () => {
} ), { type: DESERIALIZE } );

expect( state ).to.eql( {} );
expect( console.warn ).to.have.been.calledOnce;
} );
} );
} );
10 changes: 3 additions & 7 deletions client/state/posts/test/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
*/
import { expect } from 'chai';
import deepFreeze from 'deep-freeze';
import sinon from 'sinon';

/**
* Internal dependencies
*/
import { useSandbox } from 'test/helpers/use-sinon';
import {
POST_DELETE,
POST_DELETE_SUCCESS,
Expand Down Expand Up @@ -37,12 +37,8 @@ import reducer, {
import PostQueryManager from 'lib/query-manager/post';

describe( 'reducer', () => {
before( () => {
sinon.stub( console, 'warn' );
} );

after( () => {
console.warn.restore();
useSandbox( ( sandbox ) => {
sandbox.stub( console, 'warn' );
} );

it( 'should include expected keys in return value', () => {
Expand Down
Loading