Skip to content
This repository was archived by the owner on Nov 10, 2022. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from 63 commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
4aa2f6a
Add initial setup of the front-end workflow based on Node and Gulp (t…
delawski Jul 3, 2017
390fb81
Make it possible to use multiple front-end workflows directly from `p…
delawski Jul 4, 2017
f7d55d8
Add the JS workflow based on Browserify allowing for multiple bundles…
delawski Jul 4, 2017
5b702cb
Fix minor code typos.
delawski Jul 4, 2017
f5feb46
Use `browserslist` with `babel-preset-env` and `babelify` to compile …
delawski Jul 5, 2017
522be75
Add JS Lint task to the workflow.
delawski Jul 5, 2017
da8c5f0
Use better name for the config module.
delawski Jul 5, 2017
fbfdf3b
Add `watch` task to the workflow.
delawski Jul 6, 2017
ec5b126
Fix typo in prop name.
delawski Jul 10, 2017
1c84803
Add `images` task.
delawski Jul 10, 2017
14b16b2
Add `copy` task.
delawski Jul 10, 2017
839ecd8
Improve `env` parameter handling.
delawski Jul 10, 2017
4f6696d
Rename `fe-workflow` to more general `workflows`
delawski Jul 10, 2017
d0b8f1a
Introduce `TaskHelper` class and make use of it in Gulp tasks.
delawski Jul 11, 2017
c6e1f74
Update `package.json` template.
delawski Jul 11, 2017
3abb4b6
Add support for `postcss-assets` processor. Improve PostCSS processor…
delawski Jul 12, 2017
57bf6ca
Update `package.json`.
delawski Jul 12, 2017
36cbf7b
Updated to Gulp 4
mehigh Jul 12, 2017
96b7461
Updated devDependencies
mehigh Jul 13, 2017
f0d873d
Run Gulp 4 tasks sequentially. Simplify `css-lint` task configuration.
delawski Jul 13, 2017
221eb85
Merge branch 'feature/front-end-workflow' into feature/front-end-work…
delawski Jul 13, 2017
34fd6ee
Make sure all tasks have proper display names.
delawski Jul 13, 2017
7952f41
Filtred undefined paths
mehigh Jul 13, 2017
60bc56b
Replacing yarn by npm
mehigh Jul 13, 2017
afb19b0
Use `merge-stream` instead of `event-stream` in order to have task co…
delawski Jul 14, 2017
42c949f
Flatten `workflows` object - no need for separate `env` definition.
delawski Jul 14, 2017
d81cb5e
Improve tasks handling in the `gulpfile`.
delawski Jul 14, 2017
d800e72
Run `clean` task in series with other tasks being run in parallel.
delawski Jul 14, 2017
42e8d5d
Get rid of `cwd` in the tasks list as soon as possible.
delawski Jul 14, 2017
3b71783
Add preliminary test for Node min. version. Improve parallel/serial t…
delawski Jul 14, 2017
4ef3741
Updated browserslist to match Wordpress standards
mehigh Jul 17, 2017
d90f671
Updated the path to include the ./dev-lib such that it can be run fro…
mehigh Jul 17, 2017
f14ec3c
Updating minimum requirement to 6.11 (in node's stable tag)
mehigh Jul 17, 2017
bc1152e
Add support for `schemas`.
delawski Jul 19, 2017
f271623
Merge branch 'feature/front-end-workflow-update' of github.com:xwp/wp…
delawski Jul 19, 2017
d0ab033
Adjusted css schema to have /css
mehigh Jul 21, 2017
0df8259
Webpack JS
mehigh Jul 21, 2017
432e8cb
Added webpack dependencies, removed babelify browserify. added basic …
mehigh Jul 21, 2017
93541b2
JS: Added default theme schema
mehigh Jul 21, 2017
eb3e393
JS: Cleaned package.json - added sample vendors.js 2nd js compilation
mehigh Jul 21, 2017
6fcb209
Adding jQuery global to ESLint due to high percentage of WP sites usi…
mehigh Jul 24, 2017
a6a08fb
Added no unsupported browser features to the styles linting plugin
mehigh Jul 24, 2017
d4e0316
Disabled eslint.format in dev to avoid the formatting updates from tr…
mehigh Jul 24, 2017
924a9e3
Added plumber and eslint to webpack workflow
mehigh Jul 24, 2017
152a6eb
Updated comment about task that watches for JS
mehigh Jul 24, 2017
487d181
Updated authors / contributors + shrank the dependencies list accordi…
mehigh Jul 24, 2017
d285e82
ESLint Ignored the dist directory
mehigh Jul 24, 2017
66746b8
Added back empty test script
mehigh Jul 24, 2017
cd8c9ad
Fixed contributors
mehigh Jul 24, 2017
7cb7a13
Remove unneeded code in the `JS` task.
delawski Jul 24, 2017
07106c4
Remove commented out code and slight code improvements.
delawski Jul 24, 2017
b807afd
Recommendations for workflow updates.
kopepasah Jul 24, 2017
5e02f9d
Update FE workflow:
delawski Jul 24, 2017
7c4b07a
Update quotes for JSON.
kopepasah Jul 25, 2017
f63fc78
Set rules as null to not enforce.
kopepasah Jul 25, 2017
193fcce
Merge branch 'feature/front-end-workflow-update' into feature/front-e…
kopepasah Jul 25, 2017
49de169
Make it possible to ignore tasks from the initial list.
delawski Jul 25, 2017
63b0dfb
Merge pull request #246 from xwp/feature/front-end-workflow-update-recs
mehigh Jul 25, 2017
57b7055
Use `dependencies` instead of `devDependencies`.
delawski Jul 25, 2017
fea9cc0
Merge branch 'feature/front-end-workflow-update' of github.com:xwp/wp…
delawski Jul 25, 2017
db047d4
Add transpiled gulpfile.
delawski Jul 25, 2017
5187884
Transpile whole directory, not single file.
delawski Jul 25, 2017
0431731
Split Workflows into `src` and `dist` folders. Clean up `package.json`.
delawski Jul 25, 2017
53023b1
Update `package.json`.
delawski Jul 26, 2017
7083b04
Ignore `npm-debug.log`.
delawski Jul 26, 2017
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
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
**/*.min.js
**/node_modules/**
**/vendor/**
**/dist/**
10 changes: 8 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
{
"env": {
"browser": true
"browser": true,
"es6": true,
"node": true
},
"parserOptions": {
"sourceType": "module"
},
"globals": {
"_": false,
"Backbone": false,
"jQuery": false,
"jQuery": true,
"wp": false
},
"extends": "wordpress",
"rules": {
"accessor-pairs": [2],
"block-scoped-var": [2],
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
codecept.phar
node_modules
3 changes: 2 additions & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"curly": true,
"eqeqeq": true,
"eqnull": true,
"es3": true,
"esversion": 6,
"expr": true,
"immed": true,
"noarg": true,
Expand All @@ -15,6 +15,7 @@
"unused": true,

"browser": true,
"node": true,

"globals": {
"_": false,
Expand Down
7 changes: 7 additions & 0 deletions build-workflows.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

set -e

rm -rf ./workflows/dist
./node_modules/.bin/babel ./workflows/src --out-dir ./workflows/dist
mv ./workflows/dist/gulpfile.babel.js ./workflows/dist/gulpfile.js
128 changes: 123 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,136 @@
"name": "wp-dev-lib",
"version": "1.0.0",
"description": "Common code used during development of WordPress plugins and themes",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": "xwp/wp-dev-lib",
"engines": {
"node": ">=6.11.x"
},
"keywords": [
"wordpress",
"plugins",
"themes",
"development",
"tools"
],
"author": "Weston Ruter <weston@xwp.co> (https://xwp.co)",
"author": {
"name": "Weston Ruter",
"email": "weston.ruter@xwp.co",
"url": "https://www.xwp.co"
},
"contributors": [
{
"name": "Piotr Delawski",
"email": "piotr.delawski@xwp.co"
},
{
"name": "Mike Crantea",
"email": "mike.crantea@xwp.co"
},
{
"name": "Justin Kopepasah",
"email": "justin.kopepasah@xwp.co",
"url": "https://kopepasah.com"
}
],
"license": "MIT",
"homepage": "https://github.com/xwp/wp-dev-lib#readme"
"homepage": "https://github.com/xwp/wp-dev-lib#readme",
"scripts": {
"build:self": "./build-workflows.sh",
"test": "echo \"Error: no test specified\" && exit 1"
},
"browserslist": [
"last 2 Chrome versions",
"last 2 Firefox versions",
"last 2 Safari versions",
"last 2 Edge versions",
"last 2 Opera versions",
"last 2 iOS versions",
"last 1 Android version",
"last 1 ChromeAndroid version",
"ie 11",
"> 1%"
],
"babel": {
"presets": [
[
"env"
]
]
},
"stylelint": {
"extends": "stylelint-config-wordpress/scss",
"plugins": [
"stylelint-no-unsupported-browser-features"
],
"rules": {
"string-quotes": "single",
"color-hex-length": null,
"function-parentheses-space-inside": null,
"function-url-quotes": "always",
"at-rule-empty-line-before": [
"always",
{
"except": [
"first-nested",
"blockless-after-same-name-blockless"
],
"ignore": [
"after-comment"
],
"ignoreAtRules": [
"else",
"elseif"
]
}
],
"plugin/no-unsupported-browser-features": [
true,
{
"severity": "warning"
}
],
"selector-pseudo-element-colon-notation": "double",
"value-keyword-case": null

@ntwb ntwb Jul 25, 2017

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Why are the WordPress CSS Coding Standards being overridden here?

(For clarification, there are 8 rules being overridden, not easily reviewable in the PR review view)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

See also the stylelint pull request #239 where the proposal is to use styelint-config-wordpress as is without overriding any rules

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@ntwb Thank you for your comment.

First of all, please note that this ruleset is still a work in progress and may change.

To answer your question - we decided to relax or override some of the rules defined in the stylelint-config-wordpress/scss based on the way we usually format our SCSS code.

In some points our best practices align quite well with the CSS rules set by Automattic in the Calypso project:

  • We prefer using single quotes (string-quotes). It reflects the way strings in PHP and JS are treated in WordPress.
  • We always use quotes, in url functions too (function-url-quotes).
  • We allow whitespace inside parentheses (function-parentheses-space-inside). It, again, better reflects the way we format PHP and JS code.
  • We are not requiring the hex color values to be short whenever possible (color-hex-length), since they will get optimized/shortened in the SCSS compilation process.

There are also grey areas, not defined in the WordPress CSS Coding Standards, e.g.:

  • Since the standards describe CSS and not SCSS code, we decided to set the at-rule-empty-line-before rule in this particular way. We feel that the code is easier to read with the such setup.
  • The standards don't mention the selector-pseudo-element-colon-notation. Our guess is that the requirement for a single colon is included in the stylelint-config-wordpress to maintain the Internet Explorer 8 support. Since IE 8 is no longer supported by WordPress as of version 4.8, we feel our code should use the valid CSS notation, i.e. double colons.

When it comes to the value-keyword-case my opinion is that is should not be overridden here. We should always use lowercase for CSS values. @mehigh and @kopepasah what do you think about it?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I agree value-keyword-case should be enforced to lower.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Where we diverge from core standards, should we not create a separate ruleset like stylelint-ruleset-xwp that inherits from stylelint-ruleset-wordpress? Then wp-dev-lib can continue to just use stylelint-ruleset-wordpress and our projects can override the package.json to specify our flavour. Otherwise, we should try to upstream our changes if they are compelling.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks for the detailed explanation @delawski, I now see what I was missing here was a bit of context that @westonruter has now clarified. As is obvious that this repo is a XWP project, I also know quite a few people outside of XWP use this repo(or least parts of it) so diverging from WordPress' Coding Standards had me a little perplexed.

Going the route of creating stylelint-config-xwp would be 👌

Your guess in regard to selector-pseudo-element-colon-notation is correct, it was because of IE8, I've created WordPress-Coding-Standards/stylelint-config-wordpress#165 to update to double colons 👍

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This sounds really good. I went ahead and created a stylelint-config-xwp based on the stylelint-config-wordpress.

I will update the wp-dev-lib to use stylelint-config-wordpress while on most non-Core projects we will use stylelint-config-xwp.

}
},
"dependencies": {
"autoprefixer": "^7.1.2",
"babel-cli": "^6.24.1",
"babel-core": "^6.25.0",
"babel-loader": "^7.1.1",
"babel-preset-env": "^1.6.0",
"del": "^3.0.0",
"eslint": "^4.3.0",
"eslint-config-wordpress": "^2.0.0",
"eslint-loader": "^1.9.0",
"eslint-plugin-compat": "^1.0.4",
"gulp": "gulpjs/gulp.git#4.0",
"gulp-cached": "^1.1.1",
"gulp-eslint": "^4.0.0",
"gulp-if": "^2.0.2",
"gulp-imagemin": "^3.3.0",
"gulp-plumber": "^1.1.0",
"gulp-postcss": "^7.0.0",
"gulp-progeny": "^0.4.0",
"gulp-sass": "^3.1.0",
"gulp-sourcemaps": "^2.6.0",
"gulp-watch": "^4.3.11",
"lodash": "^4.17.4",
"postcss": "^6.0.8",
"postcss-assets": "^4.2.0",
"postcss-cssnext": "^3.0.2",
"postcss-pxtorem": "^4.0.1",
"postcss-reporter": "^4.0.0",
"postcss-scss": "^1.0.2",
"progress-bar-webpack-plugin": "^1.10.0",
"require-dir": "^0.3.2",
"stylelint": "^7.13.0",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This should be ^8.0.0 as stylelint-config-wordpress's 12.0.0 requires stylelint 8.0.0

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good catch! Thank you. We will update the stylelint version here.

"stylelint-config-wordpress": "^12.0.0",
"stylelint-no-unsupported-browser-features": "^1.0.0",
"validate-node-version": "^1.1.1",
"webpack": "^3.3.0",
"webpack-config-utils": "^2.3.0",
"webpack-stream": "^3.2.0",
"yargs": "^8.0.2"
}
}
17 changes: 17 additions & 0 deletions workflows/dist/gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict';

var _gulp = require('gulp');

var _gulp2 = _interopRequireDefault(_gulp);

var _preCheck = require('./utils/pre-check');

var _getTasks = require('./utils/get-tasks');

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

// Check Node version and workflow setup.
(0, _preCheck.preCheck)();

// Define default task.
_gulp2.default.task('default', _gulp2.default.series((0, _getTasks.getTasks)()));
31 changes: 31 additions & 0 deletions workflows/dist/tasks/clean.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
'use strict';

var _gulp = require('gulp');

var _gulp2 = _interopRequireDefault(_gulp);

var _getConfig = require('../utils/get-config');

var _del = require('del');

var _del2 = _interopRequireDefault(_del);

var _TaskHelper = require('../utils/TaskHelper');

var _TaskHelper2 = _interopRequireDefault(_TaskHelper);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var task = new _TaskHelper2.default({
name: 'clean',
requiredPaths: ['src'],
config: _getConfig.tasks
});

_gulp2.default.task(task.name, function (done) {
if (task.isValid()) {
(0, _del2.default)(task.src).then(function () {
return done();
});
}
});
35 changes: 35 additions & 0 deletions workflows/dist/tasks/copy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
'use strict';

var _gulp = require('gulp');

var _gulp2 = _interopRequireDefault(_gulp);

var _gulpIf = require('gulp-if');

var _gulpIf2 = _interopRequireDefault(_gulpIf);

var _gulpCached = require('gulp-cached');

var _gulpCached2 = _interopRequireDefault(_gulpCached);

var _getConfig = require('../utils/get-config');

var _TaskHelper = require('../utils/TaskHelper');

var _TaskHelper2 = _interopRequireDefault(_TaskHelper);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var task = new _TaskHelper2.default({
name: 'copy',
requiredPaths: ['src', 'dest'],
config: _getConfig.tasks
});

_gulp2.default.task(task.name, function () {
if (!task.isValid()) {
return null;
}

return task.start().pipe((0, _gulpIf2.default)(_getConfig.isDev, (0, _gulpCached2.default)(task.cacheName, { optimizeMemory: false }))).pipe(task.end());
});
54 changes: 54 additions & 0 deletions workflows/dist/tasks/css-lint.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
'use strict';

var _gulp = require('gulp');

var _gulp2 = _interopRequireDefault(_gulp);

var _gulpCached = require('gulp-cached');

var _gulpCached2 = _interopRequireDefault(_gulpCached);

var _getConfig = require('../utils/get-config');

var _gulpIf = require('gulp-if');

var _gulpIf2 = _interopRequireDefault(_gulpIf);

var _gulpPostcss = require('gulp-postcss');

var _gulpPostcss2 = _interopRequireDefault(_gulpPostcss);

var _postcssReporter = require('postcss-reporter');

var _postcssReporter2 = _interopRequireDefault(_postcssReporter);

var _postcssScss = require('postcss-scss');

var _postcssScss2 = _interopRequireDefault(_postcssScss);

var _stylelint = require('stylelint');

var _stylelint2 = _interopRequireDefault(_stylelint);

var _TaskHelper = require('../utils/TaskHelper');

var _TaskHelper2 = _interopRequireDefault(_TaskHelper);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var task = new _TaskHelper2.default({
name: 'css-lint',
requiredPaths: ['src'],
config: _getConfig.tasks,
configSlug: 'css'
});

if (undefined !== task.config) {
_gulp2.default.task(task.name, function () {
if (!task.isValid()) {
return null;
}

return task.start().pipe((0, _gulpIf2.default)(_getConfig.isDev, (0, _gulpCached2.default)(task.cacheName))).pipe((0, _gulpPostcss2.default)([(0, _stylelint2.default)(), (0, _postcssReporter2.default)({ clearAllMessages: true })], { syntax: _postcssScss2.default }));
});
}
Loading