Skip to content

Commit

Permalink
eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
chicoxyzzy committed Feb 12, 2015
1 parent fffe135 commit 1511fff
Show file tree
Hide file tree
Showing 51 changed files with 878 additions and 642 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ src/vendor_deprecated
src/**/__tests__/**
# This should be enabled but that folder has too much in it that doesn't belong
src/test
test/the-files-to-test.generated.js
50 changes: 50 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
parser: esprima-fb

env:
browser: true
node: true

globals:
__DEV__: true

rules:
# ERRORS
space-before-blocks: [2, 'always']
brace-style: 2
space-after-keywords: 2
strict: 2
# We actually have a transform to support this and we fix this for bundled
# releases but not for the npm package, so enforce it strictly
no-comma-dangle: 2
# Make this a warning for now. We do this in a few places so we might need to
# disable
no-unused-expressions: 2
block-scoped-var: 2
eol-last: 2
dot-notation: 2
consistent-return: 2
no-unused-vars: [2, args: none]
quotes: [2, 'single']

# WARNINGS
# This is the only one that's hard to track since we don't lint just changes.
max-len: [1, 80]

# WISHLIST. One day...
# We'll need a custom version of this that does a subset of the whole rule.
# Otherwise this is just too noisy.
# valid-jsdoc: 1

# DISABLED. These aren't compatible with our style
# We use this for private/internal variables
no-underscore-dangle: 0
# We pass constructors around / access them from members
new-cap: 0
# We do this a lot.
no-use-before-define: 0
# We do this in a few places to align values
key-spacing: 0

# DISABLED. These currently cause errors when running.
no-multi-spaces: 0
18 changes: 0 additions & 18 deletions .jshintrc

This file was deleted.

93 changes: 58 additions & 35 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ var npmReactTasks = require('./grunt/tasks/npm-react');
var npmReactToolsTasks = require('./grunt/tasks/npm-react-tools');
var versionCheckTask = require('./grunt/tasks/version-check');
var gemReactSourceTasks = require('./grunt/tasks/gem-react-source');
var eslintTask = require('./grunt/tasks/eslint');

module.exports = function(grunt) {

Expand All @@ -22,45 +23,43 @@ module.exports = function(grunt) {
browserify: require('./grunt/config/browserify'),
populist: require('./grunt/config/populist')(grunt),
connect: require('./grunt/config/server')(grunt),
"webdriver-jasmine": require('./grunt/config/webdriver-jasmine'),
"webdriver-perf": require('./grunt/config/webdriver-perf'),
'webdriver-jasmine': require('./grunt/config/webdriver-jasmine'),
'webdriver-perf': require('./grunt/config/webdriver-perf'),
npm: require('./grunt/config/npm'),
clean: ['./build', './*.gem', './docs/_site', './examples/shared/*.js', '.module-cache'],
clean: [
'./build',
'./*.gem',
'./docs/_site',
'./examples/shared/*.js',
'.module-cache'
],
jshint: require('./grunt/config/jshint'),
/*eslint-disable camelcase */
compare_size: require('./grunt/config/compare_size')
/*eslint-enable camelcase */
});

grunt.config.set('compress', require('./grunt/config/compress'));

Object.keys(grunt.file.readJSON('package.json').devDependencies)
.filter(function(npmTaskName) { return npmTaskName.indexOf('grunt-') === 0; })
.filter(function(npmTaskName) { return npmTaskName != 'grunt-cli'; })
.forEach(function(npmTaskName) { grunt.loadNpmTasks(npmTaskName); });

