Skip to content

Commit 45bf071

Browse files
committed
Enable strict mode.
1 parent 15043ef commit 45bf071

File tree

100 files changed

+134
-5
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+134
-5
lines changed

.jshintrc

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
"noempty": true,
1212
"nonbsp": true,
1313
"quotmark": "double",
14-
"unused": true,
14+
"strict": true,
1515
"undef": true,
16+
"unused": true,
1617
"globals": {
1718
"CSSLint": true,
1819
"YUITest": true

Gruntfile.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/* jshint camelcase:false, evil:true, node:true */
22

3+
"use strict";
4+
35
module.exports = function(grunt) {
46

57
// Project configuration.

demos/CSSLintDemo.htm

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ <h1>CSSLint Demo</h1>
7878
<div id="output"></div>
7979
<script>
8080
(function() {
81+
"use strict";
8182

8283
document.body.onclick = function(event) {
8384
event = event || window.event;

src/cli/common.js

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
/* exported cli */
77

88
function cli(api){
9+
"use strict";
910

1011
var globalOptions = {
1112
"help" : { "format" : "", "description" : "Displays this information."},

src/cli/node.js

+7
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,17 @@ cli({
1414
args: process.argv.slice(2),
1515

1616
print: function(message){
17+
"use strict";
1718
fs.writeSync(1, message + "\n");
1819
},
1920

2021
quit: function(code){
22+
"use strict";
2123
process.exit(code || 0);
2224
},
2325

2426
isDirectory: function(name){
27+
"use strict";
2528
try {
2629
return fs.statSync(name).isDirectory();
2730
} catch (ex) {
@@ -30,6 +33,7 @@ cli({
3033
},
3134

3235
getFiles: function(dir){
36+
"use strict";
3337
var files = [];
3438

3539
try {
@@ -61,14 +65,17 @@ cli({
6165
},
6266

6367
getWorkingDirectory: function() {
68+
"use strict";
6469
return process.cwd();
6570
},
6671

6772
getFullPath: function(filename){
73+
"use strict";
6874
return path.resolve(process.cwd(), filename);
6975
},
7076

7177
readFile: function(filename){
78+
"use strict";
7279
try {
7380
return fs.readFileSync(filename, "utf-8");
7481
} catch (ex) {

src/cli/rhino.js

+6
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,19 @@
88
importPackage(java.io);
99

1010
cli({
11+
1112
args: Array.prototype.concat.call(arguments),
1213
print: print,
1314
quit: quit,
1415

1516
isDirectory: function(name){
17+
"use strict";
1618
var dir = new File(name);
1719
return dir.isDirectory();
1820
},
1921

2022
getFiles: function(dir){
23+
"use strict";
2124
var files = [];
2225

2326
function traverse(dir) {
@@ -37,14 +40,17 @@ cli({
3740
},
3841

3942
getWorkingDirectory: function() {
43+
"use strict";
4044
return (new File(".")).getCanonicalPath();
4145
},
4246

4347
getFullPath: function(filename){
48+
"use strict";
4449
return (new File(filename)).getCanonicalPath();
4550
},
4651

4752
readFile: function(filename) {
53+
"use strict";
4854
try {
4955
return readFile(filename);
5056
} catch (ex) {

src/cli/wsh.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
/* global cli */
99

1010
var wshapi = (function(){
11+
"use strict";
12+
1113
var fso = new ActiveXObject("Scripting.FileSystemObject");
1214
var shell = WScript.CreateObject("WScript.Shell");
1315
var finalArgs = [], i, args = WScript.Arguments;
@@ -41,7 +43,6 @@ var wshapi = (function(){
4143

4244
if (!Array.prototype.indexOf) {
4345
Array.prototype.indexOf = function (searchElement /*, fromIndex */ ) {
44-
"use strict";
4546
if (this === void 0 || this === null) {
4647
throw new Error("unknown instance");
4748
}

src/core/CSSLint.js

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
/* exported CSSLint */
1010

1111
var CSSLint = (function(){
12+
"use strict";
1213

1314
var rules = [],
1415
formatters = [],

src/core/Reporter.js

+8
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* they are errors or warnings.
99
*/
1010
function Reporter(lines, ruleset){
11+
"use strict";
1112

1213
/**
1314
* List of messages being reported.
@@ -54,6 +55,7 @@ Reporter.prototype = {
5455
* @method error
5556
*/
5657
error: function(message, line, col, rule){
58+
"use strict";
5759
this.messages.push({
5860
type : "error",
5961
line : line,
@@ -74,6 +76,7 @@ Reporter.prototype = {
7476
* @deprecated Use report instead.
7577
*/
7678
warn: function(message, line, col, rule){
79+
"use strict";
7780
this.report(message, line, col, rule);
7881
},
7982

@@ -86,6 +89,7 @@ Reporter.prototype = {
8689
* @method report
8790
*/
8891
report: function(message, line, col, rule){
92+
"use strict";
8993
this.messages.push({
9094
type : this.ruleset[rule.id] === 2 ? "error" : "warning",
9195
line : line,
@@ -105,6 +109,7 @@ Reporter.prototype = {
105109
* @method info
106110
*/
107111
info: function(message, line, col, rule){
112+
"use strict";
108113
this.messages.push({
109114
type : "info",
110115
line : line,
@@ -122,6 +127,7 @@ Reporter.prototype = {
122127
* @method rollupError
123128
*/
124129
rollupError: function(message, rule){
130+
"use strict";
125131
this.messages.push({
126132
type : "error",
127133
rollup : true,
@@ -137,6 +143,7 @@ Reporter.prototype = {
137143
* @method rollupWarn
138144
*/
139145
rollupWarn: function(message, rule){
146+
"use strict";
140147
this.messages.push({
141148
type : "warning",
142149
rollup : true,
@@ -152,6 +159,7 @@ Reporter.prototype = {
152159
* @method stat
153160
*/
154161
stat: function(name, value){
162+
"use strict";
155163
this.stats[name] = value;
156164
}
157165
};

src/core/Util.js

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ CSSLint.Util = {
1111
* @return {Object} The receiver
1212
*/
1313
mix: function(receiver, supplier){
14+
"use strict";
1415
var prop;
1516

1617
for (prop in supplier){
@@ -29,6 +30,7 @@ CSSLint.Util = {
2930
* @return {int} The index of the value if found, -1 if not.
3031
*/
3132
indexOf: function(values, value){
33+
"use strict";
3234
if (values.indexOf){
3335
return values.indexOf(value);
3436
} else {
@@ -48,6 +50,7 @@ CSSLint.Util = {
4850
* @return {void}
4951
*/
5052
forEach: function(values, func) {
53+
"use strict";
5154
if (values.forEach){
5255
return values.forEach(func);
5356
} else {

src/formatters/checkstyle-xml.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
(function() {
2+
"use strict";
23

34
/**
45
* Replace special characters before write to output.

src/formatters/compact.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ CSSLint.addFormatter({
88
* @return {String} to prepend before all results
99
*/
1010
startFormat: function() {
11+
"use strict";
1112
return "";
1213
},
1314

@@ -16,6 +17,7 @@ CSSLint.addFormatter({
1617
* @return {String} to append after all results
1718
*/
1819
endFormat: function() {
20+
"use strict";
1921
return "";
2022
},
2123

@@ -27,6 +29,7 @@ CSSLint.addFormatter({
2729
* @return {String} output for results
2830
*/
2931
formatResults: function(results, filename, options) {
32+
"use strict";
3033
var messages = results.messages,
3134
output = "";
3235
options = options || {};
@@ -41,7 +44,7 @@ CSSLint.addFormatter({
4144
};
4245

4346
if (messages.length === 0) {
44-
return options.quiet ? "" : filename + ": Lint Free!";
47+
return options.quiet ? "" : filename + ": Lint Free!";
4548
}
4649

4750
CSSLint.Util.forEach(messages, function(message) {

src/formatters/csslint-xml.js

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ CSSLint.addFormatter({
88
* @return {String} to prepend before all results
99
*/
1010
startFormat: function(){
11+
"use strict";
1112
return "<?xml version=\"1.0\" encoding=\"utf-8\"?><csslint>";
1213
},
1314

@@ -16,6 +17,7 @@ CSSLint.addFormatter({
1617
* @return {String} to append after all results
1718
*/
1819
endFormat: function(){
20+
"use strict";
1921
return "</csslint>";
2022
},
2123

@@ -27,6 +29,7 @@ CSSLint.addFormatter({
2729
* @return {String} output for results
2830
*/
2931
formatResults: function(results, filename/*, options*/) {
32+
"use strict";
3033
var messages = results.messages,
3134
output = [];
3235

src/formatters/junit-xml.js

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ CSSLint.addFormatter({
88
* @return {String} to prepend before all results
99
*/
1010
startFormat: function(){
11+
"use strict";
1112
return "<?xml version=\"1.0\" encoding=\"utf-8\"?><testsuites>";
1213
},
1314

@@ -16,6 +17,7 @@ CSSLint.addFormatter({
1617
* @return {String} to append after all results
1718
*/
1819
endFormat: function() {
20+
"use strict";
1921
return "</testsuites>";
2022
},
2123

@@ -27,6 +29,7 @@ CSSLint.addFormatter({
2729
* @return {String} output for results
2830
*/
2931
formatResults: function(results, filename/*, options*/) {
32+
"use strict";
3033

3134
var messages = results.messages,
3235
output = [],

src/formatters/lint-xml.js

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ CSSLint.addFormatter({
88
* @return {String} to prepend before all results
99
*/
1010
startFormat: function(){
11+
"use strict";
1112
return "<?xml version=\"1.0\" encoding=\"utf-8\"?><lint>";
1213
},
1314

@@ -16,6 +17,7 @@ CSSLint.addFormatter({
1617
* @return {String} to append after all results
1718
*/
1819
endFormat: function(){
20+
"use strict";
1921
return "</lint>";
2022
},
2123

@@ -27,6 +29,7 @@ CSSLint.addFormatter({
2729
* @return {String} output for results
2830
*/
2931
formatResults: function(results, filename/*, options*/) {
32+
"use strict";
3033
var messages = results.messages,
3134
output = [];
3235

src/formatters/text.js

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ CSSLint.addFormatter({
88
* @return {String} to prepend before all results
99
*/
1010
startFormat: function() {
11+
"use strict";
1112
return "";
1213
},
1314

@@ -16,6 +17,7 @@ CSSLint.addFormatter({
1617
* @return {String} to append after all results
1718
*/
1819
endFormat: function() {
20+
"use strict";
1921
return "";
2022
},
2123

@@ -27,6 +29,7 @@ CSSLint.addFormatter({
2729
* @return {String} output for results
2830
*/
2931
formatResults: function(results, filename, options) {
32+
"use strict";
3033
var messages = results.messages,
3134
output = "";
3235
options = options || {};

src/rules/adjoining-classes.js

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ CSSLint.addRule({
1212

1313
//initialization
1414
init: function(parser, reporter){
15+
"use strict";
1516
var rule = this;
1617
parser.addListener("startrule", function(event){
1718
var selectors = event.selectors,

src/rules/box-model.js

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ CSSLint.addRule({
1111

1212
//initialization
1313
init: function(parser, reporter){
14+
"use strict";
1415
var rule = this,
1516
widthProperties = {
1617
border: 1,

src/rules/box-sizing.js

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ CSSLint.addRule({
1313

1414
//initialization
1515
init: function(parser, reporter){
16+
"use strict";
1617
var rule = this;
1718

1819
parser.addListener("property", function(event){

src/rules/bulletproof-font-face.js

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ CSSLint.addRule({
1313

1414
//initialization
1515
init: function(parser, reporter){
16+
"use strict";
1617
var rule = this,
1718
fontFaceRule = false,
1819
firstSrc = true,

0 commit comments

Comments
 (0)