jshint

Static-analysis with custom rules for JavaScript?

我是研究僧i 提交于 2019-12-09 13:23:11
问题 Does JSLint, JSHint, or some other open-source static code analysis tool support adding custom rules for code compliance, or are there some ECMAScript compliant parsers that I can use to get the results as close as possible to the ones seen in the snippet below? For example, I’d like to look into JavaScript code and list what functions are called, if it calls a library (or APIs provided by smartphones for HTML5 widgets) to register all that fall under the namespaces of that API, to make a

jshint - Create custom warnings/rules

给你一囗甜甜゛ 提交于 2019-12-08 17:03:42
问题 Is it possible to create a custom jshint rule, add it to existing inbuilt rules, configure it (on or off) in our projects? Is jshint extendable, like how we create our own custom tasks in Grunt? Sometimes we need to enforce a javascript coding practice just in our environment. For example, we want to enforce our developers to use Date.now() instead of Date.getTime(). 回答1: You should consider using ESLint in that case. Every rule is standalone. Even the default rules. So you could take one of

How can I make jshint indent options work

我只是一个虾纸丫 提交于 2019-12-08 15:24:23
问题 jslint can check indent by run 'jslint --indent 4 test.js', but I don't get it work in jshint. I do it as the follow steps. install jshint through "npm install -g jshint" edit ~/.jshintrc, my jshintrc looks like {..., "indent":4, "white":false, ...} edit js file test.js / jshint indent:4 / var condition, doSth; if (condition) doSth(); // expected to be invalid run jshint test.js, but the indent checking is not working. The 2 spaces started line can pass the check. 回答1: It's a version problem.

Error Local Npm module “jshint-stylish” not found when it exists locally (via symlink)

别说谁变了你拦得住时间么 提交于 2019-12-08 03:40:05
问题 I have a linux symlink to a folder called node_modules in my folder with the grunt file but when I run grunt I get this: Local Npm module "jshint-stylish" not found. Is it installed? All my other npm modules work fine,any ideas? my grunt file: module.exports = function (grunt) { grunt.loadNpmTasks('grunt-shell'); grunt.loadNpmTasks('grunt-open'); grunt.loadNpmTasks('grunt-contrib-watch'); grunt.loadNpmTasks('grunt-contrib-clean'); grunt.loadNpmTasks('grunt-contrib-concat'); grunt.loadNpmTasks

Jshint / PhpStorm: “Unresolved variable” when using jquery .data()

独自空忆成欢 提交于 2019-12-07 20:11:21
问题 Phpstorm keeps telling me I have an undefined variable input.connectto Html: <div class="b-showColorinList" data-connectto="123456" data-othervalue="Lorem Ipsum">... JS: $(document).on('click', '.b-showColorinList', function() { cm.showColorInList( $(this) ); }); And: /** * Uses ajax to get other color in list view * @param {object} inputObj */ cm.showColorInList = function(inputObj) { "use strict"; var input = inputObj.data(), parent = $("#"+input.connectto), othervalue = input.othervalue; I

How to run JSHint on files with Django template markup in them?

六眼飞鱼酱① 提交于 2019-12-07 05:51:18
问题 I would like to run JSHint on all my Javascript source files but several of them have some embedded Django template markup. JSHint throws a ton of errors on this markup. Is there a way to either... Tell JSHint to ignore this markup Run the Djnago template parser with some dummy data to generate all permutations of the rendered js file and then run JSHint on that? I assume I could write a bunch of code to do #2 but i'm wondering if there's an easier way. 回答1: Depending on a markup you can get

Cannot use GLOB with JSHint in Windows?

只谈情不闲聊 提交于 2019-12-07 03:43:34
问题 I'm doing a PoC of NPM as a build tool (http://blog.keithcirkel.co.uk/how-to-use-npm-as-a-build-tool/). I'm fairly new using NPM. For now, I only have JSHint and Mocha installed. My packagae.json is attached. Now, when I run "npm run lint" in the command line (Windows 7), it gives me an error: c:\project>npm run list MyNPMProject@1.0.0 lint c:\project jshint test/*.js ERROR: Can't open test/*.js It works when I change the script "lint": "jshint test/test.js". Can I use glob with jshint?

This function has too many statements. (41)

三世轮回 提交于 2019-12-07 03:28:56
问题 I have this controller .controller('ctrl', function($scope, $rootScope, $timeout, $alert, $location, $tooltip, $popover, BetSlipFactory, AccordionsFactory, AuthFactory, RiskWinCalculations) {...}); and, I am getting this error due to jshint : line 10 col 44 This function has too many statements. (41) so, what should I do to avoid it ? 回答1: It doesn't mean poorly managed code as @pankajparkar says before, it could be because you have something like this, lets say this from one of my projects:

Enabling JSHint Support for Ext.js in Intellij Idea

删除回忆录丶 提交于 2019-12-06 11:06:48
So, when i'm using JSHint for my Ext.js project everytime i use Ext it is marked as 'Ext' is not defined by JSHint. How do i suppress this warning or integrate Ext.js into JSHint? I have integrated the Ext sources into my project as an external library and code completion works, so Intellij knows about Ext. SOLUTION: @Nikos answer and the jshint documentation gave me the right direction. I have placed a file called .jshintrc in the root directory of my project. Content: { "predef": [ "Ext", "Ext5" ] } Second set intellij to use the .jshintrc file: In settings -> Languages & Frameworks -

Running grunt-contrib-jshint only on recently modified files

本小妞迷上赌 提交于 2019-12-06 06:08:36
问题 We're going through refactoring the code on a very large site. I would like to enforce linting on any files that get changed, but ignore the rest (as many of them will end up being removed so it's a waste of time to tidy them up). I would like to have a grunt task that checks that a file's modified date is more recent than its created (*fetched from repo) date and lints it if this is the case (would be good also to have grunt update a json list of files to be linted). I haven't used node much