diff --git a/.jscsrc b/.jscsrc index 6425f203..9a7bbb01 100644 --- a/.jscsrc +++ b/.jscsrc @@ -2,6 +2,6 @@ "preset": "wordpress", "fileExtensions": [ ".js" ], "excludeFiles": [ - "js/skip-link-focus-fix.js" + "js/**.min.js" ] } \ No newline at end of file diff --git a/.jshintignore b/.jshintignore index 92af1049..54162f6f 100644 --- a/.jshintignore +++ b/.jshintignore @@ -1,2 +1 @@ -js/skip-link-focus-fix.js -**.min.js \ No newline at end of file +js/**.min.js \ No newline at end of file diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index 012652e9..00000000 --- a/.jshintrc +++ /dev/null @@ -1,26 +0,0 @@ -{ - "boss": true, - "curly": true, - "eqeqeq": true, - "eqnull": true, - "es3": true, - "expr": true, - "immed": true, - "noarg": true, - "nonbsp": true, - "onevar": true, - "quotmark": "single", - "trailing": true, - "undef": true, - "unused": true, - - "browser": true, - - "globals": { - "_": false, - "Backbone": false, - "jQuery": false, - "JSON": false, - "wp": false - } -} diff --git a/.travis.yml b/.travis.yml index b0e38c28..4499a99d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,15 +22,9 @@ matrix: # Current $required_php_version for WordPress: 5.2.4 # aliased to 5.2.17 - php: '5.2' - # aliased to 5.3.29 - - php: '5.3' - # aliased to a recent 5.4.x version - - php: '5.4' - # aliased to a recent 5.5.x version - - php: '5.5' - env: SNIFF=1 # aliased to a recent 5.6.x version - php: '5.6' + env: SNIFF=1 # aliased to a recent 7.x version - php: '7.0' # aliased to a recent hhvm version @@ -49,22 +43,26 @@ matrix: # Failures in this section will result in build status 'errored'. before_script: - export PHPCS_DIR=/tmp/phpcs - - export WPCS_DIR=/tmp/wpcs + - export SNIFFS_DIR=/tmp/sniffs # Install CodeSniffer for WordPress Coding Standards checks. - if [[ "$SNIFF" == "1" ]]; then git clone -b master --depth 1 https://github.com/squizlabs/PHP_CodeSniffer.git $PHPCS_DIR; fi # Install WordPress Coding Standards. - - if [[ "$SNIFF" == "1" ]]; then git clone -b master --depth 1 https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git $WPCS_DIR; fi - # Set install path for WordPress Coding Standards. + - if [[ "$SNIFF" == "1" ]]; then git clone -b master --depth 1 https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git $SNIFFS_DIR; fi + # Install PHP Compatibility sniffs. + - if [[ "$SNIFF" == "1" ]]; then git clone -b master --depth 1 https://github.com/wimg/PHPCompatibility.git $SNIFFS_DIR/PHPCompatibility; 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/scripts/phpcs --config-set installed_paths $WPCS_DIR; fi + - if [[ "$SNIFF" == "1" ]]; then $PHPCS_DIR/scripts/phpcs --config-set installed_paths $SNIFFS_DIR; fi # After CodeSniffer install you should refresh your path. - if [[ "$SNIFF" == "1" ]]; then phpenv rehash; fi - # Install JSCS: JavaScript Code Style checker + # 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 + # 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. + - wget https://develop.svn.wordpress.org/trunk/.jshintrc # Run test script commands. # Default is specific to project language. diff --git a/codesniffer.ruleset.xml b/codesniffer.ruleset.xml index b313a022..f16b3114 100644 --- a/codesniffer.ruleset.xml +++ b/codesniffer.ruleset.xml @@ -12,4 +12,7 @@ - \ No newline at end of file + + + + diff --git a/js/skip-link-focus-fix.js b/js/skip-link-focus-fix.js index 44df0c4b..a39cefbf 100644 --- a/js/skip-link-focus-fix.js +++ b/js/skip-link-focus-fix.js @@ -1,16 +1,16 @@ /** - * skip-link-focus-fix.js + * File skip-link-focus-fix.js. * * Helps with accessibility for keyboard only users. * * Learn more: https://git.io/vWdr2 */ ( function() { - var is_webkit = navigator.userAgent.toLowerCase().indexOf( 'webkit' ) > -1, - is_opera = navigator.userAgent.toLowerCase().indexOf( 'opera' ) > -1, - is_ie = navigator.userAgent.toLowerCase().indexOf( 'msie' ) > -1; + var isWebkit = navigator.userAgent.toLowerCase().indexOf( 'webkit' ) > -1, + isOpera = navigator.userAgent.toLowerCase().indexOf( 'opera' ) > -1, + isIe = navigator.userAgent.toLowerCase().indexOf( 'msie' ) > -1; - if ( ( is_webkit || is_opera || is_ie ) && document.getElementById && window.addEventListener ) { + if ( ( isWebkit || isOpera || isIe ) && document.getElementById && window.addEventListener ) { window.addEventListener( 'hashchange', function() { var id = location.hash.substring( 1 ), element;