nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: jshint/jshint
Pull request #3633 (2022-11-07 00:43:21)

[[FIX]] Allow initializing const bindings to undef
Warning W080 is inappropriate for constant bindings because, unlike `var` and `let` declarations, `const` requires an initializer.

Relax the emission of W080 to allow initializing constant bindings with `undefined`. Add unit tests to verify that the warning continues to be emitted for constant bindings declared in ES2015 destructuring patterns.

jugglinmike: This resolves gh-3632,

Patch:
diff --git a/src/jshint.js b/src/jshint.js
index 480a21b8..c02e77b8 100644
--- a/src/jshint.js
+++ b/src/jshint.js
@@ -4499,7 +4499,7 @@ var JSHINT = (function() {
         var id = state.tokens.prev;
         value = expression(context, 10);
         if (value) {
-          if (value.identifier && value.value === "undefined") {
+          if (!isConst && value.identifier && value.value === "undefined") {
             warning("W080", id, id.value);
           }
           if (!lone) {


Test patch:
diff --git a/tests/unit/core.js b/tests/unit/core.js
index 139eeb01..284fdaf2 100644
--- a/tests/unit/core.js
+++ b/tests/unit/core.js
@@ -847,16 +847,21 @@ exports.testUndefinedAssignment = function (test) {
 
   TestRun(test)
     .addError(1, 5, "It's not necessary to initialize 'x' to 'undefined'.")
-    .addError(2, 7, "It's not necessary to initialize 'y' to 'undefined'.")
     .addError(3, 5, "It's not necessary to initialize 'z' to 'undefined'.")
     .addError(4, 9, "It's not necessary to initialize 'a' to 'undefined'.")
-    .addError(6, 9, "It's not necessary to initialize 'c' to 'undefined'.")
     .addError(7, 7, "It's not necessary to initialize 'd' to 'undefined'.")
     .addError(9, 9, "It's not necessary to initialize 'f' to 'undefined'.")
-    .addError(10, 11, "It's not necessary to initialize 'g' to 'undefined'.")
     .addError(11, 9, "It's not necessary to initialize 'h' to 'undefined'.")
     .test(src, {esnext: true});
 
+  TestRun(test)
+    .addError(1, 8, "It's not necessary to initialize 'x' to 'undefined'.")
+    .addError(2, 8, "It's not necessary to initialize 'y' to 'undefined'.")
+    .test([
+      "const {x = undefined} = {};",
+      "const [y = undefined] = [];",
+    ], {esversion: 6});
+
   test.done();
 };
Repository: lesshint/lesshint
Pull request #54 (2015-08-29 22:32:35)

fix(attributeQuotes): skip validation for value-less selector
Support value-less attributes (a.k.a. boolean attributes)


Patch:
diff --git a/lib/linters/attribute_quotes.js b/lib/linters/attribute_quotes.js
index 146f8b1..3838434 100644
--- a/lib/linters/attribute_quotes.js
+++ b/lib/linters/attribute_quotes.js
@@ -24,6 +24,11 @@ module.exports = function (options) {
         return null;
     }
 
+    // Bail if there's no value to check
+    if (!selector.contains('attributeSelector')) {
+        return null;
+    }
+
     // Use last ident when no quotes are present
     value = selector.first('string') || selector.last('ident');
 


Test patch:
diff --git a/test/specs/linters/attribute_quotes.js b/test/specs/linters/attribute_quotes.js
index 25303c0..8e4ed0f 100644
--- a/test/specs/linters/attribute_quotes.js
+++ b/test/specs/linters/attribute_quotes.js
@@ -203,6 +203,24 @@ describe('lesshint', function () {
             }));
         });
 
+        it('should return null for value-less selectors', function () {
+            var source = 'input[disabled] {}';
+            var ast;
+            var options = {
+                attributeQuotes: {
+                    enabled: true
+                }
+            };
+
+            ast = linter.parseAST(source);
+            ast = ast.first().first('selector').first('simpleSelector');
+
+            assert.equal(null, attributeQuotes({
+                config: options,
+                node: ast
+            }));
+        });
+
         it('should throw on invalid "style" value', function () {
             var source = 'input[type=text] {}';
             var ast;
Repository: lesshint/lesshint
Pull request #60 (2015-09-02 14:24:01)

fix verbiage in url_quotes linter
simple syntax fix


Patch:
diff --git a/lib/linters/url_quotes.js b/lib/linters/url_quotes.js
index bd5199e..589e752 100644
--- a/lib/linters/url_quotes.js
+++ b/lib/linters/url_quotes.js
@@ -33,7 +33,7 @@ module.exports = function (options) {
             column: value.start.column,
             line: value.start.line,
             linter: 'urlQuotes',
-            message: 'URLs should enclosed in quotes.'
+            message: 'URLs should be enclosed in quotes.'
         };
     }
 


Test patch:
diff --git a/test/specs/linters/url_quotes.js b/test/specs/linters/url_quotes.js
index f8c7732..7fb5a24 100644
--- a/test/specs/linters/url_quotes.js
+++ b/test/specs/linters/url_quotes.js
@@ -52,7 +52,7 @@ describe('lesshint', function () {
                 column: 26,
                 line: 1,
                 linter: 'urlQuotes',
-                message: 'URLs should enclosed in quotes.'
+                message: 'URLs should be enclosed in quotes.'
             };
 
             var options = {
@@ -101,7 +101,7 @@ describe('lesshint', function () {
                 column: 26,
                 line: 1,
                 linter: 'urlQuotes',
-                message: 'URLs should enclosed in quotes.'
+                message: 'URLs should be enclosed in quotes.'
             };
 
             var options = {
Repository: lesshint/lesshint
Pull request #85 (2015-10-20 14:05:12)

Skip variable declarations in propertyUnits linter
This MR skips variable declarations inside of classes similar to the example below.

```less
ul {
    @var-name: 25px;
}
```


Patch:
diff --git a/lib/linters/property_units.js b/lib/linters/property_units.js
index ddecfac..cd5c05d 100644
--- a/lib/linters/property_units.js
+++ b/lib/linters/property_units.js
@@ -15,6 +15,9 @@ module.exports = {
         var sprintf = require('sprintf-js').sprintf;
         var self = this;
 
+        if (!node.contains('property') || !node.first('property').contains('ident')) {
+            return null;
+        }
         property = node.first('property').first('ident').content;
         value = node.first('value');
 


Test patch:
diff --git a/test/specs/linters/property_units.js b/test/specs/linters/property_units.js
index 8b52fb1..28e702e 100644
--- a/test/specs/linters/property_units.js
+++ b/test/specs/linters/property_units.js
@@ -364,5 +364,21 @@ describe('lesshint', function () {
 
             assert.equal(null, lint(options, ast));
         });
+
+        it('should return null when variable declaration', function () {
+            var source = '.foo { @var-name: 12px; }';
+            var ast;
+
+            var options = {
+                propertyUnits: {
+                    enabled: true,
+                }
+            };
+
+            ast = parseAST(source);
+            ast = ast.first().first('block').first('declaration');
+
+            assert.equal(null, lint(options, ast));
+        });
     });
 });
Repository: lesshint/lesshint
Pull request #86 (2015-10-20 16:06:19)

Lint quotes in @import urls


Patch:
diff --git a/lib/linters/url_quotes.js b/lib/linters/url_quotes.js
index 324c3bf..6eb86c8 100644
--- a/lib/linters/url_quotes.js
+++ b/lib/linters/url_quotes.js
@@ -2,16 +2,20 @@
 
 module.exports = {
     name: 'urlQuotes',
-    nodeTypes: ['declaration'],
+    nodeTypes: ['declaration', 'atrule'],
     message: 'URLs should be enclosed in quotes.',
 
     lint: function urlQuotesLinter (config, node) {
         var value;
         var url;
 
-        node.forEach('value', function (element) {
-            value = element.first('uri');
-        });
+        if (node.is('declaration')) {
+            node.forEach('value', function (element) {
+                value = element.first('uri');
+            });
+        } else if (node.is('atrule')) {
+            value = node.first('uri');
+        }
 
         // No URLs found, bail
         if (!value) {


Test patch:
diff --git a/test/specs/linters/url_quotes.js b/test/specs/linters/url_quotes.js
index 50a5917..9dbcb0f 100644
--- a/test/specs/linters/url_quotes.js
+++ b/test/specs/linters/url_quotes.js
@@ -65,6 +65,48 @@ describe('lesshint', function () {
             assert.deepEqual(actual, expected);
         });
 
+        it('should not allow missing quotes in imports', function () {
+            var source = '@import url(http://google.de)';
+            var actual;
+            var ast;
+
+            var expected = [{
+                column: 9,
+                line: 1,
+                linter: 'urlQuotes',
+                message: 'URLs should be enclosed in quotes.'
+            }];
+
+            var options = {
+                urlQuotes: {
+                    enabled: true
+                }
+            };
+
+            ast = parseAST(source);
+            ast = ast.first();
+
+            actual = lint(options, ast);
+
+            assert.deepEqual(actual, expected);
+        });
+
+        it('should allow quoted urls in imports', function () {
+            var source = '@import url(\'http://google.de\')';
+            var ast;
+
+            var options = {
+                urlQuotes: {
+                    enabled: true
+                }
+            };
+
+            ast = parseAST(source);
+            ast = ast.first();
+
+            assert.strictEqual(undefined, lint(options, ast));
+        });
+
         it('should allow quoted URLs strings surrounded by spaces (#22)', function () {
             var source = ".foo { background-image: url( 'img/image.jpg' ); }";
             var ast;
Repository: lesshint/lesshint
Pull request #178 (2016-05-20 11:24:57)

2.0 propertyOrdering bugs
This fixes two issues:
* It treated all the declarations in nested rules as one and thus complained about them. See #177.
* It would complain on variables that weren't alphabetically ordered.


Patch:
diff --git a/lib/linters/property_ordering.js b/lib/linters/property_ordering.js
index 0d2fe63..68a0247 100644
--- a/lib/linters/property_ordering.js
+++ b/lib/linters/property_ordering.js
@@ -15,17 +15,18 @@ module.exports = {
             throw new Error('Invalid setting value for propertyOrdering: ' + config.style);
         }
 
-        node.walkDecls(function (declaration) {
+        node.each(function (child) {
             var currentProperty;
             var property;
 
-            if (results.length) {
+            if (child.type !== 'decl' || results.length) {
                 return;
             }
 
-            property = declaration.prop;
+            property = child.prop;
 
-            if (!property) {
+            // Ignore declarations without a property and variables
+            if (!property || (property && /^@/.test(property))) {
                 return;
             }
 
@@ -34,8 +35,8 @@ module.exports = {
             // Check for proper ordering
             if (previousProp && previousProp.localeCompare(currentProperty) > 0) {
                 results = [{
-                    column: declaration.source.start.column,
-                    line: declaration.source.start.line,
+                    column: child.source.start.column,
+                    line: child.source.start.line,
                     message: self.message
                 }];
             }


Test patch:
diff --git a/test/specs/linters/property_ordering.js b/test/specs/linters/property_ordering.js
index 5b14f9d..7381f86 100644
--- a/test/specs/linters/property_ordering.js
+++ b/test/specs/linters/property_ordering.js
@@ -71,12 +71,19 @@ describe('lesshint', function () {
             });
         });
 
-        it('should not try to check variables', function () {
-            var source = '.foo { @var: auto; }';
+        it('should check each rule on its own', function () {
+            var source = '';
             var options = {
                 style: 'alpha'
             };
 
+            source += '.form-group {';
+            source += '    margin-bottom: 0;';
+            source += '    .form-control {';
+            source += '        height: auto;';
+            source += '    }';
+            source += '}';
+
             return spec.parse(source, function (ast) {
                 var result = spec.linter.lint(options, ast.root.first);
 
@@ -85,7 +92,7 @@ describe('lesshint', function () {
         });
 
         it('should not try to check variables', function () {
-            var source = '.foo { @var: auto; }';
+            var source = '.foo { @b: auto; @a: inherit; }';
             var options = {
                 style: 'alpha'
             };
Repository: lesshint/lesshint
Pull request #258 (2016-09-16 13:52:43)

Add support for LESS merge feature
DuplicateProperty config should ingnore duplicate property ending with a "+" or "+_". This is a LESS merge feature. See: http://lesscss.org/features/#merge-feature

shellscape: The code change looks good, but we'll need some specs to go along with this. 
MichelGratton: This PR fix this Issue: https://github.com/lesshint/lesshint/issues/257 I think all informations is there
shellscape: I think you're misunderstanding. When we make a new code change, there needs to be specs (tests) created for the change. New specs for the property merging should be created in this file: https://github.com/lesshint/lesshint/blob/master/test/specs/linters/duplicate_property.js

Patch:
diff --git a/lib/linters/duplicate_property.js b/lib/linters/duplicate_property.js
index 159a509..875ce48 100644
--- a/lib/linters/duplicate_property.js
+++ b/lib/linters/duplicate_property.js
@@ -19,7 +19,7 @@ module.exports = {
                 return true;
             }
 
-            if (properties.indexOf(decl.prop) >= 0) {
+            if (!decl.prop.match(/\+\_?$/) && properties.indexOf(decl.prop) >= 0) {
                 results.push({
                     message: util.format(self.message, decl.prop),
                     column: decl.source.start.column,


Test patch:
diff --git a/test/specs/linters/duplicate_property.js b/test/specs/linters/duplicate_property.js
index 6703cb3..ac64b75 100644
--- a/test/specs/linters/duplicate_property.js
+++ b/test/specs/linters/duplicate_property.js
@@ -103,5 +103,32 @@ describe('lesshint', function () {
                 expect(result).to.be.undefined;
             });
         });
+
+        it('should ignore comma merge properties', function () {
+            var source = '.foo { box-shadow+: 0 0 10px #555; box-shadow+: inset 0 0 5px #222; }';
+            var options = {
+                exclude: []
+            };
+
+            return spec.parse(source, function (ast) {
+                var result = spec.linter.lint(options, ast.root.first);
+
+                expect(result).to.be.undefined;
+            });
+        });
+
+        it('should ignore space merge properties', function () {
+            var source = '.foo { transform+_: scale(2); transform+_: rotate(15deg); }';
+            var options = {
+                exclude: []
+            };
+
+            return spec.parse(source, function (ast) {
+                var result = spec.linter.lint(options, ast.root.first);
+
+                expect(result).to.be.undefined;
+            });
+        });
+
     });
 });
Repository: lesshint/lesshint
Pull request #366 (2017-03-17 14:28:19)

Add check for variable in url quotes linter.
**Which issue, if any, does this resolve?**
#364 

**Is there anything in this PR that needs extra explaining or should something specific be focused on?**
Seems pretty straightforward.

jwilsson: Cool, thanks for contributing! 🎉 

Patch:
diff --git a/lib/linters/url_quotes.js b/lib/linters/url_quotes.js
index 17518e5..b4c52f4 100644
--- a/lib/linters/url_quotes.js
+++ b/lib/linters/url_quotes.js
@@ -34,6 +34,11 @@ module.exports = {
             const uri = child.first.next();
             const value = uri.value.trim();
 
+            // Ignore variables
+            if (value.substring(0, 1) === '@') {
+                return;
+            }
+
             /**
              * postcss-values-parser has a bug with url string params surrounded by
              * spaces. So account for that here.


Test patch:
diff --git a/test/specs/linters/url_quotes.js b/test/specs/linters/url_quotes.js
index 9bee407..385ef27 100644
--- a/test/specs/linters/url_quotes.js
+++ b/test/specs/linters/url_quotes.js
@@ -167,5 +167,16 @@ describe('lesshint', function () {
                 expect(result).to.deep.equal(expected);
             });
         });
+
+        it('should ignore variables', function () {
+            const source = '.foo { background-image: url(@bar) }';
+
+            return spec.parse(source, function (ast) {
+                const result = spec.linter.lint({}, ast.root.first.first);
+
+                expect(result).to.be.undefined;
+            });
+        });
+
     });
 });
Repository: lesshint/lesshint
Pull request #429 (2017-09-20 06:55:02)

Typo: missing 'n' in trailing_whitespace complaint


Patch:
diff --git a/lib/linters/README.md b/lib/linters/README.md
index bf6aa3c..9f76081 100644
--- a/lib/linters/README.md
+++ b/lib/linters/README.md
@@ -866,7 +866,7 @@ Semicolons are optional after the last property in a ruleset but it's a good hab
 ```
 
 ## trailingWhitespace
-There should't be any trailing whitespace since this will mess up diffs etc.
+There shouldn't be any trailing whitespace since this will mess up diffs etc.
 
 ## urlFormat
 All URLs should be relative.
diff --git a/lib/linters/trailing_whitespace.js b/lib/linters/trailing_whitespace.js
index 0fd24b9..88dbc88 100644
--- a/lib/linters/trailing_whitespace.js
+++ b/lib/linters/trailing_whitespace.js
@@ -3,7 +3,7 @@
 module.exports = {
     name: 'trailingWhitespace',
     nodeTypes: ['root'],
-    message: "There should't be any trailing whitespace.",
+    message: "There shouldn't be any trailing whitespace.",
 
     lint: function trailingWhitespaceLinter (config, node) {
         // Ignore empty files


Test patch:
diff --git a/test/specs/linters/trailing_whitespace.js b/test/specs/linters/trailing_whitespace.js
index 83dd3c6..4a979f6 100644
--- a/test/specs/linters/trailing_whitespace.js
+++ b/test/specs/linters/trailing_whitespace.js
@@ -38,7 +38,7 @@ describe('lesshint', function () {
             const expected = [{
                 column: 9,
                 line: 1,
-                message: "There should't be any trailing whitespace."
+                message: "There shouldn't be any trailing whitespace."
             }];
 
             return spec.parse(source, function (ast) {
@@ -53,7 +53,7 @@ describe('lesshint', function () {
             const expected = [{
                 column: 9,
                 line: 1,
-                message: "There should't be any trailing whitespace."
+                message: "There shouldn't be any trailing whitespace."
             }];
 
             return spec.parse(source, function (ast) {
Repository: lesshint/lesshint
Pull request #441 (2017-11-27 22:08:40)

variableValue Linter - Allowed Values
<!--
If you're submitting a PR for a new feature, please open an issue about it first so we can discuss it.
If you're submitting a PR for something else, for example a documentation fix, go right ahead!
-->

**Which issue, if any, does this resolve?**
https://github.com/lesshint/lesshint/issues/355

**Is there anything in this PR that needs extra explaining or should something specific be focused on?**
No


justtal: Done

Patch:
diff --git a/lib/config/defaults.json b/lib/config/defaults.json
index e922baa..4496f3e 100644
--- a/lib/config/defaults.json
+++ b/lib/config/defaults.json
@@ -205,6 +205,7 @@
     "variableValue": {
         "enabled": true,
         "always": [],
-        "never": []
+        "never": [],
+        "allowedValues": []
     }
 }
diff --git a/lib/linters/README.md b/lib/linters/README.md
index 7b80167..0faa77b 100644
--- a/lib/linters/README.md
+++ b/lib/linters/README.md
@@ -975,9 +975,10 @@ The [CSS spec](http://dev.w3.org/csswg/css-values/#url-value) also recommends th
 Force variable or non variable value in property.
 
 Option     | Description
----------- | ----------
-`always`    | Array of property names
-`never`    | Array of property names
+--------------- | ----------
+`always`        | Array of property names
+`never`         | Array of property names
+`allowedValues` | Array of allowed non variables values
 
 ### always ['color'] valid
 ```less
@@ -986,6 +987,13 @@ Option     | Description
 }
 ```
 
+### always ['color'] allowedValues ['none'] valid
+```less
+.foo {
+    color: none;
+}
+```
+
 ### always ['color'] invalid
 ```less
 .foo {
diff --git a/lib/linters/variable_value.js b/lib/linters/variable_value.js
index 467b3c6..57efc15 100644
--- a/lib/linters/variable_value.js
+++ b/lib/linters/variable_value.js
@@ -9,6 +9,11 @@ module.exports = {
     message: '%s is not allowed in "%s" property.',
 
     lint: function variableValueLinter (config, node) {
+        if (config.allowedValues &&
+            config.allowedValues.indexOf(node.value) !== -1) {
+            return;
+        }
+
         if (config.never && config.never.indexOf(node.prop) !== -1) {
             if (isVariable(node.value)) {
                 const position = node.positionBy({


Test patch:
diff --git a/test/specs/linters/variable_value.js b/test/specs/linters/variable_value.js
index 22a037b..c804d5e 100644
--- a/test/specs/linters/variable_value.js
+++ b/test/specs/linters/variable_value.js
@@ -100,5 +100,19 @@ describe('lesshint', function () {
                 expect(result).to.be.undefined;
             });
         });
+
+        it('should allow value if in allowedValues list', function () {
+            const source = 'color: none;';
+            const options = {
+                always: ['color'],
+                allowedValues: ['none']
+            };
+
+            return spec.parse(source, function (ast) {
+                const result = spec.linter.lint(options, ast.root.first);
+
+                expect(result).to.be.undefined;
+            });
+        });
     });
 });