nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: shellscape/postcss-less
Pull request #79 (2017-06-10 09:13:29)

Handle quote-less import paths correctly
**Which issue #** if any, does this resolve?
#77
<!-- PRs must be accompanied by related tests -->

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

---

<!-- add additional comments here -->



Patch:
diff --git a/lib/less-parser.js b/lib/less-parser.js
index f69064c..105613b 100755
--- a/lib/less-parser.js
+++ b/lib/less-parser.js
@@ -164,7 +164,12 @@ export default class LessParser extends Parser {
         break;
       }
       else if (tokn[0] === 'brackets') {
-        directives.push(tokn);
+        if (node.urlFunc) {
+          node.importPath = tokn[1].replace(/[()]/g, '');
+        }
+        else {
+          directives.push(tokn);
+        }
       }
       else if (tokn[0] === 'space') {
         if (directives.length) {


Test patch:
diff --git a/test/parser/import.spec.js b/test/parser/import.spec.js
index cee34f4..5a49f2c 100644
--- a/test/parser/import.spec.js
+++ b/test/parser/import.spec.js
@@ -39,6 +39,22 @@ describe('Parser', () => {
               }).catch(done);
     });
 
+    it('should parse @imports with a quote-less url function as Import', (done) => {
+      const lessText = '@import url(foo.less);';
+
+      postcss()
+              .process(lessText, { syntax: lessSyntax })
+              .then((result) => {
+                expect(result).to.be.not.null;
+                expect(result.css).to.equal(lessText);
+                expect(result.root.first).to.be.an.instanceof(Import);
+                expect(result.root.first.importPath).to.equal('foo.less');
+                expect(result.root.first.urlFunc).to.equal(true);
+
+                done();
+              }).catch(done);
+    });
+
     it('should parse @imports as Import, no space', (done) => {
       const lessText = '@import"foo.less";';
Repository: shellscape/postcss-less
Pull request #80 (2017-06-14 22:48:02)

less-parser: Handle edge case with single token mixins.
The parser didn't account for mixins that were used in the following manner:

```
.foo {.my-mixin}
```

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



Patch:
diff --git a/lib/less-parser.js b/lib/less-parser.js
index 105613b..7b64943 100755
--- a/lib/less-parser.js
+++ b/lib/less-parser.js
@@ -321,6 +321,11 @@ export default class LessParser extends Parser {
 
     // dont process an end of rule if there's only one token and it's unknown (#64)
     if (end && this.tokens.length > 1) {
+      // Handle the case where the there is only a single token in the end rule.
+      if (start === this.pos) {
+        this.pos += 1;
+      }
+
       const foundEndOfRule = this.ruleEnd({
         start,
         params,


Test patch:
diff --git a/test/parser/mixins.spec.js b/test/parser/mixins.spec.js
index b8a7d15..1987681 100644
--- a/test/parser/mixins.spec.js
+++ b/test/parser/mixins.spec.js
@@ -36,9 +36,19 @@ describe('Parser', () => {
 
         expect(root.first.first.type).to.eql('rule');
         expect(root.first.first.selector).to.eql('.mixin-name');
-        expect(root.first.params).to.be.an('undefined');
+        expect(root.first.params).to.be.undefined;
         expect(root.first.first.empty).to.eql(true);
-        expect(root.first.first.nodes).to.be.an('undefined');
+        expect(root.first.first.nodes).to.be.undefined;
+      });
+
+      it('mixin without body and without whitespace #2', () => {
+        const root = parse('.base {.mixin-name}');
+
+        expect(root.first.first.type).to.eql('rule');
+        expect(root.first.first.selector).to.eql('.mixin-name');
+        expect(root.first.params).to.be.undefined;
+        expect(root.first.first.empty).to.eql(true);
+        expect(root.first.first.nodes).to.be.undefined;
       });
     });
Repository: shellscape/postcss-less
Pull request #94 (2017-10-15 07:47:45)

Allow space between ! and important for mixins
**Which issue #** if any, does this resolve?
#87

<!-- PRs must be accompanied by related tests -->

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

---

This behaves like PostCSS, only adding `node.raws.important` when it's not `!important`. I also noticed there was a failing test unrelated to this change which I've left untouched.

shellscape: Looks good, thanks!

Patch:
diff --git a/lib/less-parser.js b/lib/less-parser.js
index 52f374d..6f838a6 100755
--- a/lib/less-parser.js
+++ b/lib/less-parser.js
@@ -114,9 +114,14 @@ export default class LessParser extends Parser {
       // eslint-disable-next-line
       delete this.current.nodes;
 
-      if (/!important/i.test(node.selector)) {
+      if (/!\s*important/i.test(node.selector)) {
         node.important = true;
-        node.selector = node.selector.replace(/\s*!important/i, '');
+
+        if (/\s*!\s+important/i.test(node.selector)) {
+          node.raws.important = node.selector.match(/(\s*!\s+important)/i)[1];
+        }
+
+        node.selector = node.selector.replace(/\s*!\s*important/i, '');
       }
 
       // rules don't have trailing semicolons in vanilla css, so they get


Test patch:
diff --git a/test/parser/mixins.spec.js b/test/parser/mixins.spec.js
index 6ccab18..d2f857f 100644
--- a/test/parser/mixins.spec.js
+++ b/test/parser/mixins.spec.js
@@ -158,6 +158,23 @@ describe('Parser', () => {
         expect(root.first.important).to.eql(true);
       });
 
+      it('parses nested mixins with `! important`', () => {
+        const code = `
+                    .foo() ! important;
+                    .bar()! important;
+                `;
+
+        const root = parse(code);
+
+        expect(root.first.selector).to.eql('.foo()');
+        expect(root.first.important).to.eql(true);
+        expect(root.first.raws.important).to.eql(' ! important');
+
+        expect(root.last.selector).to.eql('.bar()');
+        expect(root.last.important).to.eql(true);
+        expect(root.last.raws.important).to.eql('! important');
+      });
+
       it('parses nested mixins with the rule set', () => {
         const params = '({background-color: red;})';
         const ruleSet = `.desktop-and-old-ie ${ params }`;
Repository: shellscape/postcss-less
Pull request #95 (2017-11-10 20:36:32)

Stringify !important correctly
**Which issue #** if any, does this resolve?
I didn't create an issue since this is just a small follow-up to #94 where I realized I'd missed the stringifying bit.

<!-- PRs must be accompanied by related tests -->

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

---

<!-- add additional comments here -->


jwilsson: I found another bug too, which I've fixed as well. Everything but ` !important` (note the leading space) should be included in `node.raws.important`.

Patch:
diff --git a/lib/less-parser.js b/lib/less-parser.js
index 6f838a6..30192e8 100755
--- a/lib/less-parser.js
+++ b/lib/less-parser.js
@@ -117,8 +117,8 @@ export default class LessParser extends Parser {
       if (/!\s*important/i.test(node.selector)) {
         node.important = true;
 
-        if (/\s*!\s+important/i.test(node.selector)) {
-          node.raws.important = node.selector.match(/(\s*!\s+important)/i)[1];
+        if (/\s*!\s*important/i.test(node.selector)) {
+          node.raws.important = node.selector.match(/(\s*!\s*important)/i)[1];
         }
 
         node.selector = node.selector.replace(/\s*!\s*important/i, '');
diff --git a/lib/less-stringifier.js b/lib/less-stringifier.js
index fe12f8a..a8a22a2 100755
--- a/lib/less-stringifier.js
+++ b/lib/less-stringifier.js
@@ -27,7 +27,12 @@ export default class LessStringifier extends Stringifier {
 
     if (node.empty && node.raws.semicolon) {
       if (node.important) {
-        this.builder(' !important');
+        if (node.raws.important) {
+          this.builder(node.raws.important);
+        }
+        else {
+          this.builder(' !important');
+        }
       }
 
       if (node.raws.semicolon) {


Test patch:
diff --git a/test/stringify.spec.js b/test/stringify.spec.js
index 4ba6452..e470d35 100644
--- a/test/stringify.spec.js
+++ b/test/stringify.spec.js
@@ -119,5 +119,19 @@ describe('#stringify()', () => {
         done(error);
       });
     });
+
+    it('stringifies mixin with !important', (done) => {
+      const less = '.foo { .mix() ! important; }';
+
+      postcss().process(less, {
+        syntax: postcssLess,
+        stringifier: stringify
+      }).then((result) => {
+        expect(result.content).to.eql(less);
+        done();
+      }).catch((error) => {
+        done(error);
+      });
+    });
   });
 });
Repository: shellscape/postcss-less
Pull request #107 (2018-05-29 19:03:01)

Add '!' to list of chars that end at-words
**Which issue #** if any, does this resolve?
#105 
<!-- PRs must be accompanied by related tests -->

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

---

<!-- add additional comments here -->


jwilsson: @shellscape I guess we could double check with the Prettier-guys. I'll run a quick check on stylelint too.

@evilebottnawi Do you think this could cause any issues for in Prettier? Thanks!
shellscape: @jwilsson OK when you're confident about stylelint, say the word and I'll merge it.
jwilsson: @shellscape Everything looks good in stylelint, we're all set!

@evilebottnawi Thanks for checking!

Patch:
diff --git a/lib/tokenizer/globals.js b/lib/tokenizer/globals.js
index c41c863..9736fb8 100644
--- a/lib/tokenizer/globals.js
+++ b/lib/tokenizer/globals.js
@@ -24,7 +24,7 @@ export const tilde = '~'.charCodeAt(0);
 export const hash = '#'.charCodeAt(0);
 
 
-export const atEndPattern = /[ \n\t\r\f\{\(\)'"\\;/\[\]#]/g;
+export const atEndPattern = /[ \n\t\r\f\{\(\)'"\\;/\[\]#!]/g;
 export const wordEndPattern = /[ \n\t\r\f\(\)\{\}:,;@!'"\\\]\[#]|\/(?=\*)/g;
 export const badBracketPattern = /.[\\\/\("'\n]/;
 


Test patch:
diff --git a/test/tokenize.spec.js b/test/tokenize.spec.js
index 0174f37..fab49d5 100644
--- a/test/tokenize.spec.js
+++ b/test/tokenize.spec.js
@@ -188,5 +188,11 @@ describe('#tokenize()', () => {
     //     [ '}', '}', 1, 28 ]
     //   ]);
     // });
+    it('tokenizes @var next to !important separately', () => {
+      testTokens('@var!important', [
+        ['at-word', '@var', 1, 1, 1, 4],
+        ['word', '!important', 1, 5, 1, 14]
+      ]);
+    });
   });
 });