// Super simplified eslint task that we can use to replace linting. This just
// shells out to eslint.
grunt.registerTask('eslint', function() {
var done = this.async();
grunt.util.spawn({
cmd: 'node_modules/.bin/eslint',
args: ['src']
}, function(err, result, code) {
if (code === 0) {
grunt.log.ok('Lint passed (but may contain warnings)');
} else {
grunt.log.error('Lint failed');
}
if (result.stdout.length) {
grunt.log.writeln(result.stdout);
}

done(code === 0);
.filter(function(npmTaskName) {
return npmTaskName.indexOf('grunt-') === 0;
})
.filter(function(npmTaskName) {
return npmTaskName !== 'grunt-cli';
})
.forEach(function(npmTaskName) {
grunt.loadNpmTasks(npmTaskName);
});
});

grunt.registerTask('eslint', eslintTask);

grunt.registerTask('lint', ['eslint']);

grunt.registerTask('download-previous-version', require('./grunt/tasks/download-previous-version.js'));
grunt.registerTask(
'download-previous-version',
require('./grunt/tasks/download-previous-version.js')
);

grunt.registerTask('delete-build-modules', function() {
if (grunt.file.exists('build/modules')) {
Expand Down Expand Up @@ -93,11 +92,28 @@ module.exports = function(grunt) {

grunt.registerTask('version-check', versionCheckTask);

grunt.registerTask('build:basic', ['jsx:normal', 'version-check', 'browserify:basic']);
grunt.registerTask('build:addons', ['jsx:normal', 'browserify:addons']);
grunt.registerTask('build:transformer', ['jsx:normal', 'browserify:transformer']);
grunt.registerTask('build:min', ['jsx:normal', 'version-check', 'browserify:min']);
grunt.registerTask('build:addons-min', ['jsx:normal', 'browserify:addonsMin']);
grunt.registerTask('build:basic', [
'jsx:normal',
'version-check',
'browserify:basic'
]);
grunt.registerTask('build:addons', [
'jsx:normal',
'browserify:addons'
]);
grunt.registerTask('build:transformer', [
'jsx:normal',
'browserify:transformer'
]);
grunt.registerTask('build:min', [
'jsx:normal',
'version-check',
'browserify:min'
]);
grunt.registerTask('build:addons-min', [
'jsx:normal',
'browserify:addonsMin'
]);
grunt.registerTask('build:withCodeCoverageLogging', [
'jsx:normal',
'version-check',
Expand All @@ -117,8 +133,15 @@ module.exports = function(grunt) {
'version-check',
'populist:test'
]);
grunt.registerTask('build:npm-react', ['version-check', 'jsx:normal', 'npm-react:release']);
grunt.registerTask('build:gem-react-source', ['build', 'gem-react-source:release']);
grunt.registerTask('build:npm-react', [
'version-check',
'jsx:normal',
'npm-react:release'
]);
grunt.registerTask('build:gem-react-source', [
'build',
'gem-react-source:release'
]);

grunt.registerTask('webdriver-phantomjs', webdriverPhantomJSTask);

Expand Down Expand Up @@ -161,7 +184,7 @@ module.exports = function(grunt) {
'webdriver-perf:saucelabs_firefox',
'webdriver-perf:saucelabs_chrome',
'webdriver-perf:saucelabs_ie11',
'webdriver-perf:saucelabs_ie8',
'webdriver-perf:saucelabs_ie8'
]);

grunt.registerTask('test:webdriver:saucelabs', [
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ grunt test
grunt test --debug
# For speed, you can use fasttest and add --filter to only run one test
grunt fasttest --filter=ReactIdentity
# Lint the code with JSHint
# Lint the code with ESLint
grunt lint
# Wipe out build directory
grunt clean
Expand Down
3 changes: 1 addition & 2 deletions grunt/config/browserify.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* jshint multistr:true */
/* jshint -W040 */
/*eslint-disable no-multi-str */

'use strict';

Expand Down
2 changes: 1 addition & 1 deletion grunt/config/compare_size.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ module.exports = {
return gzip.zip(contents, {}).length;
}
},
cache: ".grunt/sizecache.json"
cache: '.grunt/sizecache.json'
}
};
2 changes: 1 addition & 1 deletion grunt/config/copy.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';

/*eslint-disable camelcase*/
module.exports = {

react_docs: {
Expand Down
22 changes: 11 additions & 11 deletions grunt/config/jsx.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ var grunt = require('grunt');
var _ = require('lodash');

var rootIDs = [
"React",
"ReactWithAddons"
'React',
'ReactWithAddons'
];

// TODO: stop packaging these libraries
rootIDs = rootIDs.concat([
"merge",
"mergeInto",
"copyProperties"
'merge',
'mergeInto',
'copyProperties'
]);

var normal = {
Expand All @@ -23,23 +23,23 @@ var normal = {
constants: {}
};
},
sourceDir: "src",
outputDir: "build/modules"
sourceDir: 'src',
outputDir: 'build/modules'
};


var test = {
rootIDs: rootIDs.concat([
"test/all.js",
"**/__tests__/*.js"
'test/all.js',
'**/__tests__/*.js'
]),
getConfig: function() {
return _.merge({}, normal.getConfig(), {
mocking: true
});
},
sourceDir: "src",
outputDir: "build/modules"
sourceDir: 'src',
outputDir: 'build/modules'
};


Expand Down
14 changes: 7 additions & 7 deletions grunt/config/populist.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

module.exports = function(grunt) {
var jasmine = {
rootDirectory: "build/jasmine",
// This syntax means to require and expose the "jasmine" module
rootDirectory: 'build/jasmine',
// This syntax means to require and expose the 'jasmine' module
// (build/jasmine/jasmine.js) as global.jasmine, and to require the
// "all" module (build/jasmine/all.js) but not expose it globally.
args: ["jasmine:jasmine", "all:"],
outfile: "./build/jasmine.js"
// 'all' module (build/jasmine/all.js) but not expose it globally.
args: ['jasmine:jasmine', 'all:'],
outfile: './build/jasmine.js'
};

var filterExpr = grunt.option('filter');
Expand All @@ -19,8 +19,8 @@ module.exports = function(grunt) {
}

var test = {
rootDirectory: "build/modules",
args: ["test/all:harness"],
rootDirectory: 'build/modules',
args: ['test/all:harness'],
requires: [filterExpr],
outfile: './build/react-test.js'
};
Expand Down
Loading

0 comments on commit 1511fff

Please sign in to comment.