This repository has been archived by the owner on Apr 22, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 3e3f7b7
Showing
5 changed files
with
126 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.DS_Store | ||
.idea | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"extends": "stylelint-config-standard", | ||
"rules": { | ||
"value-no-vendor-prefix": true, | ||
"property-no-vendor-prefix": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
Quicklint Stylelint | ||
====== | ||
A CLI wrapping a simple stylelint config based on [stylelint-config-standard](https://github.com/stylelint/stylelint-config-standard). | ||
|
||
The rules/options that differ from the standard: | ||
- [value-no-vendor-prefix](https://stylelint.io/user-guide/rules/value-no-vendor-prefix/) set to `true` as [autoprefixer](https://github.com/postcss/autoprefixer) should be used | ||
- [property-no-vendor-prefix](https://stylelint.io/user-guide/rules/property-no-vendor-prefix/) set to `true` as [autoprefixer](https://github.com/postcss/autoprefixer) should be used | ||
|
||
|
||
Installation | ||
------ | ||
Add the package as a dev dependency: | ||
```bash | ||
npm i -D github:cbodin/quicklint-stylelint#v1.0.0 | ||
``` | ||
|
||
|
||
Usage | ||
------ | ||
The default behavior is to lint all the `.pcss` and `.css` files in the `src/` folder. | ||
If any other folders should be used, the search paths can be specified with the `--paths` argument. | ||
|
||
To include both the default `src/` folder and a `server/` folder, both paths will need to be supplied: | ||
```bash | ||
quicklint-stylelint --paths src/,server/ | ||
``` | ||
|
||
Run `npx quicklint-stylelint -h` for a list of all options. | ||
|
||
A common scenario is to include a test script in your `package.json` file: | ||
```json | ||
{ | ||
"scripts": { | ||
"test": "quicklint-stylelint" | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/usr/bin/env node | ||
|
||
(function () { | ||
const path = require('path'); | ||
const stylelint = require('stylelint'); | ||
const stylelintFormatterPretty = require('stylelint-formatter-pretty'); | ||
const { ArgumentParser } = require('argparse'); | ||
|
||
// Load package config | ||
const packageConfig = path.resolve(__dirname, '../package.json'); | ||
const packageInfo = require(packageConfig); | ||
|
||
// Configure arguments | ||
const parser = new ArgumentParser({ | ||
version: packageInfo.version, | ||
description: packageInfo.description, | ||
}); | ||
parser.addArgument(['--paths'], { | ||
help: 'Define search paths, comma separated. Default "src/"', | ||
defaultValue: 'src/', | ||
}); | ||
|
||
// Check arguments | ||
const args = parser.parseArgs(); | ||
|
||
// Create file globs of all paths | ||
const globs = []; | ||
const extensions = ['.pcss', '.css']; | ||
|
||
for (const extension of extensions) { | ||
for (const folderPath of args.paths.split(',')) { | ||
const folder = path.resolve(process.cwd(), folderPath); | ||
globs.push(path.resolve(folder, `*${extension}`)); | ||
globs.push(path.resolve(folder, '**', `*${extension}`)); | ||
} | ||
} | ||
|
||
console.log(`\x1b[34m ➜ Running Stylelint.\x1b[0m`); | ||
|
||
// Load stylelint config | ||
const configPath = path.resolve(__dirname, '../.stylelintrc.json'); | ||
const baseConfig = require(configPath); | ||
|
||
// Lint | ||
stylelint.lint({ | ||
config: baseConfig, | ||
files: globs, | ||
formatter: stylelintFormatterPretty, | ||
}).then((data) => { | ||
if (data.errored) { | ||
console.log(data.output); | ||
process.exit(1); | ||
} | ||
|
||
console.log(`\x1b[32m ✔ No Stylelint errors.\x1b[0m`); | ||
}); | ||
}()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "@cbodin/quicklint-stylelint", | ||
"version": "1.0.0", | ||
"description": "Pre-configured Stylelint using stylelint-config-standard as a base, packaged in a simple CLI", | ||
"author": "Christofer Bodin <[email protected]>", | ||
"license": "MIT", | ||
"private": true, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/cbodin/quicklint-stylelint.git" | ||
}, | ||
"main": "./bin/cli.js", | ||
"bin": { | ||
"quicklint-stylelint": "./bin/cli.js" | ||
}, | ||
"dependencies": { | ||
"argparse": "^1.0.10", | ||
"stylelint": "^9.10.1", | ||
"stylelint-config-standard": "^18.2.0", | ||
"stylelint-formatter-pretty": "^1.0.3" | ||
} | ||
} |