Skip to content

Commit

Permalink
fix: Add initial support for long comments in headers of WordPress th…
Browse files Browse the repository at this point in the history
…eme `style.css` files. (#151)

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.
  • Loading branch information
ntwb committed May 31, 2020
1 parent e96ee67 commit 5c671cd
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/stylelint-config-wordpress/__tests__/themes-valid.css
Original file line number Diff line number Diff line change
@@ -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;
}
29 changes: 29 additions & 0 deletions packages/stylelint-config-wordpress/__tests__/themes.js
Original file line number Diff line number Diff line change
@@ -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 )
) );
});
});
1 change: 1 addition & 0 deletions packages/stylelint-config-wordpress/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 5c671cd

Please sign in to comment.