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: Introduce custom ESLint rules, including Lodash import restrictions #3015

Merged
merged 4 commits into from
Feb 8, 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
7 changes: 5 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ module.exports = {
'modules': true
},
'plugins': [
'eslint-plugin-react'
'eslint-plugin-react',
'eslint-plugin-wpcalypso'
],
'rules': {
'brace-style': [ 1, '1tbs' ],
Expand Down Expand Up @@ -89,6 +90,8 @@ module.exports = {
'valid-jsdoc': [ 1, { 'requireReturn': false } ],
// Common top-of-file requires, expressions between external, interal
'vars-on-top': 1,
'yoda': 0
'yoda': 0,
// Custom rules
"wpcalypso/no-lodash-import": 2
}
};
4 changes: 2 additions & 2 deletions client/lib/user/support-user-interop.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { compose } from 'lodash';
import compose from 'lodash/function/compose';

/**
* Internal dependencies
Expand Down Expand Up @@ -43,7 +43,7 @@ export default function( reduxStore ) {
// update the wpcom API interceptor accordingly.
reduxStore.subscribe( () => {
const state = reduxStore.getState();

if ( wpcom.setSupportUserToken( getSupportUser( state ), getSupportToken( state ) ) ) {
onTokenChange();
}
Expand Down
2 changes: 1 addition & 1 deletion client/my-sites/exporter/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* External dependencies
*/
import { connect } from 'react-redux';
import { compose } from 'lodash';
import compose from 'lodash/function/compose';

/**
* Internal dependencies
Expand Down
2 changes: 1 addition & 1 deletion client/my-sites/exporter/spinner-button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* External dependencies
*/
import React, { PropTypes } from 'react';
import { omit } from 'lodash';
import omit from 'lodash/object/omit';

/**
* Internal dependencies
Expand Down
7 changes: 5 additions & 2 deletions client/state/notices/actions.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* External dependencies
*/
import uniqueId from 'lodash/utility/uniqueId';

/**
* Internal dependencies
*/
Expand All @@ -7,8 +12,6 @@ import {
SET_ROUTE
} from 'state/action-types';

import { uniqueId } from 'lodash';

export function removeNotice( noticeId ) {
return {
noticeId: noticeId,
Expand Down
4 changes: 2 additions & 2 deletions docs/coding-guidelines/javascript.md
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,7 @@ More about:

## ESLint

To help encourages folks to follow the coding standards, there is a [ESLint](http://eslint.org/) configuration file ```.eslintrc``` that configures ESLint to detect code that doesn't follow the guidelines. ESLint also catches basic syntax errors, and natively supports both ES6 and JSX. It can be extended by plugins, such as [eslint-plugin-react](https://github.com/yannickcr/eslint-plugin-react), which we use in our configuration.
To help encourages folks to follow the coding standards, there is a [ESLint](http://eslint.org/) configuration file ```.eslintrc``` that configures ESLint to detect code that doesn't follow the guidelines. ESLint also catches basic syntax errors, and natively supports both ES6 and JSX. It can be extended by plugins, such as [`eslint-plugin-wpcalypso`](https://github.com/yannickcr/eslint-plugin-wpcalypso), which we use in our configuration.

There are [integrations](http://eslint.org/docs/user-guide/integrations) for many editors that will automatically detect the configuration file and run the checks.

Expand Down Expand Up @@ -1044,7 +1044,7 @@ If you are using Sublime Text, you can use the `SublimeLinter-eslint` plugin to
Before following these instructions, you'll want to globally install ESLint and related dependencies by running the following command in your terminal:

```bash
npm install -g eslint eslint-plugin-react babel-eslint
npm install -g eslint eslint-plugin-wpcalypso eslint-plugin-react babel-eslint
```

#### Identifying Spaces with Sublime Text
Expand Down
8 changes: 8 additions & 0 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@
"esformatter-special-bangs": "1.0.1",
"eslint": "1.10.3",
"eslint-plugin-react": "3.11.3",
"eslint-plugin-wpcalypso": "1.0.0",
"jsdom": "7.2.0",
"localStorage": "1.0.2",
"lodash-deep": "1.5.3",
Expand Down
4 changes: 2 additions & 2 deletions server/i18nlint/i18nlint.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ var fs = require( 'fs' ),
preProcessXGettextJSMatch = require( '../i18n/preprocess-xgettextjs-match.js' ),
SourceMapConsumer = require( 'source-map' ).SourceMapConsumer,
tokenize = require( '../../client/lib/interpolate-components/tokenize.js' ),
contains = require( 'lodash' ).contains,
flow = require( 'lodash' ).flow;
contains = require( 'lodash/collection/contains' ),
flow = require( 'lodash/function/flow' );

/*
* Module variables
Expand Down