Is there an option for jscs and jshint in .jscsrc/.jshintrc to turn off linting for a directory? - jshint

I would like to disable linting for all files in a directory
For example
/
some.js <-LINT
noLint
file1.js <- NO LINT
file2.js <- NO LINT
subDir
file3.js <- NO LINT

I don't think that is possible. For jscs, I can imagine you can create a jscsrc that effectively disables all default rules. For example:
{
"validateLineBreaks": false,
"disallowMultipleVarDecl": false,
"validateIndentation": null
}
For jshint, you can try something similar:
{
"browser": true,
"jquery": true,
"mocha": true,
"node": true,
"curly": false,
"eqeqeq": false,
"maxdepth": 99,
"maxerr": 1000,
"undef": false,
"unused": false,
"esversion": 6,
"expr": true
}
So instead of disabling, you create settings that are as loose as possible.

Related

Module '"tapable"' has no exported member 'Tapable'

I was working on a WordPress plugin for a custom Gutenberg block.
Since I needed to add additional scripts which I wanted to write in TypeScript, I used "$ tsc --watch" and a "tsconfig.json"-file to compile them.
After installing #wordpress/scripts ("$ npm i --save-dev --save-exact #wordpress/scripts"), tsc indicated 89 errors at this path: node_modules#types\webpack\index.d.ts.
I have opened this file and found that the source of all the errors was the first line of this import statement:
import {
Tapable,
HookMap,
SyncBailHook,
SyncHook,
SyncLoopHook,
SyncWaterfallHook,
AsyncParallelBailHook,
AsyncParallelHook,
AsyncSeriesBailHook,
AsyncSeriesHook,
AsyncSeriesWaterfallHook,
} from 'tapable';
Tsc was still working for my files, but having 89 errors thrown each time I compile is concerning nonetheless.
This is the code of my tsconfig.json:
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"allowUnreachableCode": false,
"declaration": false,
"resolveJsonModule": true,
"experimentalDecorators": true,
"lib": [
"dom",
"es2017"
],
"moduleResolution": "node",
"module": "esnext",
"target": "es2017",
"outDir": "script/build",
"noUnusedLocals": true,
"noUnusedParameters": true,
"jsx": "react",
"jsxFactory": "h"
},
"include": [
"script/src"
],
"exclude": [
"node_modules"
]
}
I found that the problem was the path of the import statement.
Webpack was importing Tapable from node_modules/tapable when it would have needed to import it from node_modules/#types/tapable.
Changing the last line of the import statement fixed all errors:
} from '../tapable';

Get Shared channel list and joined user list via slack API

