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

Packages: Extract Eslint config package #7965

Merged
merged 5 commits into from
Nov 30, 2018
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
16 changes: 7 additions & 9 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,8 @@ const majorMinorRegExp = escapeRegExp( version.replace( /\.\d+$/, '' ) ) + '(\\.
module.exports = {
root: true,
extends: [
'./eslint/config.js',
'plugin:jest/recommended'
],
env: {
Copy link
Member Author

@gziolo gziolo Nov 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It turned out plugin:jest/recommended includes the related env and plugins config :)

https://github.com/jest-community/eslint-plugin-jest/blob/master/index.js#L35-L52

'jest/globals': true,
},
plugins: [
'jest',
'@wordpress/eslint-config',
'plugin:jest/recommended',
],
rules: {
'no-restricted-syntax': [
Expand Down Expand Up @@ -189,9 +183,13 @@ module.exports = {
overrides: [
{
files: [ 'test/e2e/**/*.js' ],
env: {
browser: true,
},
globals: {
page: true,
browser: true,
page: true,
wp: true,
},
},
],
Expand Down
6 changes: 6 additions & 0 deletions docs/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,12 @@
"markdown_source": "https://github.com/raw/WordPress/gutenberg/master/packages/escape-html/README.md",
"parent": "packages"
},
{
"title": "@wordpress/eslint-config",
"slug": "packages-eslint-config",
"markdown_source": "https://github.com/raw/WordPress/gutenberg/master/packages/eslint-config/README.md",
"parent": "packages"
},
{
"title": "@wordpress/format-library",
"slug": "packages-format-library",
Expand Down
147 changes: 44 additions & 103 deletions package-lock.json

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

5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"@wordpress/babel-preset-default": "file:packages/babel-preset-default",
"@wordpress/browserslist-config": "file:packages/browserslist-config",
"@wordpress/custom-templated-path-webpack-plugin": "file:packages/custom-templated-path-webpack-plugin",
"@wordpress/eslint-config": "file:packages/eslint-config",
"@wordpress/jest-console": "file:packages/jest-console",
"@wordpress/jest-preset-default": "file:packages/jest-preset-default",
"@wordpress/library-export-default-webpack-plugin": "file:packages/library-export-default-webpack-plugin",
Expand All @@ -80,11 +81,7 @@
"deasync": "0.1.13",
"deep-freeze": "0.0.1",
"doctrine": "2.1.0",
"eslint-config-wordpress": "2.0.0",
"eslint-plugin-jest": "21.5.0",
"eslint-plugin-jsx-a11y": "6.0.2",
"eslint-plugin-react": "7.7.0",
"eslint-plugin-wordpress": "git://github.com/WordPress-Coding-Standards/eslint-plugin-wordpress.git#1774343f6226052a46b081e01db3fca8793cc9f1",
"espree": "3.5.4",
"glob": "7.1.2",
"husky": "0.14.3",
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
Expand Up @@ -5,6 +5,8 @@ import { Component } from '@wordpress/element';
import { __, _x } from '@wordpress/i18n';
import { BACKSPACE, DELETE, F10 } from '@wordpress/keycodes';

const { wp } = window;

function isTmceEmpty( editor ) {
// When tinyMce is empty the content seems to be:
// <p><br data-mce-bogus="1"></p>
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,14 +1,16 @@
/**
* External Dependencies
*/
import { castArray, pick } from 'lodash';
import { castArray, defaults, pick } from 'lodash';

/**
* WordPress dependencies
*/
import { Component } from '@wordpress/element';
import { __ } from '@wordpress/i18n';

const { wp } = window;

// Getter for the sake of unit tests.
const getGalleryDetailsMediaFrame = () => {
/**
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
24 changes: 24 additions & 0 deletions packages/eslint-config/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# ESLint Config

[ESLint](https://eslint.org/) config for WordPress development.

## Installation

Install the module

```bash
npm install @wordpress/eslint-config --save-dev
```

### Usage

Next, extend the configuration from your project's `.eslintrc` file:

```json
"extends": "@wordpress/eslint-config"
```

Refer to the [ESLint documentation on Shareable Configs](http://eslint.org/docs/developer-guide/shareable-configs) for more information.


<br/><br/><p align="center"><img src="https://s.w.org/style/images/codeispoetry.png?1" alt="Code is Poetry." /></p>
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' ),
};
8 changes: 8 additions & 0 deletions packages/eslint-config/configs/esnext.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* 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 = {
rules: require( './rules/es5' ),
};
Loading