Skip to content

Commit

Permalink
Packages: Extract Eslint config package
Browse files Browse the repository at this point in the history
  • Loading branch information
gziolo committed Nov 27, 2018
1 parent 5ac7b89 commit 90ab8dc
Show file tree
Hide file tree
Showing 8 changed files with 173 additions and 105 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Expand Up @@ -19,7 +19,7 @@ const majorMinorRegExp = escapeRegExp( version.replace( /\.\d+$/, '' ) ) + '(\\.
module.exports = {
root: true,
extends: [
'./eslint/config.js',
'@wordpress/eslint-config',
'plugin:jest/recommended'
],
env: {
Expand Down
142 changes: 45 additions & 97 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
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
24 changes: 24 additions & 0 deletions packages/eslint-config/README.md
@@ -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>
7 changes: 7 additions & 0 deletions packages/eslint-config/configs/esnext.js
@@ -0,0 +1,7 @@
module.exports = {
env: {
es6: true,
},

rules: require( './rules/esnext' ),
};
66 changes: 66 additions & 0 deletions packages/eslint-config/configs/rules/esnext.js
@@ -0,0 +1,66 @@
// see https://eslint.org/docs/rules/#ecmascript-6
//
module.exports = {
// require braces around arrow function bodies
'arrow-body-style': 'off',
// require parentheses around arrow function arguments
'arrow-parens': 'off',
// enforce consistent spacing before and after the arrow in arrow functions
'arrow-spacing': 'off',
// require super() calls in constructors
'constructor-super': 'error',
// enforce consistent spacing around * operators in generator functions
'generator-star-spacing': 'off',
// disallow reassigning class members
'no-class-assign': 'off',
// disallow arrow functions where they could be confused with comparisons
'no-confusing-arrow': 'off',
// disallow reassigning `const` variables
'no-const-assign': 'error',
// disallow duplicate class members
'no-dupe-class-members': 'error',
// disallow duplicate module imports
'no-duplicate-imports': 'error',
// disallow `new` operators with the `Symbol` object
'no-new-symbol': 'off',
// disallow specified modules when loaded by `import`
'no-restricted-imports': 'off',
// disallow `this`/`super` before calling `super()` in constructors
'no-this-before-super': 'off',
// disallow unnecessary computed property keys in object literals
'no-useless-computed-key': 'error',
// disallow unnecessary constructors
'no-useless-constructor': 'error',
// disallow renaming import, export, and destructured assignments to the same name
'no-useless-rename': 'off',
// require `let` or `const` instead of `var`
'no-var': 'error',
// require or disallow method and property shorthand syntax for object literals
'object-shorthand': 'off',
// require arrow functions as callbacks
'prefer-arrow-callback': 'off',
// require `const` declarations for variables that are never reassigned after declared
'prefer-const': 'error',
// require destructuring from arrays and/or objects
'prefer-destructuring': 'off',
// disallow `parseInt()` and `Number.parseInt()` in favor of binary, octal, and hexadecimal literals
'prefer-numeric-literals': 'off',
// require rest parameters instead of `arguments`
'prefer-rest-params': 'off',
// require spread operators instead of `.apply()`
'prefer-spread': 'off',
// require template literals instead of string concatenation
'prefer-template': 'off',
// require generator functions to contain `yield`
'require-yield': 'off',
// enforce spacing between rest and spread operators and their expressions
'rest-spread-spacing': 'off',
// enforce sorted import declarations within modules
'sort-imports': 'off',
// require symbol descriptions
'symbol-description': 'off',
// require or disallow spacing around embedded expressions of template strings
'template-curly-spacing': [ 'error', 'always' ],
// require or disallow spacing around the `*` in `yield*` expressions
'yield-star-spacing': 'off',
};
4 changes: 1 addition & 3 deletions eslint/config.js → packages/eslint-config/index.js
Expand Up @@ -2,13 +2,12 @@ module.exports = {
parser: 'babel-eslint',
extends: [
'wordpress',
'plugin:wordpress/esnext',
'./configs/esnext.js',
'plugin:react/recommended',
'plugin:jsx-a11y/recommended',
],
env: {
browser: false,
es6: true,
node: true,
},
parserOptions: {
Expand All @@ -22,7 +21,6 @@ module.exports = {
document: true,
},
plugins: [
'wordpress',
'react',
'jsx-a11y',
],
Expand Down

0 comments on commit 90ab8dc

Please sign in to comment.