forked from mirror/_s
Merge pull request #1386 from Ismail-elkorchi/linting-travis
PHP, SCSS and JS linting tools for use in local and Travis
This commit is contained in:
commit
f5248e18ef
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"extends": [
|
||||||
|
"plugin:@wordpress/eslint-plugin/es5"
|
||||||
|
],
|
||||||
|
"env": {
|
||||||
|
"browser": true
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
/node_modules
|
||||||
|
/vendor
|
||||||
|
package-lock.json
|
||||||
|
composer.lock
|
7
.jscsrc
7
.jscsrc
|
@ -1,7 +0,0 @@
|
||||||
{
|
|
||||||
"preset": "wordpress",
|
|
||||||
"fileExtensions": [ ".js" ],
|
|
||||||
"excludeFiles": [
|
|
||||||
"js/**.min.js"
|
|
||||||
]
|
|
||||||
}
|
|
|
@ -1 +0,0 @@
|
||||||
js/**.min.js
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
{
|
||||||
|
"extends": [
|
||||||
|
"stylelint-config-wordpress/scss"
|
||||||
|
],
|
||||||
|
"ignoreFiles": [
|
||||||
|
"sass/_normalize.scss"
|
||||||
|
],
|
||||||
|
"rules": {
|
||||||
|
"font-family-no-missing-generic-family-keyword": null,
|
||||||
|
"no-descending-specificity": null,
|
||||||
|
"block-no-empty": null
|
||||||
|
}
|
||||||
|
}
|
121
.travis.yml
121
.travis.yml
|
@ -4,92 +4,67 @@
|
||||||
# For use with the Underscores WordPress theme.
|
# For use with the Underscores WordPress theme.
|
||||||
# @link https://github.com/Automattic/_s
|
# @link https://github.com/Automattic/_s
|
||||||
|
|
||||||
# Ditch sudo and use containers.
|
# Tell Travis CI which distro to use.
|
||||||
# @link https://docs.travis-ci.com/user/migrating-from-legacy/#Why-migrate-to-container-based-infrastructure%3F
|
|
||||||
# @link https://docs.travis-ci.com/user/workers/container-based-infrastructure/#Routing-your-build-to-container-based-infrastructure
|
|
||||||
sudo: false
|
|
||||||
dist: trusty
|
dist: trusty
|
||||||
|
|
||||||
# Declare project language.
|
# Cache directories between builds.
|
||||||
# @link https://about.travis-ci.org/docs/user/languages/php/
|
# @link https://docs.travis-ci.com/user/caching/#arbitrary-directories
|
||||||
language: php
|
cache:
|
||||||
|
directories:
|
||||||
|
# Cache directory for npm.
|
||||||
|
- $HOME/.npm
|
||||||
|
# Cache directory for older Composer versions.
|
||||||
|
- $HOME/.composer/cache/files
|
||||||
|
# Cache directory for more recent Composer versions.
|
||||||
|
- $HOME/.cache/composer/files
|
||||||
|
|
||||||
|
# Declare project language.
|
||||||
|
# @link https://docs.travis-ci.com/user/languages/php/
|
||||||
|
language:
|
||||||
|
- php
|
||||||
|
|
||||||
|
php:
|
||||||
|
- 5.6
|
||||||
|
- 7.0
|
||||||
|
- 7.1
|
||||||
|
- 7.2
|
||||||
|
- 7.3
|
||||||
|
|
||||||
# Declare versions of PHP to use. Use one decimal max.
|
|
||||||
# @link https://docs.travis-ci.com/user/build-configuration/
|
|
||||||
matrix:
|
matrix:
|
||||||
fast_finish: true
|
fast_finish: true
|
||||||
|
|
||||||
include:
|
include:
|
||||||
# Current $required_php_version for WordPress: 5.2.4
|
- php: 7.4
|
||||||
# aliased to 5.2.17
|
|
||||||
- php: '5.2'
|
|
||||||
dist: precise
|
|
||||||
# aliased to a recent 5.6.x version
|
|
||||||
- php: '5.6'
|
|
||||||
env: SNIFF=1
|
env: SNIFF=1
|
||||||
# aliased to a recent 7.0.x version
|
|
||||||
- php: '7.0'
|
|
||||||
# aliased to a recent 7.2.x version
|
|
||||||
- php: '7.2'
|
|
||||||
# bleeding edge PHP
|
|
||||||
- php: 'nightly'
|
|
||||||
|
|
||||||
allow_failures:
|
before_install:
|
||||||
- php: 'nightly'
|
|
||||||
|
|
||||||
# Use this to prepare the system to install prerequisites or dependencies.
|
|
||||||
# e.g. sudo apt-get update.
|
|
||||||
# Failures in this section will result in build status 'errored'.
|
|
||||||
# before_install:
|
|
||||||
|
|
||||||
# Use this to prepare your build for testing.
|
|
||||||
# e.g. copy database configurations, environment variables, etc.
|
|
||||||
# Failures in this section will result in build status 'errored'.
|
|
||||||
before_script:
|
|
||||||
# Speed up build time by disabling Xdebug.
|
# Speed up build time by disabling Xdebug.
|
||||||
- phpenv config-rm xdebug.ini || echo 'No xdebug config.'
|
- phpenv config-rm xdebug.ini || echo 'No xdebug config.'
|
||||||
# Set up temporary paths.
|
# Download and install the latest long-term support release of node.
|
||||||
- export PHPCS_DIR=/tmp/phpcs
|
- nvm install --lts
|
||||||
- export WPCS_DIR=/tmp/wpcs
|
# Install Composer dependencies.
|
||||||
- export PHPCOMPAT_DIR=/tmp/phpcompatibility
|
- composer install
|
||||||
# Install CodeSniffer for WordPress Coding Standards checks.
|
# Install NPM dependencies.
|
||||||
- if [[ "$SNIFF" == "1" ]]; then git clone -b master --depth 1 https://github.com/squizlabs/PHP_CodeSniffer.git $PHPCS_DIR; fi
|
- npm install
|
||||||
# Install WordPress Coding Standards.
|
|
||||||
- if [[ "$SNIFF" == "1" ]]; then git clone -b 0.14.1 --depth 1 https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git $WPCS_DIR; fi
|
|
||||||
# Install PHP Compatibility sniffs.
|
|
||||||
- if [[ "$SNIFF" == "1" ]]; then git clone -b master --depth 1 https://github.com/wimg/PHPCompatibility.git $PHPCOMPAT_DIR; fi
|
|
||||||
# Set install path for PHPCS sniffs.
|
|
||||||
# @link https://github.com/squizlabs/PHP_CodeSniffer/blob/4237c2fc98cc838730b76ee9cee316f99286a2a7/CodeSniffer.php#L1941
|
|
||||||
- if [[ "$SNIFF" == "1" ]]; then $PHPCS_DIR/bin/phpcs --config-set installed_paths $WPCS_DIR,$PHPCOMPAT_DIR; fi
|
|
||||||
# After CodeSniffer install you should refresh your path.
|
|
||||||
- if [[ "$SNIFF" == "1" ]]; then phpenv rehash; fi
|
|
||||||
# Install JSCS: JavaScript Code Style checker.
|
|
||||||
# @link http://jscs.info/
|
|
||||||
- if [[ "$SNIFF" == "1" ]]; then npm install -g jscs; fi
|
|
||||||
# Install JSHint, a JavaScript Code Quality Tool.
|
|
||||||
# @link http://jshint.com/docs/
|
|
||||||
- if [[ "$SNIFF" == "1" ]]; then npm install -g jshint; fi
|
|
||||||
# Pull in the WP Core jshint rules.
|
|
||||||
- if [[ "$SNIFF" == "1" ]]; then wget https://develop.svn.wordpress.org/trunk/.jshintrc; fi
|
|
||||||
|
|
||||||
# Run test script commands.
|
|
||||||
# Default is specific to project language.
|
|
||||||
# All commands must exit with code 0 on success. Anything else is considered failure.
|
|
||||||
script:
|
script:
|
||||||
# Search for PHP syntax errors.
|
# Validate the composer.json file.
|
||||||
- find -L . -name '*.php' -print0 | xargs -0 -n 1 -P 4 php -l
|
# @link https://getcomposer.org/doc/03-cli.md#validate
|
||||||
# Run the theme through JSHint.
|
- composer validate --no-check-all --strict
|
||||||
- if [[ "$SNIFF" == "1" ]]; then jshint .; fi
|
|
||||||
# Run the theme through JavaScript Code Style checker.
|
# Search for PHP syntax errors using PHP Parallel Lint.
|
||||||
- if [[ "$SNIFF" == "1" ]]; then jscs .; fi
|
# @link https://github.com/php-parallel-lint/PHP-Parallel-Lint
|
||||||
# WordPress Coding Standards.
|
- composer lint:php
|
||||||
# @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards
|
|
||||||
# @link https://pear.php.net/package/PHP_CodeSniffer/
|
# Check the PHP files with the coding standards documented in the phpcs.xml.dist file.
|
||||||
# Uses a custom ruleset based on WordPress. This ruleset is automatically
|
- if [[ "$SNIFF" == 1 ]]; then composer lint:wpcs; fi
|
||||||
# picked up by PHPCS as it's named `phpcs.xml(.dist)`.
|
|
||||||
- if [[ "$SNIFF" == "1" ]]; then $PHPCS_DIR/bin/phpcs --runtime-set ignore_warnings_on_exit 1; fi
|
# Check the JS files with the lint-js script defined in the @wordpress/scripts package.
|
||||||
|
- if [[ "$SNIFF" == 1 ]]; then npm run lint:js; fi
|
||||||
|
|
||||||
|
# Check the SCSS files with the lint-style script defined in the @wordpress/scripts package.
|
||||||
|
- if [[ "$SNIFF" == 1 ]]; then npm run lint:scss; fi
|
||||||
|
|
||||||
# Receive notifications for build results.
|
# Receive notifications for build results.
|
||||||
# @link https://docs.travis-ci.com/user/notifications/#Email-notifications
|
# @link https://docs.travis-ci.com/user/notifications/#configuring-email-notifications
|
||||||
notifications:
|
notifications:
|
||||||
email: false
|
email: false
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
{
|
||||||
|
"name": "automattic/underscores",
|
||||||
|
"type": "wordpress-theme",
|
||||||
|
"description": "Hi. I'm a starter theme called _s, or underscores, if you like. I'm a theme meant for hacking so don't use me as a Parent Theme. Instead try turning me into the next, most awesome, WordPress theme out there. That's what I'm here for.",
|
||||||
|
"keywords": [
|
||||||
|
"WordPress",
|
||||||
|
"Themes"
|
||||||
|
],
|
||||||
|
"homepage": "https://github.com/Automattic/_s",
|
||||||
|
"license": "GPL-2.0-or-later",
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Contributors",
|
||||||
|
"homepage": "https://github.com/Automattic/_s/graphs/contributors"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"require": {
|
||||||
|
"php": ">=5.6"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"dealerdirect/phpcodesniffer-composer-installer": "^0.6.2",
|
||||||
|
"wptrt/wpthemereview": "^0.2.1",
|
||||||
|
"php-parallel-lint/php-parallel-lint": "^1.2.0"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"lint:wpcs": "@php ./vendor/squizlabs/php_codesniffer/bin/phpcs --runtime-set testVersion 5.6-",
|
||||||
|
"lint:php": "@php ./vendor/bin/parallel-lint --exclude .git --exclude vendor ."
|
||||||
|
},
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/Automattic/_s/issues",
|
||||||
|
"source": "https://github.com/Automattic/_s"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
{
|
||||||
|
"name": "underscores",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "Hi. I'm a starter theme called _s, or underscores, if you like. I'm a theme meant for hacking so don't use me as a Parent Theme. Instead try turning me into the next, most awesome, WordPress theme out there. That's what I'm here for.",
|
||||||
|
"author": "Automattic Theme Team",
|
||||||
|
"license": "GPL-2.0-or-later",
|
||||||
|
"keywords": [
|
||||||
|
"WordPress",
|
||||||
|
"Theme"
|
||||||
|
],
|
||||||
|
"homepage": "https://github.com/Automattic/_s#readme",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/Automattic/_s.git"
|
||||||
|
},
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/Automattic/_s/issues"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@wordpress/scripts": "^7.2.0"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"lint:scss": "wp-scripts lint-style 'sass/**/*.scss'",
|
||||||
|
"lint:js": "wp-scripts lint-js 'js/*.js'"
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,9 +1,9 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<ruleset name="WordPress Theme Coding Standards">
|
<ruleset name="WordPress Theme Coding Standards">
|
||||||
<!-- See https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml -->
|
<!-- See https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml -->
|
||||||
<!-- See https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards -->
|
<!-- See https://github.com/WordPress/WordPress-Coding-Standards -->
|
||||||
<!-- See https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki -->
|
<!-- See https://github.com/WPTRT/WPThemeReview -->
|
||||||
<!-- See https://github.com/wimg/PHPCompatibility -->
|
<!-- See https://github.com/PHPCompatibility/PHPCompatibilityWP -->
|
||||||
|
|
||||||
<!-- Set a description for this ruleset. -->
|
<!-- Set a description for this ruleset. -->
|
||||||
<description>A custom set of code standard rules to check for WordPress themes.</description>
|
<description>A custom set of code standard rules to check for WordPress themes.</description>
|
||||||
|
@ -28,21 +28,28 @@
|
||||||
<!-- Check up to 8 files simultanously. -->
|
<!-- Check up to 8 files simultanously. -->
|
||||||
<arg name="parallel" value="8"/>
|
<arg name="parallel" value="8"/>
|
||||||
|
|
||||||
<!-- Only check the PHP, CSS and SCSS files. JS files are checked separately with JSCS and JSHint. -->
|
<!-- Only check the PHP files. JS, and CSS files are checked separately with @wordpress/scripts package. -->
|
||||||
<arg name="extensions" value="php,css,scss/css"/>
|
<arg name="extensions" value="php"/>
|
||||||
|
|
||||||
<!-- Check all files in this directory and the directories below it. -->
|
<!-- Check all files in this directory and the directories below it. -->
|
||||||
<file>.</file>
|
<file>.</file>
|
||||||
|
|
||||||
|
<!-- Exclude patterns. -->
|
||||||
|
<exclude-pattern>/vendor/*</exclude-pattern>
|
||||||
|
<exclude-pattern>/node_modules/*</exclude-pattern>
|
||||||
|
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
#############################################################################
|
#############################################################################
|
||||||
USE THE WordPress RULESET
|
USE THE WordPress AND THE Theme Review RULESET
|
||||||
#############################################################################
|
#############################################################################
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<rule ref="WordPress"/>
|
<rule ref="WordPress">
|
||||||
|
<!-- This rule does not apply here since the _s prefix should be changed by the theme author. -->
|
||||||
|
<exclude name="WordPress.NamingConventions.PrefixAllGlobals.ShortPrefixPassed"/>
|
||||||
|
</rule>
|
||||||
|
<rule ref="WPThemeReview"/>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
@ -97,36 +104,7 @@
|
||||||
#############################################################################
|
#############################################################################
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
<config name="testVersion" value="5.6-"/>
|
||||||
<config name="testVersion" value="5.2-99.0"/>
|
<rule ref="PHPCompatibilityWP"/>
|
||||||
<rule ref="PHPCompatibility">
|
|
||||||
<!-- Whitelist PHP native classes, interfaces, functions and constants which
|
|
||||||
are back-filled by WP.
|
|
||||||
|
|
||||||
Based on:
|
|
||||||
* /wp-includes/compat.php
|
|
||||||
* /wp-includes/random_compat/random.php
|
|
||||||
-->
|
|
||||||
<exclude name="PHPCompatibility.PHP.NewClasses.errorFound"/>
|
|
||||||
<exclude name="PHPCompatibility.PHP.NewClasses.typeerrorFound"/>
|
|
||||||
|
|
||||||
<exclude name="PHPCompatibility.PHP.NewConstants.json_pretty_printFound"/>
|
|
||||||
<exclude name="PHPCompatibility.PHP.NewConstants.php_version_idFound"/>
|
|
||||||
|
|
||||||
<exclude name="PHPCompatibility.PHP.NewFunctions.hash_equalsFound"/>
|
|
||||||
<exclude name="PHPCompatibility.PHP.NewFunctions.json_last_error_msgFound"/>
|
|
||||||
<exclude name="PHPCompatibility.PHP.NewFunctions.random_intFound"/>
|
|
||||||
<exclude name="PHPCompatibility.PHP.NewFunctions.random_bytesFound"/>
|
|
||||||
<exclude name="PHPCompatibility.PHP.NewFunctions.array_replace_recursiveFound"/>
|
|
||||||
|
|
||||||
<exclude name="PHPCompatibility.PHP.NewInterfaces.jsonserializableFound"/>
|
|
||||||
</rule>
|
|
||||||
|
|
||||||
<!-- Whitelist the WP Core mysql_to_rfc3339() function. -->
|
|
||||||
<rule ref="PHPCompatibility.PHP.RemovedExtensions">
|
|
||||||
<properties>
|
|
||||||
<property name="functionWhitelist" type="array" value="mysql_to_rfc3339"/>
|
|
||||||
</properties>
|
|
||||||
</rule>
|
|
||||||
|
|
||||||
</ruleset>
|
</ruleset>
|
||||||
|
|
Reference in New Issue