Browse Source

moved to eslint

  * jshint is old, and has fallen out of favor
  * neither currently supports immed, newcap, sub as they're deprecated
  in jshint. This means you must move to jcss if you want style
  checking. I left that that excercise to someone else. Everything else
  works and the options have been ported to eslint (defaults removed).
  Eslint requires less configuration and defaults to sane and safe.
Evan Carroll 6 năm trước cách đây
mục cha
commit
87d4d4e911
3 tập tin đã thay đổi với 22 bổ sung27 xóa
  1. 12 0
      .eslintrc.json
  2. 7 25
      Gruntfile.js
  3. 3 2
      package.json

+ 12 - 0
.eslintrc.json

@@ -0,0 +1,12 @@
+{
+	"rules": {
+		"no-use-before-define": 2,
+		"no-caller": 2,
+		"no-eq-null": 2
+	},
+	"parserOptions": { "ecmaVersion": 6 },
+	"env": {
+		"browser": true,
+		"node": true
+	}
+}

+ 7 - 25
Gruntfile.js

@@ -4,25 +4,7 @@ module.exports = function(grunt) {
   // Project configuration.
   grunt.initConfig({
     // Task configuration.
-    jshint: {
-      options: {
-        curly: true,
-        eqeqeq: true,
-        immed: true,
-        latedef: true,
-        newcap: true,
-        noarg: true,
-        sub: true,
-        undef: true,
-        unused: true,
-        boss: true,
-        eqnull: true,
-        node: true,
-        globals: {
-          jQuery: true,
-          window: true,
-        }
-      },
+    eslint: {
       gruntfile: {
         src: 'Gruntfile.js'
       },
@@ -35,22 +17,22 @@ module.exports = function(grunt) {
     },
     watch: {
       gruntfile: {
-        files: '<%= jshint.gruntfile.src %>',
-        tasks: ['jshint:gruntfile']
+        files: '<%= eslint.gruntfile.src %>',
+        tasks: ['eslint:gruntfile']
       },
       lib_test: {
-        files: '<%= jshint.lib_test.src %>',
-        tasks: ['jshint:lib_test', 'nodeunit']
+        files: '<%= eslint.lib_test.src %>',
+        tasks: ['eslint:lib_test', 'nodeunit']
       }
     }
   });
 
   // These plugins provide necessary tasks.
   grunt.loadNpmTasks('grunt-contrib-nodeunit');
-  grunt.loadNpmTasks('grunt-contrib-jshint');
+	grunt.loadNpmTasks("gruntify-eslint");
   grunt.loadNpmTasks('grunt-contrib-watch');
 
   // Default task.
-  grunt.registerTask('default', ['jshint', 'nodeunit']);
+  grunt.registerTask('default', ['eslint', 'nodeunit']);
 
 };

+ 3 - 2
package.json

@@ -29,10 +29,11 @@
     "start": "grunt default watch"
   },
   "devDependencies": {
-    "grunt": "~0.4.1",
+    "grunt": "^0.4.5",
     "grunt-cli": "~1.2.0",
+    "grunt-contrib-eslint": "~0.6.4",
     "grunt-contrib-nodeunit": "~0.2.0",
     "grunt-contrib-watch": "~0.5.3",
-    "grunt-contrib-jshint": "~0.6.4"
+    "gruntify-eslint": "^5.0.0"
   }
 }