diff --git a/package.json b/package.json index 7f1bde090eb4..79f4cebc1101 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "0.36.4", "devDependencies": { "asar": "^0.9.0", + "eslint": "^1.10.3", "request": "*" }, "optionalDependencies": { diff --git a/script/cibuild b/script/cibuild index 1273945409e4..391b859a3d2e 100755 --- a/script/cibuild +++ b/script/cibuild @@ -63,6 +63,7 @@ def main(): run_script('bootstrap.py', args) run_script('cpplint.py') + run_script('eslint.py') if PLATFORM != 'win32': run_script('pylint.py') if is_release: diff --git a/script/eslint.py b/script/eslint.py new file mode 100755 index 000000000000..8fa2c3a7e3a7 --- /dev/null +++ b/script/eslint.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python + +import glob +import os +import sys + +from lib.util import execute + + +SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) + + +def main(): + os.chdir(SOURCE_ROOT) + + eslint = os.path.join(SOURCE_ROOT, 'node_modules', '.bin', 'eslint') + if sys.platform in ['win32', 'cygwin']: + eslint += '.cmd' + settings = ['--quiet', '--config'] + + sourceConfig = os.path.join('script', 'eslintrc-base.json') + sourceFiles = ['atom'] + execute([eslint] + settings + [sourceConfig] + sourceFiles) + + specConfig = os.path.join('script', 'eslintrc-spec.json') + specFiles = glob.glob('spec/*.js') + execute([eslint] + settings + [specConfig] + specFiles) + + +if __name__ == '__main__': + sys.exit(main()) diff --git a/script/eslintrc-base.json b/script/eslintrc-base.json new file mode 100644 index 000000000000..5c9f15eb666d --- /dev/null +++ b/script/eslintrc-base.json @@ -0,0 +1,31 @@ +{ + "rules": { + "indent": [ + 0, + 2, + { + "SwitchCase": 1 + } + ], + "quotes": [ + 0, + "single" + ], + "semi": [ + 0, + "always" + ], + "comma-dangle": 0, + "linebreak-style": 0, + "no-console": 0, + "no-undef": 0, + "no-unreachable": 0, + "no-unused-vars": 0 + }, + "env": { + "es6": true, + "node": true, + "browser": true + }, + "extends": "eslint:recommended" +} diff --git a/script/eslintrc-spec.json b/script/eslintrc-spec.json new file mode 100644 index 000000000000..3a4fbe2c1281 --- /dev/null +++ b/script/eslintrc-spec.json @@ -0,0 +1,10 @@ +{ + "rules": { + "no-empty": 0 + }, + "env": { + "jquery": true, + "mocha": true + }, + "extends": "./eslintrc-base.json" +}