Skip to content

Commit 7147a34

Browse files
committed
chore: prepare for v3.0.0 release
1 parent a28a329 commit 7147a34

File tree

4 files changed

+101
-188
lines changed

4 files changed

+101
-188
lines changed

.github/CONTRIBUTING.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
## Contributing in @rollup-cabal
2+
3+
We 💛 contributions! The rules for contributing to this project are few:
4+
5+
1. Don't be a jerk
6+
1. Ask nicely
7+
1. Search issues before opening a new one
8+
1. Lint and run tests locally before submitting a PR
9+
1. Adhere to the code style the project has chosen
10+
11+
❤️ Rollup? Please consider supporting our collective:
12+
👉 https://opencollective.com/rollup/donate

.github/ISSUE_TEMPLATE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
* Node Version:
88
* NPM Version:
9+
* postcss Version:
910
* postcss-less Version:
1011

1112
If you have a large amount of code to share which demonstrates the problem you're experiencing, please provide a link to your

README.md

Lines changed: 71 additions & 169 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,45 @@
1+
[tests]: https://img.shields.io/circleci/project/github/shellscape/postcss-less.svg
2+
[tests-url]: https://circleci.com/gh/shellscape/postcss-less
3+
4+
[cover]: https://codecov.io/gh/shellscape/postcss-less/branch/master/graph/badge.svg
5+
[cover-url]: https://codecov.io/gh/shellscape/postcss-less
6+
7+
[size]: https://packagephobia.now.sh/badge?p=postcss-less
8+
[size-url]: https://packagephobia.now.sh/result?p=postcss-less
9+
110
[PostCSS]: https://github.com/postcss/postcss
211
[PostCSS-SCSS]: https://github.com/postcss/postcss-scss
312
[LESS]: http://lesless.org
413
[Autoprefixer]: https://github.com/postcss/autoprefixer
514
[Stylelint]: http://stylelint.io/
615

7-
# PostCSS LESS Syntax [![Build Status](https://img.shields.io/travis/shellscape/postcss-less.svg?branch=develop)](https://travis-ci.org/shellscape/postcss-less) [![npm Version](https://img.shields.io/npm/v/postcss-less.svg)](https://www.npmjs.com/package/postcss-less)
16+
# postcss-less
817

9-
[PostCSS] Syntax for parsing [LESS]
18+
[![tests][tests]][tests-url]
19+
[![cover][cover]][cover-url]
20+
[![size][size]][size-url]
1021

11-
<img align="right" width="95" height="95"
12-
title="Philosopher's stone, logo of PostCSS"
13-
src="http://postcss.github.io/postcss/logo.svg">
22+
A [PostCSS] Syntax for parsing [LESS]
1423

15-
Please note: poscss-less is not a LESS compiler. For compiling LESS, please use
16-
the official toolset for LESS.
24+
_Note: This module requires Node v6.14.4+. `poscss-less` is not a LESS compiler. For compiling LESS, please use the official toolset for LESS._
1725

18-
## Getting Started
26+
## Install
1927

20-
First thing's first, install the module:
28+
Using npm:
2129

22-
```
30+
```console
2331
npm install postcss-less --save-dev
2432
```
2533

26-
## LESS Transformations
34+
Using yarn:
35+
36+
```console
37+
yarn add postcss-less --dev
38+
```
2739

28-
The most common use of `postcss-less` is for applying PostCSS transformations
29-
directly to LESS source. eg. ia theme written in LESS which uses [Autoprefixer]
30-
to add appropriate vendor prefixes.
40+
## Usage
41+
42+
The most common use of `postcss-less` is for applying PostCSS transformations directly to LESS source. eg. ia theme written in LESS which uses [Autoprefixer] to add appropriate vendor prefixes.
3143

3244
```js
3345
const syntax = require('postcss-less');
@@ -38,174 +50,74 @@ postcss(plugins)
3850
});
3951
```
4052

41-
## Inline Comments
42-
43-
Parsing of single-line comments in CSS is also supported.
44-
45-
```less
46-
:root {
47-
// Main theme color
48-
--color: red;
49-
}
50-
```
51-
52-
Note that you don't need a custom stringifier to handle the output; the default
53-
stringifier will automatically convert single line comments into block comments.
54-
If you need to support inline comments, please use a [custom PostCSSLess stringifier](#stringifier).
55-
56-
## Rule Node
57-
58-
[PostCSS Rule Node](https://github.com/postcss/postcss/blob/master/docs/api.md#rule-node)
59-
60-
### rule.empty
61-
62-
Determines whether or not a rule contains declarations.
63-
64-
_Note: Previously `ruleWithoutBody`. This is a breaking change from v0.16.0 to v1.0.0._
65-
66-
```js
67-
import postCssLess from 'postcss-less';
68-
const less = `
69-
.class2 {
70-
&:extend(.class1);
71-
.mixin-name(@param1, @param2);
72-
}
73-
`;
74-
const root = postCssLess.parse(less);
75-
76-
root.first.nodes[0].empty // => true for &:extend
77-
root.first.nodes[1].empty // => true for calling of mixin
78-
```
79-
80-
### rule.extend
53+
## LESS Specific Parsing
8154

82-
Determines whether or not a rule is [nested](http://lesscss.org/features/#extend-feature-extend-inside-ruleset).
55+
### `@import`
8356

84-
_Note: Previously `extendRule`. This is a breaking change from v0.16.0 to v1.0.0._
57+
Parsing of LESS-specific `@import` statements and options are supported.
8558

86-
```js
87-
import postCssLess from 'postcss-less';
88-
const less = `
89-
.class2 {
90-
&:extend(.class1);
91-
}
92-
`;
93-
const root = postCssLess.parse(less);
94-
95-
root.first.nodes[0].extend // => true
59+
```less
60+
@import (option) 'file.less';
9661
```
9762

