Skip to content

Commit

Permalink
feat: Add stylelint-disable snippets (#37)
Browse files Browse the repository at this point in the history
feat: Add `stylelint-disable` snippets
  • Loading branch information
ntwb committed Jan 6, 2020
2 parents 23c7008 + 565b92e commit 0fd9975
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 1 deletion.
17 changes: 16 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"theme": "dark"
},
"categories": [
"Linters"
"Linters",
"Snippets"
],
"keywords": [
"css",
Expand Down Expand Up @@ -117,6 +118,20 @@
".stylelintignore"
]
}
],
"snippets": [
{
"language": "css",
"path": "./snippets/stylelint-disable.json"
},
{
"language": "postcss",
"path": "./snippets/stylelint-disable.json"
},
{
"language": "scss",
"path": "./snippets/stylelint-disable.json"
}
]
},
"dependencies": {
Expand Down
17 changes: 17 additions & 0 deletions snippets/stylelint-disable.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"stylelint-disable": {
"prefix": "stylelint-disable",
"body": ["/* stylelint-disable ${1:rule} */", "$0/* stylelint-enable ${1:rule} */"],
"description": "Turn off all stylelint or individual rules, after which you do not need to re-enable stylelint."
},
"stylelint-disable-line": {
"prefix": "stylelint-disable-line",
"body": ["/* stylelint-disable-line ${0:rule} */"],
"description": "Turn off stylelint rules for individual lines only, after which you do not need to explicitly re-enable them."
},
"stylelint-disable-next-line": {
"prefix": "stylelint-disable-next-line",
"body": ["/* stylelint-disable-next-line ${0:rule} */"],
"description": "Turn off stylelint rules for the next line only, after which you do not need to explicitly re-enable them."
}
}
49 changes: 49 additions & 0 deletions snippets/stylelint-disable.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
'use strict';

const snippets = require('./stylelint-disable.json');

const unique = (xs) => [...new Set(xs)];

describe('Snippets', () => {
const keys = Object.keys(snippets);

it('should not be empty', () => {
expect(keys.length).toBeGreaterThan(0);
});

it('is sorted by key', () => {
const sortedKeys = [...keys].sort();

expect(keys).toEqual(sortedKeys);
});

it('has unique prefixes', () => {
const prefixes = Object.values(snippets).map((x) => x.prefix);

expect(prefixes).toEqual(unique(prefixes));
});

describe.each(keys)('%s', (key) => {
it('should have a prefix', () => {
const { prefix } = snippets[key];

expect(prefix).toBeDefined();
expect(prefix.length).toBeGreaterThan(0);
expect(prefix.startsWith('stylelint-disable')).toBe(true);
});

it('should have a body', () => {
const { body } = snippets[key];

expect(body).toBeDefined();
expect(body.length).toBeGreaterThan(0);
});

it('should have a description', () => {
const { description } = snippets[key];

expect(description).toBeDefined();
expect(description.length).toBeGreaterThan(0);
});
});
});

0 comments on commit 0fd9975

Please sign in to comment.