Skip to content

Commit

Permalink
Remove no longer necessary globals from the Eslint config
Browse files Browse the repository at this point in the history
  • Loading branch information
gziolo committed Nov 28, 2018
1 parent 2f1e4ad commit d5256b4
Show file tree
Hide file tree
Showing 8 changed files with 121 additions and 123 deletions.
28 changes: 17 additions & 11 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* External dependencies
*/
const { escapeRegExp, map } = require( 'lodash' );
const pluginJest = require( 'eslint-plugin-jest' );

/**
* Internal dependencies
Expand All @@ -18,16 +19,7 @@ const majorMinorRegExp = escapeRegExp( version.replace( /\.\d+$/, '' ) ) + '(\\.

module.exports = {
root: true,
extends: [
'@wordpress/eslint-config',
'plugin:jest/recommended'
],
env: {
'jest/globals': true,
},
plugins: [
'jest',
],
extends: '@wordpress/eslint-config',
rules: {
'no-restricted-syntax': [
'error',
Expand Down Expand Up @@ -187,11 +179,25 @@ module.exports = {
} ],
},
overrides: [
{
files: [
'packages/**/test/**/*.js',
'packages/block-serialization-spec-parser/shared-tests.js',
'packages/jest-*/**/*.js',
'test/integration/**/*.js',
'test/e2e/**/*.js',
],
...pluginJest.configs.recommended,
},
{
files: [ 'test/e2e/**/*.js' ],
env: {
browser: true,
},
globals: {
page: true,
browser: true,
page: true,
wp: true,
},
},
],
Expand Down
2 changes: 2 additions & 0 deletions packages/block-library/src/classic/edit.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* global wp */

/**
* WordPress dependencies
*/
Expand Down
6 changes: 4 additions & 2 deletions packages/edit-post/src/hooks/components/media-upload/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/* global wp */

/**
* External Dependencies
*/
import { castArray, pick } from 'lodash';
import { castArray, defaults, pick } from 'lodash';

/**
* WordPress dependencies
Expand Down Expand Up @@ -36,7 +38,7 @@ const getGalleryDetailsMediaFrame = () => {
multiple: 'add',
editable: false,

library: wp.media.query( _.defaults( {
library: wp.media.query( defaults( {
type: 'image',
}, this.options.library ) ),
} ),
Expand Down
12 changes: 12 additions & 0 deletions packages/eslint-config/configs/es5.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* The original version of this file is based on WordPress ESLint rules and shared configs:
* https://github.com/WordPress-Coding-Standards/eslint-plugin-wordpress.
*/

module.exports = {
env: {
es6: true,
},

rules: require( './rules/esnext' ),
};
6 changes: 1 addition & 5 deletions packages/eslint-config/configs/esnext.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,5 @@
*/

module.exports = {
env: {
es6: true,
},

rules: require( './rules/esnext' ),
rules: require( './rules/es5' ),
};
84 changes: 84 additions & 0 deletions packages/eslint-config/configs/rules/es5.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
module.exports = {
// Possible Errors
// Disallow assignment in conditional expressions
'no-cond-assign': [ 'error', 'except-parens' ],
// Disallow irregular whitespace outside of strings and comments
'no-irregular-whitespace': 'error',
// Best Practices
// Specify curly brace conventions for all control statements
curly: [ 'error', 'all' ],
// Encourages use of dot notation whenever possible
'dot-notation': [ 'error', {
allowKeywords: true,
allowPattern: '^[a-z]+(_[a-z]+)+$',
} ],
// Disallow use of multiline strings
'no-multi-str': 'error',
// Disallow use of the with statement
'no-with': 'error',
// Requires to declare all vars on top of their containing scope
'vars-on-top': 'error',
// Require immediate function invocation to be wrapped in parentheses
'wrap-iife': 'error',
// Require or disallow Yoda conditions
yoda: [ 'error', 'always' ],
// Strict Mode
// Variables
// Stylistic Issues
// Enforce spacing inside array brackets
'array-bracket-spacing': [ 'error', 'always' ],
// Enforce one true brace style
'brace-style': 'error',
// Require camel case names
camelcase: [ 'error', {
properties: 'always',
} ],
// Disallow or enforce trailing commas
'comma-dangle': [ 'error', 'never' ],
// Enforce spacing before and after comma
'comma-spacing': 'error',
// Enforce one true comma style
'comma-style': [ 'error', 'last' ],
// Enforce newline at the end of file, with no multiple empty lines
'eol-last': 'error',
// Enforces spacing between keys and values in object literal properties
'key-spacing': [ 'error', {
beforeColon: false,
afterColon: true,
} ],
// Enforce spacing before and after keywords
'keyword-spacing': 'error',
// Disallow mixed "LF" and "CRLF" as linebreaks
'linebreak-style': [ 'error', 'unix' ],
// Enforces empty lines around comments
'lines-around-comment': [ 'error', {
beforeLineComment: true,
} ],
// Disallow mixed spaces and tabs for indentation
'no-mixed-spaces-and-tabs': 'error',
// Disallow multiple empty lines
'no-multiple-empty-lines': 'error',
// Disallow trailing whitespace at the end of lines
'no-trailing-spaces': 'error',
// Require or disallow an newline around variable declarations
'one-var-declaration-per-line': [ 'error', 'initializations' ],
// Enforce operators to be placed before or after line breaks
'operator-linebreak': [ 'error', 'after' ],
// Specify whether backticks, double or single quotes should be used
quotes: [ 'error', 'single' ],
// Require or disallow use of semicolons instead of ASI
semi: [ 'error', 'always' ],
// Require or disallow space before blocks
'space-before-blocks': [ 'error', 'always' ],
// Require or disallow space before function opening parenthesis
'space-before-function-paren': [ 'error', 'never' ],
// Require or disallow space before blocks
'space-in-parens': [ 'error', 'always', { exceptions: [ '{}', '[]' ] } ],
// Require spaces around operators
'space-infix-ops': 'error',
// Require or disallow spaces before/after unary operators (words on by default, nonwords)
'space-unary-ops': [ 'error', {
overrides: { '!': true },
} ],
// Legacy
};
103 changes: 0 additions & 103 deletions packages/eslint-config/configs/wordpress.js

This file was deleted.

3 changes: 1 addition & 2 deletions packages/eslint-config/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
module.exports = {
parser: 'babel-eslint',
extends: [
'./configs/wordpress.js',
'./configs/es5.js',
'./configs/esnext.js',
'plugin:react/recommended',
'plugin:jsx-a11y/recommended',
],
env: {
browser: false,
node: true,
},
parserOptions: {
Expand Down

0 comments on commit d5256b4

Please sign in to comment.