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

AMP Stories: Use Gutenberg ESLint config #1894

Merged
merged 4 commits into from
Feb 21, 2019
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
209 changes: 10 additions & 199 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,202 +1,13 @@
{
"root": true,
"extends": [
"wordpress",
"eslint:recommended",
"plugin:react/recommended"
],
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"plugins": [
"react"
],
"env": {
"browser": true
},
"globals": {
"wp": true,
"window": true,
"document": true
},
"settings": {
"react": {
"pragma": "wp",
"version": "16.6"
}
},
"rules": {
"no-magic-numbers": [2, { "ignoreArrayIndexes": true, "ignore": [ -1, 0, 1 ] }],
"array-bracket-spacing": [
"error",
"always"
],
"brace-style": [
"error",
"1tbs"
],
"camelcase": [
"error",
{
"properties": "never"
}
],
"comma-dangle": [
"error",
"never"
],
"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
}
],
"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/no-children-prop": "off",
"react/prop-types": "off",
"react/react-in-jsx-scope": "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"
}
"extends": [ "plugin:@wordpress/eslint-plugin/recommended" ],
"settings": {
"react": {
"pragma": "wp",
"version": "16.6"
}
},
"globals": {
"wp": true,
}
}
65 changes: 32 additions & 33 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,31 @@ module.exports = function( grunt ) {
// Clean up the build.
clean: {
build: {
src: [ 'build' ]
}
src: [ 'build' ],
},
},

// Shell actions.
shell: {
options: {
stdout: true,
stderr: true
stderr: true,
},
readme: {
command: './vendor/xwp/wp-dev-lib/scripts/generate-markdown-readme' // Generate the readme.md.
command: './vendor/xwp/wp-dev-lib/scripts/generate-markdown-readme', // Generate the readme.md.
},
phpunit: {
command: 'phpunit'
command: 'phpunit',
},
verify_matching_versions: {
command: 'php bin/verify-version-consistency.php'
command: 'php bin/verify-version-consistency.php',
},
webpack_production: {
command: 'cross-env BABEL_ENV=production webpack'
command: 'cross-env BABEL_ENV=production webpack',
},
create_build_zip: {
command: 'if [ ! -e build ]; then echo "Run grunt build first."; exit 1; fi; if [ -e amp.zip ]; then rm amp.zip; fi; cd build; zip -r ../amp.zip .; cd ..; echo; echo "ZIP of build: $(pwd)/amp.zip"'
}
command: 'if [ ! -e build ]; then echo "Run grunt build first."; exit 1; fi; if [ -e amp.zip ]; then rm amp.zip; fi; cd build; zip -r ../amp.zip .; cd ..; echo; echo "ZIP of build: $(pwd)/amp.zip"',
},
},

// Deploys a git Repo to the WordPress SVN repo.
Expand All @@ -44,10 +44,10 @@ module.exports = function( grunt ) {
options: {
plugin_slug: 'amp',
build_dir: 'build',
assets_dir: 'wp-assets'
}
}
}
assets_dir: 'wp-assets',
},
},
},

} );

Expand All @@ -59,41 +59,40 @@ module.exports = function( grunt ) {

// Register tasks.
grunt.registerTask( 'default', [
'build'
'build',
] );

grunt.registerTask( 'readme', [
'shell:readme'
'shell:readme',
] );

grunt.registerTask( 'build', function() {
var done, spawnQueue, stdout;
done = this.async();
spawnQueue = [];
stdout = [];
const done = this.async();
const spawnQueue = [];
const stdout = [];

grunt.task.run( 'shell:webpack_production' );

spawnQueue.push(
{
cmd: 'git',
args: [ '--no-pager', 'log', '-1', '--format=%h', '--date=short' ]
args: [ '--no-pager', 'log', '-1', '--format=%h', '--date=short' ],
},
{
cmd: 'git',
args: [ 'ls-files' ]
args: [ 'ls-files' ],
}
);

function finalize() {
var commitHash, lsOutput, versionAppend, paths;
commitHash = stdout.shift();
lsOutput = stdout.shift();
versionAppend = new Date().toISOString().replace( /\.\d+/, '' ).replace( /-|:/g, '' ) + '-' + commitHash;
const commitHash = stdout.shift();
const lsOutput = stdout.shift();
const versionAppend = new Date().toISOString().replace( /\.\d+/, '' ).replace( /-|:/g, '' ) + '-' + commitHash;

paths = lsOutput.trim().split( /\n/ ).filter( function( file ) {
const paths = lsOutput.trim().split( /\n/ ).filter( function( file ) {
return ! /^(blocks|\.|bin|([^/]+)+\.(md|json|xml)|Gruntfile\.js|tests|wp-assets|readme\.md|composer\..*|patches|webpack.*|assets\/src)/.test( file );
} );

paths.push( 'vendor/autoload.php' );
paths.push( 'assets/js/*-compiled.js' );
paths.push( 'vendor/composer/**' );
Expand All @@ -110,7 +109,7 @@ module.exports = function( grunt ) {
options: {
noProcess: [ '*/**', 'LICENSE', 'jetpack-helper.php', 'wpcom-helper.php' ], // That is, only process amp.php and readme.txt.
process: function( content, srcpath ) {
var matches, version, versionRegex;
let matches, version, versionRegex;
if ( /amp\.php$/.test( srcpath ) ) {
versionRegex = /(\*\s+Version:\s+)(\d+(\.\d+)+-\w+)/;

Expand All @@ -124,9 +123,9 @@ module.exports = function( grunt ) {
}
}
return content;
}
}
}
},
},
},
} );
grunt.task.run( 'readme' );
grunt.task.run( 'copy' );
Expand All @@ -135,7 +134,7 @@ module.exports = function( grunt ) {
}

function doNext() {
var nextSpawnArgs = spawnQueue.shift();
const nextSpawnArgs = spawnQueue.shift();
if ( ! nextSpawnArgs ) {
finalize();
} else {
Expand All @@ -156,12 +155,12 @@ module.exports = function( grunt ) {
} );

grunt.registerTask( 'create-build-zip', [
'shell:create_build_zip'
'shell:create_build_zip',
] );

grunt.registerTask( 'deploy', [
'shell:phpunit',
'shell:verify_matching_versions',
'wp_deploy'
'wp_deploy',
] );
};
Loading