98-
### rule.important
99-
100-
Determines whether or not a rule is marked as [important](http://lesscss.org/features/#mixins-feature-the-important-keyword).
101-
102-
_Note: This is a breaking change from v0.16.0 to v1.0.0._
63+
The AST will contain an `AtRule` node with:
10364

104-
```js
105-
import postCssLess from 'postcss-less';
106-
const less = `
107-
.class {
108-
.mixin !important;
109-
}
110-
`;
111-
const root = postCssLess.parse(less);
65+
- an `import: true` property
66+
- a `filename: <String>` property containing the imported filename
67+
- an `options: <String>` property containing any [import options](http://lesscss.org/features/#import-atrules-feature-import-options) specified
11268

113-
root.first.nodes[0].important // => true
114-
root.first.nodes[0].selector // => '.mixin'
115-
```
69+
### Inline Comments
11670

117-
### rule.mixin
71+
Parsing of single-line comments in CSS is supported.
11872

119-
Determines whether or not a rule is a [mixin](http://lesscss.org/features/#mixins-feature).
120-
121-
```js
122-
import postCssLess from 'postcss-less';
123-
const less = `
124-
.class2 {
125-
.mixin-name;
126-
}
127-
`;
128-
const root = postCssLess.parse(less);
129-
130-
root.first.nodes[0].mixin // => true
73+
```less
74+
:root {
75+
// Main theme color
76+
--color: red;
77+
}
13178
```
13279

133-
### rule.nodes
80+
The AST will contain a `Comment` node with an `inline: true` property.
13481

135-
An `Array` of child nodes.
82+
### Mixins
13683

137-
**Note** that `nodes` is `undefined` for rules that don't contain declarations.
84+
Parsing of LESS mixins is supported.
13885

139-
```js
140-
import postCssLess from 'postcss-less';
141-
const less = `
142-
.class2 {
143-
&:extend(.class1);
144-
.mixin-name(@param1, @param2);
145-
}
146-
`;
147-
const root = postCssLess.parse(less);
148-
149-
root.first.nodes[0].nodes // => undefined for &:extend
150-
root.first.nodes[1].nodes // => undefined for mixin
86+
```less
87+
.my-mixin {
88+
color: black;
89+
}
15190
```
15291

153-
## Comment Node
92+
The AST will contain an `AtRule` node with a `mixin: true` property.
15493

155-
[PostCSS Comment Node](https://github.com/postcss/postcss/blob/master/docs/api.md#comment-node)
94+
#### `!important`
15695

157-
### comment.inline
96+
Mixins that declare `!important` will contain an `important: true` property on their respective node.
15897

159-
Determines whether or not a comment is inline.
98+
### Variables
16099

161-
```js
162-
import postCssLess from 'postcss-less';
100+
Parsing of LESS variables is supported.
163101

164-
const root = postCssLess.parse('// Hello world');
165-
166-
root.first.inline // => true
167-
```
168-
169-
### comment.block
170-
171-
Determines whether or not a comment is a block comment.
172-
173-
```js
174-
import postCssLess from 'postcss-less';
175-
176-
const root = postCssLess.parse('/* Hello world */');
177-
178-
root.first.block // => true
102+
```less
103+
@link-color: #428bca;
179104
```
180105

181-
### comment.raws.begin
182-
183-
Precending characters of a comment node. eg. `//` or `/*`.
184-
185-
### comment.raws.content
186-
187-
Raw content of the comment.
106+
The AST will contain an `AtRule` node with a `variable: true` property.
188107

189-
```js
190-
import postCssLess from 'postcss-less';
191-
192-
const root = postCssLess.parse('// Hello world');
193-
194-
root.first.raws.content // => '// Hello world'
195-
```
108+
_Note: LESS variables are strictly parsed - a colon (`:`) must immediately follow a variable name._
196109

197110
## Stringifying
198111

199112
To process LESS code without PostCSS transformations, custom stringifier
200113
should be provided.
201114

202115
```js
203-
import postcss from 'postcss';
204-
import postcssLess from 'postcss-less';
205-
import stringify from 'postcss-less/less-stringify';
116+
const postcss = require('postcss');
117+
const syntax = require('postcss-less');
206118

207-
const lessCode = `
208-
// Non-css comment
119+
const less = `
120+
// inline comment
209121
210122
.container {
211123
.mixin-1();
@@ -220,29 +132,19 @@ const lessCode = `
220132
}
221133
`;
222134

223-
postcss()
224-
.process(less, {
225-
syntax: postcssLess,
226-
stringifier: stringify
227-
})
228-
.then((result) => {
229-
console.log(result.content); // this will be value of `lessCode` without changing comments or mixins
230-
});
135+
const result = await postcss().process(less, { syntax });
136+
137+
// will contain the value of `less`
138+
const { content } = result;
231139
```
232140

233141
## Use Cases
234142

235-
* Lint LESS code with 3rd-party plugins.
236-
* Apply PostCSS transformations (such as [Autoprefixer](https://github.com/postcss/autoprefixer)) directly to the LESS source code
237-
238-
## Contribution
239-
240-
Please, check our guidelines: [CONTRIBUTING.md](./CONTRIBUTING.md)
143+
- Lint LESS code with 3rd-party plugins.
144+
- Apply PostCSS transformations (such as [Autoprefixer](https://github.com/postcss/autoprefixer)) directly to the LESS source code
241145

242-
## Attribution
146+
## Meta
243147

244-
This module is based on the [postcss-scss](https://github.com/postcss/postcss-scss) library.
148+
[CONTRIBUTING](./.github/CONTRIBUTING)
245149

246-
[![npm Downloads](https://img.shields.io/npm/dt/postcss-less.svg)](https://www.npmjs.com/package/postcss-less)
247-
[![npm License](https://img.shields.io/npm/l/postcss-less.svg)](https://www.npmjs.com/package/postcss-less)
248-
[![js-strict-standard-style](https://img.shields.io/badge/code%20style-strict-117D6B.svg)](https://github.com/keithamus/eslint-config-strict)
150+
[LICENSE (MIT)](./LICENSE)

package.json

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,12 @@
33
"version": "2.0.0",
44
"description": "LESS parser for PostCSS",
55
"license": "MIT",
6-
"repository": "webschik/postcss-less",
7-
"keywords": [
8-
"css",
9-
"postcss",
10-
"postcss-syntax",
11-
"parser",
12-
"less"
13-
],
14-
"main": "lib/index.js",
15-
"files": [
16-
"lib",
17-
"README.md",
18-
"LICENSE"
19-
],
6+
"repository": "shellscape/postcss-less",
207
"author": "Denys Kniazevych <webschik@gmail.com>",
21-
"maintainer": {
22-
"name": "Andrew Powell",
23-
"email": "andrew@shellscape.org",
24-
"url": "shellscape.org"
25-
},
8+
"maintainer": "Andrew Powell <andrew@shellscape.org>",
9+
"homepage": "https://github.com/shellscape/postcss-less",
10+
"bugs": "https://github.com/shellscape/postcss-less/issues",
11+
"main": "lib/index.js",
2612
"engines": {
2713
"node": ">=6.14.4"
2814
},
@@ -38,6 +24,11 @@
3824
"security": "npm audit",
3925
"test": "ava"
4026
},
27+
"files": [
28+
"lib",
29+
"README.md",
30+
"LICENSE"
31+
],
4132
"dependencies": {
4233
"postcss": "^7.0.2"
4334
},
@@ -59,6 +50,13 @@
5950
"standard-version": "^4.4.0",
6051
"url-join": "^4.0.0"
6152
},
53+
"keywords": [
54+
"css",
55+
"postcss",
56+
"postcss-syntax",
57+
"parser",
58+
"less"
59+
],
6260
"pre-commit": "lint-staged",
6361
"lint-staged": {
6462
"*.js": [

0 commit comments

Comments
 (0)