My goal is to list up Slack shared channel list, which joined users via Slack web API.
/usr/bin/curl -s -XPOST 'https://slack.com/api/conversations.list?token=MY_TOKEN&pretty=1' | jq -r '.channels[]|select(.is_shared = "true")'
But return is including non-shared channels also, like a (.is_shared = "false"). I have no idea why am I getting such results. Appreciate any help.
I use following code
/usr/bin/curl -s -XPOST 'https://slack.com/api/conversations.list?token=MY_TOKEN&pretty=1'
and results is
{
"ok": true,
"channels": [
{
"id": "C2U56FH6Z",
"name": "hoge_general",
"is_channel": true,
"is_group": false,
"is_im": false,
"created": 1477470814,
"is_archived": false,
"is_general": false,
"unlinked": 0,
"name_normalized": "hoge_general",
"is_shared": false,
"parent_conversation": null,
"creator": "U2UABCDEF",
"is_ext_shared": false,
"is_org_shared": false,
"shared_team_ids": [
"T2U94ABCDE"
],
"pending_shared": [],
"pending_connected_team_ids": [],
"is_pending_ext_shared": false,
"is_member": true,
"is_private": false,
"is_mpim": false,
"topic": {
"value": "Editor \2",
"creator": "U2UABCDE",
"last_set": 1478675694
},
"purpose": {
"value": "AAA editor ",
"creator": "U2UABABCDF",
"last_set": 14774596815
},
"previous_names": [],
"num_members": 11
},
So, I try to get channnel name which method is .
Comparison of values in jq is done using the == operator; = is the assignment operator which changes values (similar to many C-like programming languages).
The is_shared property in your JSON document is of type boolean (true or false), but you are comparing it to a string ("true" or "false"). That will always result in false (true == "true" is false).
Instead, compare booleans with booleans: .channels[] | select(.is_shared == true)
And, as with most other programming languages, conditionals compare implicitly against true, so if you have == true somewhere, this is redundant 99% of the time and can be simplified: .channels[] | select(.is_shared)

Can't configure karma to use karma-spec-reporter

In my karma.conf.js
plugins : [
'karma-phantomjs-launcher',
'karma-angular-filesort',
'karma-coverage',
'karma-jasmine',
'karma-ng-html2js-preprocessor',
'karma-spec-reporter',
],
coverageReporter: {
type : 'html',
dir : 'coverage/'
},
specReporter: {
maxLogLines: 10,
suppressPassed: false,
suppressFailed: false,
suppressSkipped: false,
suppressErrorSummary: false
},
// reporters: ['progress']
reporters: ['spec']
Yet when I run my tests (gulp test), the output continues to be the same as when karma used the 'progress' reporter.
What am I missing?

Grunt less source maps change path prefix

My config
server: {
options: {
sourceMap: true,
sourceMapFilename: '.tmp/styles/main.css.map',
sourceMapURL: '/styles/main.css.map'
},
files: {
'.tmp/styles/main.css':
'src/app/views/styles/application.less'
}
},
My structure
.tmp
src
Gruntfile.js
so after calling grunt less:server
I am getting .tmp/styles/main.css.map
with attr "sources" everywhere src/ prefix
but I want without src/ because server starts from src/*
How can I change it ?
Since version 1.0.0. grunt-contrib-less accepts the same options as the command line compiler does. You can get a list of these options by running lessc wihtout any argument on your command line:
--source-map-rootpath=X Adds this path onto the sourcemap filename and less file paths.
So you should use:
options: {
sourceMap: true,
sourceMapFilename: '.tmp/styles/main.css.map',
sourceMapURL: '/styles/main.css.map',
sourceMapRootpath: "/app/views/styles/"
}

how to use multiple mochacov reporters in single Gruntfile and get the coverage report

Currently am switching between html-cov and json-cov in my gruntfile and running the command
grunt mochacov:all > coverage.html
(or)
grunt mochacov:all > coverage.json
Here is the json portion of config from my Gruntfile.js :
mochacov : {
options : {
reporter : 'json-cov',
//reporter : 'travis-cov',
require : ['should'],
timeout: 250000,
//quiet : true,
output : 'coverage.json',
},
all: ['test/test-*.js']
},
Is there anyway using which i can get both coverage.html and coverage.json in the output by default by specifying both html-cov and json-cov somehow?
Sadly, looks like by default grunt-mocha-cov doesn't support this, as the reporter only accepts a 'string' (per the docs).
Theoretically this should be possible with a grunt multitask.
I have found out the answer for the same :-
This is what we need to have in our Gruntfile.js
mochacov: {
jsoncoverage: {
options: {
reporter: 'json-cov',
//reporter : 'travis-cov',
require: ['should'],
timeout: 250000,
//quiet : true,
output: 'reports/coverage.json'
},
all: ['test/test-*.js']
},
htmlcoverage: {
options: {
reporter: 'html-cov',
//reporter : 'travis-cov',
require: ['should'],
timeout: 250000,
//quiet : true,
output: 'reports/coverage.html'
},
all: ['test/test-*.js']
}
}
//and then the following line needs to be there :
grunt.registerTask('mochacoverage', ['mochacov:jsoncoverage', 'mochacov:htmlcoverage']);
Then we can run it using grunt mochacoverage and it will do both html and json

Resources