-
Notifications
You must be signed in to change notification settings - Fork 368
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Webpack/Eslinting for Gutenberg blocks (#1533)
* Initial import from the add/jobs-shortcode-block branch * Fix linting issue and remove job related block include.
- Loading branch information
Showing
8 changed files
with
366 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"presets": [ | ||
[ "env", { | ||
"modules": false, | ||
"targets": { | ||
"browsers": [ | ||
"last 2 Chrome versions", | ||
"last 2 Firefox versions", | ||
"last 2 Safari versions", | ||
"last 2 iOS versions", | ||
"last 1 Android version", | ||
"last 1 ChromeAndroid version" | ||
] | ||
} | ||
} ] | ||
], | ||
"plugins": [ | ||
[ "transform-react-jsx", { | ||
"pragma": "wp.element.createElement" | ||
} ], | ||
"transform-class-properties", | ||
"transform-object-rest-spread", | ||
"lodash" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
assets/build | ||
assets/js | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,176 @@ | ||
module.exports = { | ||
root: true, | ||
parser: 'babel-eslint', | ||
extends: [ | ||
'wordpress', | ||
'plugin:wordpress/esnext', | ||
'plugin:react/recommended', | ||
'plugin:jsx-a11y/recommended', | ||
], | ||
env: { | ||
browser: true, | ||
es6: true, | ||
}, | ||
parserOptions: { | ||
sourceType: 'module', | ||
ecmaFeatures: { | ||
jsx: true, | ||
}, | ||
}, | ||
globals: { | ||
wp: true, | ||
window: true, | ||
document: true, | ||
"jQuery": true, | ||
"ajaxurl": true, | ||
"woo_localized_data": true | ||
}, | ||
plugins: [ | ||
'wordpress', | ||
'react', | ||
'jsx-a11y', | ||
], | ||
settings: { | ||
react: { | ||
pragma: 'wp', | ||
}, | ||
}, | ||
rules: { | ||
'array-bracket-spacing': [ 'error', 'always' ], | ||
'arrow-parens': [ 'error', 'always' ], | ||
'arrow-spacing': 'error', | ||
'brace-style': [ 'error', '1tbs' ], | ||
camelcase: [ 'error', { properties: 'never' } ], | ||
'comma-dangle': [ 'error', 'always-multiline' ], | ||
'comma-spacing': 'error', | ||
'comma-style': 'error', | ||
'computed-property-spacing': [ 'error', 'always' ], | ||
'dot-notation': 'error', | ||
'eol-last': 'error', | ||
eqeqeq: 'error', | ||
'func-call-spacing': 'error', | ||
indent: [ 'error', 'tab', { SwitchCase: 1 } ], | ||
'jsx-a11y/label-has-for': [ 'error', { | ||
required: 'id', | ||
} ], | ||
'jsx-a11y/media-has-caption': 'off', | ||
'jsx-a11y/no-noninteractive-tabindex': 'off', | ||
'jsx-a11y/role-has-required-aria-props': 'off', | ||
'jsx-quotes': 'error', | ||
'key-spacing': 'error', | ||
'keyword-spacing': 'error', | ||
'lines-around-comment': 'off', | ||
'no-alert': 'error', | ||
'no-bitwise': 'error', | ||
'no-caller': 'error', | ||
'no-console': 'error', | ||
'no-debugger': 'error', | ||
'no-dupe-args': 'error', | ||
'no-dupe-keys': 'error', | ||
'no-duplicate-case': 'error', | ||
'no-else-return': 'error', | ||
'no-eval': 'error', | ||
'no-extra-semi': 'error', | ||
'no-fallthrough': 'error', | ||
'no-lonely-if': 'error', | ||
'no-mixed-operators': 'error', | ||
'no-mixed-spaces-and-tabs': 'error', | ||
'no-multiple-empty-lines': [ 'error', { max: 1 } ], | ||
'no-multi-spaces': 'error', | ||
'no-multi-str': 'off', | ||
'no-negated-in-lhs': 'error', | ||
'no-nested-ternary': 'error', | ||
'no-redeclare': 'error', | ||
'no-restricted-syntax': [ | ||
'error', | ||
{ | ||
selector: 'CallExpression[callee.name=/^__|_n|_x$/]:not([arguments.0.type=/^Literal|BinaryExpression$/])', | ||
message: 'Translate function arguments must be string literals.', | ||
}, | ||
{ | ||
selector: 'CallExpression[callee.name=/^_n|_x$/]:not([arguments.1.type=/^Literal|BinaryExpression$/])', | ||
message: 'Translate function arguments must be string literals.', | ||
}, | ||
{ | ||
selector: 'CallExpression[callee.name=_nx]:not([arguments.2.type=/^Literal|BinaryExpression$/])', | ||
message: 'Translate function arguments must be string literals.', | ||
}, | ||
], | ||
'no-shadow': 'error', | ||
'no-undef': 'error', | ||
'no-undef-init': 'error', | ||
'no-unreachable': 'error', | ||
'no-unsafe-negation': 'error', | ||
'no-unused-expressions': 'error', | ||
'no-unused-vars': 'error', | ||
'no-useless-return': 'error', | ||
'no-whitespace-before-property': 'error', | ||
'object-curly-spacing': [ 'error', 'always' ], | ||
'padded-blocks': [ 'error', 'never' ], | ||
'quote-props': [ 'error', 'as-needed' ], | ||
'react/display-name': 'off', | ||
'react/jsx-curly-spacing': [ 'error', { | ||
when: 'always', | ||
children: true, | ||
} ], | ||
'react/jsx-equals-spacing': 'error', | ||
'react/jsx-indent': [ 'error', 'tab' ], | ||
'react/jsx-indent-props': [ 'error', 'tab' ], | ||
'react/jsx-key': 'error', | ||
'react/jsx-tag-spacing': 'error', | ||
'react/no-children-prop': 'off', | ||
'react/prop-types': 'off', | ||
semi: 'error', | ||
'semi-spacing': 'error', | ||
'space-before-blocks': [ 'error', 'always' ], | ||
'space-before-function-paren': [ 'error', { | ||
anonymous: 'never', | ||
named: 'never', | ||
asyncArrow: 'always', | ||
} ], | ||
'space-in-parens': [ 'error', 'always' ], | ||
'space-infix-ops': [ 'error', { int32Hint: false } ], | ||
'space-unary-ops': [ 'error', { | ||
overrides: { | ||
'!': true, | ||
yield: true, | ||
}, | ||
} ], | ||
'valid-jsdoc': [ 'error', { | ||
prefer: { | ||
arg: 'param', | ||
argument: 'param', | ||
extends: 'augments', | ||
returns: 'return', | ||
}, | ||
preferType: { | ||
array: 'Array', | ||
bool: 'boolean', | ||
Boolean: 'boolean', | ||
float: 'number', | ||
Float: 'number', | ||
int: 'number', | ||
integer: 'number', | ||
Integer: 'number', | ||
Number: 'number', | ||
object: 'Object', | ||
String: 'string', | ||
Void: 'void', | ||
}, | ||
requireParamDescription: false, | ||
requireReturn: false, | ||
} ], | ||
'valid-typeof': 'error', | ||
yoda: 'off', | ||
}, | ||
overrides: [ | ||
{ | ||
files: 'packages/**/*.js?', | ||
settings: { | ||
react: { | ||
pragma: 'createElement', | ||
}, | ||
}, | ||
}, | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
/** | ||
* Handles Job Manager's Gutenberg Blocks. | ||
* | ||
* @package wp-job-manager | ||
* @since 1.32.0 | ||
*/ | ||
|
||
if ( ! defined( 'ABSPATH' ) ) { | ||
exit; // Exit if accessed directly. | ||
} | ||
|
||
/** | ||
* WP_Job_Manager_Blocks | ||
*/ | ||
class WP_Job_Manager_Blocks { | ||
/** | ||
* The static instance of the WP_Job_Manager_Blocks | ||
* | ||
* @var self | ||
*/ | ||
private static $_instance = null; | ||
|
||
/** | ||
* Singleton instance getter | ||
* | ||
* @return self | ||
*/ | ||
public static function get_instance() { | ||
if ( ! self::$_instance ) { | ||
self::$_instance = new WP_Job_Manager_Blocks(); | ||
} | ||
|
||
return self::$_instance; | ||
} | ||
|
||
/** | ||
* Instance constructor | ||
*/ | ||
private function __construct() { | ||
if ( ! function_exists( 'register_block_type' ) ) { | ||
return; | ||
} | ||
|
||
add_action( 'init', array( $this, 'register_blocks' ) ); | ||
} | ||
|
||
/** | ||
* Register all Gutenblocks | ||
*/ | ||
public function register_blocks() { | ||
// Add script includes for gutenblocks. | ||
} | ||
} | ||
|
||
WP_Job_Manager_Blocks::get_instance(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.