From 836190acc045fb729cf525e46a0bc3da4c471fdf Mon Sep 17 00:00:00 2001 From: Stuart Jones Date: Sun, 25 Oct 2020 17:17:08 +1030 Subject: [PATCH] fix lint errors --- README.md | 2 +- package.json | 2 +- src/util/extractGridLineNames.js | 11 +++++++---- test/util/extractGridLineNames.test.js | 16 +++++++++++++--- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index d35516e..d57f109 100644 --- a/README.md +++ b/README.md @@ -142,7 +142,7 @@ Additionally, the plugin will create properly indexed utilities for line names d module.exports = { theme: { gridTemplateColumns: { - 'default-layout': 'repeat(3, [left] 1fr [right]', + 'default-layout': 'repeat(3, [left] 1fr [right])', } } } diff --git a/package.json b/package.json index 9ece28a..d5751b5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@savvywombat/tailwindcss-grid-named-lines", - "version": "1.2.0", + "version": "1.2.1", "description": "A plugin to provide TailwindCSS utilities for named grid lines.", "keywords": [ "tailwind", diff --git a/src/util/extractGridLineNames.js b/src/util/extractGridLineNames.js index 98de5ce..ae7438b 100644 --- a/src/util/extractGridLineNames.js +++ b/src/util/extractGridLineNames.js @@ -14,13 +14,15 @@ module.exports = function (gridTemplate) { }), // extract repeat(n, def) ..._.flatMap(value.match(/repeat\([^\)]*\)/g), (repeat) => { - const found = repeat.match(/\((?[0-9]+),\s*(\[(?[^\]]+)\])?[^\[]+(\[(?[^\]]+)\])?/) + const found = repeat.match( + /\((?[0-9]+),\s*(\[(?[^\]]+)\])?[^\[]+(\[(?[^\]]+)\])?/ + ) if (typeof found.groups.count === 'undefined') { return [] } - let result = []; + let result = [] // start at 1 here reduce the number of repeated names by one // because the first match above will include the names from repeat(n, def) for (let i = 1; i < found.groups.count; i++) { @@ -33,10 +35,11 @@ module.exports = function (gridTemplate) { } return result - }) + }), ] // create a unique list of names, including counts of how many times that name is used - const counts = _.fromPairs(matches + const counts = _.fromPairs( + matches .filter((v, i, a) => a.indexOf(v) === i) .map((match) => { return [ diff --git a/test/util/extractGridLineNames.test.js b/test/util/extractGridLineNames.test.js index 14707eb..5840c98 100644 --- a/test/util/extractGridLineNames.test.js +++ b/test/util/extractGridLineNames.test.js @@ -52,7 +52,13 @@ test('multiple gridTemplates can use the same grid line names', () => { four: '[column] 1fr [column] 1fr [column]', } - expect(extractGridLineNames(gridTemplateRows)).toEqual(['left', 'right', 'column 1', 'column 2', 'column 3']) + expect(extractGridLineNames(gridTemplateRows)).toEqual([ + 'left', + 'right', + 'column 1', + 'column 2', + 'column 3', + ]) }) test('supports repeat', () => { @@ -76,7 +82,9 @@ test('includes start and end from repeat', () => { layout: 'repeat(2, [instart] 1fr [inend])', } - expect(extractGridLineNames(gridTemplateRows)).toEqual(expect.arrayContaining(['instart 1', 'instart 2', 'inend 1', 'inend 2'])) + expect(extractGridLineNames(gridTemplateRows)).toEqual( + expect.arrayContaining(['instart 1', 'instart 2', 'inend 1', 'inend 2']) + ) }) test('supports multiple repeats', () => { @@ -84,5 +92,7 @@ test('supports multiple repeats', () => { layout: 'repeat(2, [line] 1fr) repeat(2, [more] 2fr)', } - expect(extractGridLineNames(gridTemplateRows)).toEqual(expect.arrayContaining(['line 1', 'line 2', 'more 1', 'more 2'])) + expect(extractGridLineNames(gridTemplateRows)).toEqual( + expect.arrayContaining(['line 1', 'line 2', 'more 1', 'more 2']) + ) })