diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 000000000..50a519048 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,3 @@ +{ + "extends": "./build/config/eslint.json" +} diff --git a/build/Gruntfile.coffee b/build/Gruntfile.coffee index e5acc9c7b..5596473be 100644 --- a/build/Gruntfile.coffee +++ b/build/Gruntfile.coffee @@ -52,10 +52,12 @@ _.extend(global, require('harmony-collections')) unless global.WeakMap? module.exports = (grunt) -> grunt.loadNpmTasks('grunt-coffeelint-cjsx') grunt.loadNpmTasks('grunt-lesslint') + grunt.loadNpmTasks('grunt-babel') grunt.loadNpmTasks('grunt-cson') grunt.loadNpmTasks('grunt-contrib-csslint') grunt.loadNpmTasks('grunt-coffee-react') grunt.loadNpmTasks('grunt-contrib-coffee') + grunt.loadNpmTasks('grunt-eslint') grunt.loadNpmTasks('grunt-contrib-less') grunt.loadNpmTasks('grunt-shell') grunt.loadNpmTasks('grunt-markdown') @@ -124,6 +126,25 @@ module.exports = (grunt) -> dest: appDir ext: '.js' + babelConfig = + options: require './config/babel.json' + dist: + files: [{ + expand: true + src: [ + 'src/**/*.es6' + 'src/**/*.es' + 'src/**/*.jsx' + 'internal_packages/**/*.es6' + 'internal_packages/**/*.es' + 'internal_packages/**/*.jsx' + 'static/**/*.es6' + 'static/**/*.es' + ] + dest: appDir + ext: '.js' + }] + lessConfig = options: paths: [ @@ -189,6 +210,8 @@ module.exports = (grunt) -> coffee: coffeeConfig + babel: babelConfig + cjsx: cjsxConfig less: lessConfig @@ -235,6 +258,20 @@ module.exports = (grunt) -> target: grunt.option("target")?.split(" ") or [] + eslint: + options: + configFile: 'build/config/eslint.json' + target: [ + 'internal_packages/**/*.jsx' + 'internal_packages/**/*.es6' + 'internal_packages/**/*.es' + 'dot-nylas/**/*.es6' + 'dot-nylas/**/*.es' + 'src/**/*.es6' + 'src/**/*.es' + 'src/**/*.jsx' + ] + csslint: options: 'adjoining-classes': false @@ -319,8 +356,8 @@ module.exports = (grunt) -> stderr: false failOnError: false - grunt.registerTask('compile', ['coffee', 'cjsx', 'prebuild-less', 'cson', 'peg']) - grunt.registerTask('lint', ['coffeelint', 'csslint', 'lesslint', 'nylaslint']) + grunt.registerTask('compile', ['coffee', 'cjsx', 'babel', 'prebuild-less', 'cson', 'peg']) + grunt.registerTask('lint', ['coffeelint', 'csslint', 'lesslint', 'nylaslint', 'eslint']) grunt.registerTask('test', ['shell:kill-atom', 'run-edgehill-specs']) grunt.registerTask('docs', ['build-docs', 'render-docs']) diff --git a/build/config/babel.json b/build/config/babel.json new file mode 100644 index 000000000..4687bc4f4 --- /dev/null +++ b/build/config/babel.json @@ -0,0 +1,3 @@ +{ + "presets": ["es2015", "react", "stage-0"] +} diff --git a/build/config/eslint.json b/build/config/eslint.json new file mode 100644 index 000000000..ac6b1aa99 --- /dev/null +++ b/build/config/eslint.json @@ -0,0 +1,17 @@ +{ + "extends": "airbnb", + "globals": { + "atom": false + }, + "env": { + "browser": true, + "node": true, + "jasmine": true + }, + "rules": { + "react/prop-types": [2, {"ignore": ["children"]}], + "eqeqeq": [2, "smart"], + "id-length": [0], + "no-loop-func": [0] + } +} diff --git a/build/package.json b/build/package.json index 15f516872..a9985c5ae 100644 --- a/build/package.json +++ b/build/package.json @@ -7,13 +7,18 @@ }, "dependencies": { "async": "~0.2.9", + "babel-eslint": "^4.1.3", "bluebird": "^2.3", "coffee-react-transform": "^3.1.0", "coffeelint-cjsx": "^2.0", "donna": "1.0.10", + "eslint": "^1.5.1", + "eslint-config-airbnb": "^0.1.0", + "eslint-plugin-react": "^3.4.2", "fs-plus": "2.x", "github-releases": "~0.3.0", "grunt": "~0.4.1", + "grunt-babel": "^6.0.0", "grunt-cli": "~0.1.9", "grunt-coffee-react": "^2.1.0", "grunt-coffeelint": "git+https://github.com/atom/grunt-coffeelint.git#cfb99aa99811d52687969532bd5a98011ed95bfe", @@ -24,6 +29,7 @@ "grunt-cson": "0.14.0", "grunt-download-electron": "^2.1", "grunt-electron-installer": "^1.0", + "grunt-eslint": "^17.3.1", "grunt-lesslint": "0.13.0", "grunt-markdown": "^0.7.0", "grunt-peg": "~1.1.0", diff --git a/package.json b/package.json index cc59989fe..7cc7fe77a 100644 --- a/package.json +++ b/package.json @@ -77,6 +77,10 @@ "vm-compatibility-layer": "0.1.0" }, "devDependencies": { + "babel-eslint": "^4.1.3", + "eslint": "^1.5.1", + "eslint-config-airbnb": "^0.1.0", + "eslint-plugin-react": "^3.4.2", "nock": "^2", "grunt": "^0.4.5", "grunt-serve": "^0.1.6",