From 5c671cdbfad6b9f9bac3003d787f649d931bd4ed Mon Sep 17 00:00:00 2001 From: Stephen Edgar Date: Mon, 17 Jul 2017 01:13:31 +1000 Subject: [PATCH] fix: Add initial support for long comments in headers of WordPress theme `style.css` files. (#151) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change allows for longer comments in themes header: • URLs longer than 80 characters • Descriptions longer than 80 characters • Tags longer than 80 characters Fixes #150. --- .../__tests__/themes-valid.css | 16 ++++++++++ .../__tests__/themes.js | 29 +++++++++++++++++++ packages/stylelint-config-wordpress/index.js | 1 + 3 files changed, 46 insertions(+) create mode 100644 packages/stylelint-config-wordpress/__tests__/themes-valid.css create mode 100644 packages/stylelint-config-wordpress/__tests__/themes.js diff --git a/packages/stylelint-config-wordpress/__tests__/themes-valid.css b/packages/stylelint-config-wordpress/__tests__/themes-valid.css new file mode 100644 index 00000000000000..de9a2fb8193a6c --- /dev/null +++ b/packages/stylelint-config-wordpress/__tests__/themes-valid.css @@ -0,0 +1,16 @@ +/* +Theme Name: Twenty Ten +Theme URI: https://wordpress.org/themes/twentyten/themes/twentyten/themes/twentyten/themes/twentyten/ +Description: The 2010 theme for WordPress is stylish, customizable, simple, and readable -- make it yours with a custom menu, header image, and background. Twenty Ten supports six widgetized areas (two in the sidebar, four in the footer) and featured images (thumbnails for gallery posts and custom header images for posts and pages). It includes stylesheets for print and the admin Visual Editor, special styles for posts in the "Asides" and "Gallery" categories, and has an optional one-column page template that removes the sidebar. +Author: the WordPress team +Author URI: https://wordpress.org/ +Version: 2.3 +License: GNU General Public License v2 or later +License URI: http://www.gnu.org/licenses/gpl-2.0.html +Tags: blog, two-columns, custom-header, custom-background, threaded-comments, sticky-post, translation-ready, microformats, rtl-language-support, editor-style, custom-menu, flexible-header, featured-images, footer-widgets, featured-image-header +Text Domain: twentyten +*/ + +a { + top: 0.2em; +} diff --git a/packages/stylelint-config-wordpress/__tests__/themes.js b/packages/stylelint-config-wordpress/__tests__/themes.js new file mode 100644 index 00000000000000..3582a5848b02da --- /dev/null +++ b/packages/stylelint-config-wordpress/__tests__/themes.js @@ -0,0 +1,29 @@ +'use strict'; + +const fs = require( 'fs' ), + config = require( '../' ), + stylelint = require( 'stylelint' ), + validCss = fs.readFileSync( './__tests__/themes-valid.css', 'utf-8' ); + +describe( 'flags no warnings with valid css', () => { + let result; + + beforeEach( () => { + result = stylelint.lint({ + code: validCss, + config, + }); + }); + + it( 'did not error', () => { + return result.then( data => ( + expect( data.errored ).toBeFalsy() + ) ); + }); + + it( 'flags no warnings', () => { + return result.then( data => ( + expect( data.results[0].warnings.length ).toBe( 0 ) + ) ); + }); +}); diff --git a/packages/stylelint-config-wordpress/index.js b/packages/stylelint-config-wordpress/index.js index 66edb5d6544cd5..de01f01ddcc70a 100644 --- a/packages/stylelint-config-wordpress/index.js +++ b/packages/stylelint-config-wordpress/index.js @@ -57,6 +57,7 @@ module.exports = { 'max-empty-lines': 2, 'max-line-length': [ 80, { ignore: 'non-comments', + ignorePattern: ['/(https?://[0-9,a-z]*.*)|(^description\\:.+)|(^tags\\:.+)/i'], } ], 'media-feature-colon-space-after': 'always', 'media-feature-colon-space-before': 'never',