Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare new version #14

Merged
merged 7 commits into from
Feb 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .babelrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*!
* Gulp Stylelint (v2.0.0): .babelrc.cjs
* Copyright (c) 2023-24 Adorade (https://github.com/adorade/gulp-stylelint-esm)
* License under MIT
* ========================================================================== */

module.exports = {
presets: [
["@babel/preset-env", { targets: { node: "current" } }]
]
};
52 changes: 34 additions & 18 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,21 +1,37 @@
/*!
* Gulp Stylelint (v2.0.0): .eslintrc.cjs
* Copyright (c) 2023-24 Adorade (https://github.com/adorade/gulp-stylelint-esm)
* License under MIT
* ========================================================================== */

module.exports = {
parser: "@babel/eslint-parser",
env: {
browser: true,
node: true,
es6: true
},
extends: 'stylelint',
globals: {
module: true
},
parserOptions: {
ecmaVersion: 2017,
requireConfigFile: false,
sourceType: 'module',
},
rules: {
'prefer-object-spread': 'off',
'n/prefer-global/process': ['error', 'always']
parser: "@babel/eslint-parser",
env: {
browser: true,
node: true,
es6: true
},
extends: 'stylelint',
globals: {
module: true
},
parserOptions: {
ecmaVersion: 2017,
requireConfigFile: false,
sourceType: 'module',
},
rules: {
'prefer-object-spread': 'off',
'n/prefer-global/process': ['error', 'always']
},
overrides: [
{
files: [
"test/*.test.js"
],
env: {
jest: true
}
}
]
}
2 changes: 1 addition & 1 deletion .github/renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"labels": ["lint"]
},
{
"matchPackagePatterns": ["^sinon|^tape"],
"matchPackagePatterns": ["^jest|^sinon"],
"groupName": "test packages",
"labels": ["test"]
},
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
node: [16, 18, 20]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
node: [20]

runs-on: ${{ matrix.os }}

Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# https://git-scm.com/docs/gitignore
# Folders to ignore
node_modules
.nvmrc
archive

# To do Tasks
.todo
Expand All @@ -15,6 +15,7 @@ logs

# Temporary files
tmp
.coverage

# OS or Editor folders
._*
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 Adorade
Copyright (c) 2023-24 Adorade

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
37 changes: 22 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Gulp Stylelint

[![NPM version](http://img.shields.io/npm/v/gulp-stylelint-esm?logo=npm)](https://www.npmjs.org/package/gulp-stylelint-esm)
[![NPM version](https://img.shields.io/npm/v/gulp-stylelint-esm?logo=npm)](https://www.npmjs.org/package/gulp-stylelint-esm)
[![GitHub package.json version](https://img.shields.io/github/package-json/v/adorade/gulp-stylelint-esm?color=green&logo=github)](https://github.com/adorade/gulp-stylelint-esm/blob/main/package.json)
[![license](https://img.shields.io/github/license/adorade/gulp-stylelint-esm)](https://mit-license.org)
[![Depfu Status](https://img.shields.io/depfu/dependencies/github/adorade/gulp-stylelint-esm)](https://depfu.com/repos/github/adorade/gulp-stylelint-esm)
Expand All @@ -9,10 +9,12 @@

This package is pure ESM. Please [read this](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c).

A [Gulp](http://gulpjs.com/) plugin that runs [stylelint](https://github.com/stylelint/stylelint) results through a list of reporters.
A [Gulp](https://gulpjs.com/) plugin that runs [stylelint](https://github.com/stylelint/stylelint) results through a list of reporters with ESM support.

## Installation

> **REQUIREMENTS**: Supports **stylelint > 16** and **node >= 18.12.0**.

```sh
# YARN
yarn add stylelint gulp-stylelint-esm -D
Expand All @@ -22,7 +24,7 @@ npm install stylelint gulp-stylelint-esm --save-dev

## Quick start

Once you have [configured stylelint](http://stylelint.io/user-guide/configuration/) (e.g. you have a _.stylelintrc_ file), start with the following code. You will find additional configuration [options](#options) below.
Once you have [configured stylelint](https://stylelint.io/user-guide/configuration/) (e.g. you have a _.stylelintrc_ file), start with the following code. You will find additional configuration [options](#options) below.

```js
import gulp from 'gulp';
Expand All @@ -33,23 +35,27 @@ function lintCssTask() {
.src('src/**/*.css')
.pipe(gStylelintEsm({
reporters: [
{formatter: 'string', console: true}
{ formatter: 'string', console: true }
]
}));
}
```

## Formatters

Below is the list of currently available stylelint formatters. Some of them are bundled with stylelint by default and exposed on `gStylelintEsm.formatters` object. Others need to be installed. You can [write a custom formatter](http://stylelint.io/developer-guide/formatters/) to tailor the reporting to your needs.
Below is the list of currently available **stylelint formatters**. Some of them are bundled with stylelint by default and exposed on `gStylelintEsm.formatters` object. Others need to be installed. You can [write a custom formatter](http://stylelint.io/developer-guide/formatters/) to tailor the reporting to your needs.

- `"string"` (same as `gStylelintEsm.formatters.string`) – bundled with stylelint
- `"verbose"` (same as `gStylelintEsm.formatters.verbose`) – bundled with stylelint
- `"json"` (same as `gStylelintEsm.formatters.json`) – bundled with stylelint
Formatters bundled with stylelint: `"compact"`, `"github"`, `"json"`, `"string (default)"`, `"tap"`, `"unix"`, `"verbose"`.

## Options

**gulp-stylelint-esm** supports all [stylelint options](http://stylelint.io/user-guide/node-api/#options) except [`files`](http://stylelint.io/user-guide/node-api/#files) and [`formatter`](http://stylelint.io/user-guide/node-api/#formatter) and accepts a custom set of options listed below:
**gulp-stylelint-esm** supports all [stylelint](https://stylelint.io/user-guide/options) and [Node.js API](https://stylelint.io/user-guide/node-api#options) options except:

- [`files`](http://stylelint.io/user-guide/node-api/#files), code will be provided by gulp instead
- [`formatter`](https://stylelint.io/user-guide/options#formatter), formatters are defined in the `reporters` option
- [`cache`](https://stylelint.io/user-guide/options#cache), gulp caching should be used instead

and accepts a **custom set of options** listed below:

```js
import gulp from 'gulp';
Expand All @@ -63,9 +69,9 @@ function lintCssTask() {
failAfterError: true,
reportOutputDir: 'reports/lint',
reporters: [
{formatter: 'verbose', console: true},
{formatter: 'json', save: 'report.json'},
{formatter: myStylelintFormatter, save: 'my-custom-report.txt'}
{ formatter: 'verbose', console: true },
{ formatter: 'json', save: 'report.json' },
{ formatter: myStylelintFormatter, save: 'my-custom-report.txt' }
],
debug: true
}));
Expand All @@ -78,17 +84,18 @@ When set to `true`, the process will end with non-zero error code if any error-l

### `reportOutputDir`

Base directory for lint results written to filesystem. Defaults to current working directory.
Base directory for lint results written to filesystem. Defaults to **current working directory** `process.cwd()`.

### `reporters`

List of reporter configuration objects (see below). Defaults to an empty array.
List of reporter configuration objects (see below). Defaults to **an empty array** `[]`.

```js
{
// stylelint results formatter (required):
// - pass a function for imported, custom or exposed formatters
// - pass a string ("string", "verbose", "json") for formatters bundled with stylelint
// - pass a string for formatters bundled with stylelint
// "string (default)", "compact", "github", "json", "tap", "unix", "verbose"
formatter: myFormatter,

// save the formatted result to a file (optional):
Expand Down
35 changes: 35 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*!
* Gulp Stylelint (v2.0.0): jest.config.js
* Copyright (c) 2023-24 Adorade (https://github.com/adorade/gulp-stylelint-esm)
* License under MIT
* ========================================================================== */

/** @type {import('jest').Config} */
const config = {
clearMocks: true,
// collectCoverage: true,
collectCoverageFrom: [
"src/*.mjs"
],
coverageDirectory: "./.coverage/",
coverageReporters: [
"html",
"lcov",
"text"
],
coverageThreshold: {
global: {
branches: 75,
functions: 75,
lines: 75,
statements: 75
}
},
transform: {
"\\.mjs?$": "babel-jest"
},
roots: ["test"],
testRegex: ".*\\.test\\.js$"
}

export default config;
40 changes: 21 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gulp-stylelint-esm",
"version": "1.1.1",
"description": "Gulp plugin for running Stylelint results through various reporters.",
"version": "2.0.0",
"description": "Gulp plugin for stylelint with ES module support.",
"author": {
"name": "Adorade",
"email": "office.adorade@gmail.com",
Expand All @@ -13,9 +13,9 @@
"url": "https://github.com/adorade/gulp-stylelint-esm.git"
},
"type": "module",
"exports": "./src/index.js",
"exports": "./src/index.mjs",
"files": [
"/src/*.js"
"/src/*.mjs"
],
"keywords": [
"gulpplugin",
Expand All @@ -27,35 +27,37 @@
"esm"
],
"scripts": {
"lint": "eslint \"{src,test}/**/*.js\"",
"tape": "tape \"test/*.spec.js\"",
"test": "yarn run lint && yarn run tape",
"lint": "eslint {src,test}/**/*.{mjs,js}",
"jest": "node --experimental-vm-modules --no-warnings node_modules/jest/bin/jest.js -i",
"jest:coverage": "yarn run jest --coverage",
"test": "yarn run lint && yarn run jest",
"prepublishOnly": "yarn test"
},
"peerDependencies": {
"stylelint": "^14.0.0 || ^15.0.0"
"stylelint": "16"
},
"dependencies": {
"@adorade/plugin-error": "1.0.0",
"@jridgewell/trace-mapping": "0.3.22",
"ansi-colors": "4.1.3",
"fancy-log": "2.0.0",
"plugin-error": "2.0.1",
"source-map": "0.7.4"
"fancy-log": "2.0.0"
},
"devDependencies": {
"@babel/core": "7.23.3",
"@babel/eslint-parser": "7.23.3",
"eslint": "8.54.0",
"eslint-config-stylelint": "20.0.0",
"@babel/core": "7.23.9",
"@babel/eslint-parser": "7.23.10",
"@babel/preset-env": "7.23.9",
"babel-jest": "29.7.0",
"eslint": "8.56.0",
"eslint-config-stylelint": "21.0.0",
"gulp": "4.0.2",
"gulp-clean-css": "4.3.0",
"gulp-concat": "2.6.1",
"gulp-rename": "2.0.0",
"jest": "29.7.0",
"sinon": "17.0.1",
"stylelint": "15.11.0",
"tape": "5.7.2"
"stylelint": "16.2.1"
},
"engines": {
"node": ">=16.0.0"
"node": ">=18.12.0"
},
"license": "MIT"
}
52 changes: 0 additions & 52 deletions src/apply-sourcemap.js

This file was deleted.

Loading