Repository: shellscape/postcss-less (js)

Issue:
Bracket selectors are considered mixin parameters.
* Node Version: v6.10.3
* NPM Version: v5.5.1
* postcss-less Version: v1.1.3

### LESS

```less
.a,
.b[type=text] {
  color: blue;
}
```

### JavaScript

```js
let postCssLess = require('./dist/less-syntax');
const less = `
.a,
.b[type=text] {
  color: blue;
}
`;
const root = postCssLess.parse(less);
console.log(root);
```

### Expected Behavior
No `params` set to match other postcss outputs.

### Actual Behavior
Bracket selector is considered a `params` value.

### How can we reproduce the behavior?
Use above JS file at project root.
This issue was found when using `stylelint`.

Pull request description:
#96 - Add extra check for not adding params from brackets.
Hopefully Fixes #96.

Please check one:
- [X] New tests created for this change
- [ ] Tests updated for this change

This PR:
- [ ] Adds new API
- [ ] Extends existing API, backwards-compatible
- [ ] Introduces a breaking change
- [X] Fixes a bug

---

After looking through the less documentation I have not found any mixin or extend syntax that uses brackets `[]`. The Idea is to not fill `params` with brackets.


Patch:
diff --git a/lib/less-parser.js b/lib/less-parser.js
index 30192e8..3b2aa62 100755
--- a/lib/less-parser.js
+++ b/lib/less-parser.js
@@ -316,8 +316,8 @@ export default class LessParser extends Parser {
         }
       }
 
-      // we don't want to add params for pseudo-selectors that utilize parens (#56)
-      if ((extend || !colon) && (brackets.length > 0 || type === 'brackets' || params[0])) {
+      // we don't want to add params for pseudo-selectors that utilize parens (#56) or bracket selectors (#96)
+      if ((extend || !colon) && (brackets.length > 0 || type === 'brackets' || params[0]) && brackets[0] !== ']') {
         params.push(token);
       }
 


Test patch:
diff --git a/test/parser/params.spec.js b/test/parser/params.spec.js
index d54b2c5..2e76c11 100644
--- a/test/parser/params.spec.js
+++ b/test/parser/params.spec.js
@@ -15,5 +15,13 @@ describe('Parser', () => {
       expect(root.first.params).to.be.undefined;
     });
 
+    it('should not assign parameters for bracket selectors', () => {
+      const code = '.test1,.test2[test=test] {}';
+      const root = parse(code);
+
+      expect(root.first.selector).to.eql('.test1,.test2[test=test]');
+      expect(root.first.params).to.be.undefined;
+    });
+
   });
 });