Gulp cannot parse .hintrc file - gulp

When running this Gulp task
var gulp = require('gulp'),
util = require('gulp-util'), // For logging
print = require('gulp-print'), // For logging
jshint = require('gulp-jshint');
gulp.task('analyse', function () {
log('Analyzing source with JSHint')
gulp.src(paths.jsContent)
.pipe(print())
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish', { verbose: true }))
.pipe(jshint.reporter('fail'));
});
I get this output:
[14:43:26] Starting 'analyse'...
[14:43:26] Analyzing source with JSHint
[14:43:26] Finished 'analyse' after 32 ms
[gulp] Scripts\main.js
ERROR: Can't parse config file: C:\MyProject\src\MyProject.jshintrc
Error:SyntaxError: Unexpected token
The Gulp file I use is from https://raw.githubusercontent.com/johnpapa/pluralsight-gulp/master/.jshintrc and looks like:
{
"bitwise": true,
"camelcase": true,
"curly": true,
"eqeqeq": true,
"es3": false,
"forin": true,
"freeze": true,
"immed": true,
"indent": 4,
"latedef": "nofunc",
"newcap": true,
"noarg": true,
"noempty": true,
"nonbsp": true,
"nonew": true,
"plusplus": false,
"quotmark": "single",
"undef": true,
"unused": false,
"strict": false,
"maxparams": 10,
"maxdepth": 5,
"maxstatements": 40,
"maxcomplexity": 8,
"maxlen": 120,
"asi": false,
"boss": false,
"debug": false,
"eqnull": true,
"esnext": false,
"evil": false,
"expr": false,
"funcscope": false,
"globalstrict": false,
"iterator": false,
"lastsemic": false,
"laxbreak": false,
"laxcomma": false,
"loopfunc": true,
"maxerr": 50,
"moz": false,
"multistr": false,
"notypeof": false,
"proto": false,
"scripturl": false,
"shadow": false,
"sub": true,
"supernew": false,
"validthis": false,
"noyield": false,
"browser": true,
"node": true,
"globals": {
"angular": false
}
}
Can this be solved?

Just replace your .jshintrc file with the original from John's repo and you will be fine.

Related

JSON / struct column type in AWS GLUE + AWS Athena / Hive?

I have a CSV file created from nested JSON. It has both regular type columns (e.g. int, string), as well as JSON columns, created from nested JSONs:
attributes;business_id;categories;city;days_open;latitude;longitude;name;review_count;stars;state
{"AcceptsInsurance": False, "AgesAllowed": "allages", "Alcohol": "beer_and_wine", "Ambience": {"casual": True, "classy": False, "divey": False, "hipster": False, "intimate": False, "romantic": False, "touristy": False, "trendy": False, "upscale": False}, "BYOB": False, "BikeParking": True, "BusinessAcceptsBitcoin": False, "BusinessAcceptsCreditCards": True, "BusinessParking": {"garage": False, "lot": False, "street": True, "valet": False, "validated": False}, "ByAppointmentOnly": False, "Caters": True, "CoatCheck": False, "Corkage": False, "DogsAllowed": False, "DriveThru": False, "GoodForDancing": False, "GoodForKids": False, "GoodForMeal": {"breakfast": False, "brunch": False, "dessert": False, "dinner": False, "latenight": False, "lunch": False}, "HappyHour": True, "HasTV": True, "Music": None, "NoiseLevel": "average", "Open24Hours": False, "OutdoorSeating": True, "RestaurantsAttire": "casual", "RestaurantsCounterService": False, "RestaurantsDelivery": False, "RestaurantsGoodForGroups": True, "RestaurantsPriceRange": 2, "RestaurantsReservations": False, "RestaurantsTableService": True, "RestaurantsTakeOut": True, "Smoking": "no", "WheelchairAccessible": True, "WiFi": "free"};6iYb2HFDywm3zjuRg0shjw;["Gastropubs", "Food", "Beer Gardens", "Restaurants", "Bars", "American (Traditional)", "Beer Bar", "Nightlife", "Breweries"];Boulder;["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"];40.0175444;-105.2833481;Oskar Blues Taproom;86;4.0;CO
{"AcceptsInsurance": False, "AgesAllowed": "allages", "Alcohol": "beer_and_wine", "Ambience": {"casual": True, "classy": False, "divey": False, "hipster": False, "intimate": False, "romantic": False, "touristy": False, "trendy": False, "upscale": False}, "BYOB": False, "BikeParking": False, "BusinessAcceptsBitcoin": False, "BusinessAcceptsCreditCards": True, "BusinessParking": {"garage": True, "lot": False, "street": False, "valet": False, "validated": False}, "ByAppointmentOnly": False, "Caters": True, "CoatCheck": False, "Corkage": False, "DogsAllowed": False, "DriveThru": False, "GoodForDancing": False, "GoodForKids": True, "GoodForMeal": {"breakfast": True, "brunch": False, "dessert": False, "dinner": False, "latenight": False, "lunch": True}, "HappyHour": False, "HasTV": False, "Music": None, "NoiseLevel": "average", "Open24Hours": False, "OutdoorSeating": False, "RestaurantsAttire": "casual", "RestaurantsCounterService": False, "RestaurantsDelivery": False, "RestaurantsGoodForGroups": False, "RestaurantsPriceRange": 2, "RestaurantsReservations": False, "RestaurantsTableService": True, "RestaurantsTakeOut": True, "Smoking": "no", "WheelchairAccessible": False, "WiFi": "free"};tCbdrRPZA0oiIYSmHG3J0w;["Salad", "Soup", "Sandwiches", "Delis", "Restaurants", "Cafes", "Vegetarian"];Portland;["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"];45.5889058992;-122.5933307507;Flying Elephants at PDX;126;4.0;OR
{"AcceptsInsurance": False, "AgesAllowed": "allages", "Alcohol": "none", "Ambience": None, "BYOB": False, "BikeParking": False, "BusinessAcceptsBitcoin": False, "BusinessAcceptsCreditCards": True, "BusinessParking": {"garage": False, "lot": False, "street": True, "valet": False, "validated": False}, "ByAppointmentOnly": False, "Caters": False, "CoatCheck": False, "Corkage": False, "DogsAllowed": False, "DriveThru": False, "GoodForDancing": False, "GoodForKids": False, "GoodForMeal": None, "HappyHour": False, "HasTV": False, "Music": None, "NoiseLevel": "average", "Open24Hours": False, "OutdoorSeating": False, "RestaurantsAttire": "casual", "RestaurantsCounterService": False, "RestaurantsDelivery": False, "RestaurantsGoodForGroups": False, "RestaurantsPriceRange": 2, "RestaurantsReservations": True, "RestaurantsTableService": True, "RestaurantsTakeOut": False, "Smoking": "no", "WheelchairAccessible": False, "WiFi": "no"};bvN78flM8NLprQ1a1y5dRg;["Antiques", "Fashion", "Used", "Vintage & Consignment", "Shopping", "Furniture Stores", "Home & Garden"];Portland;["Thursday", "Friday", "Saturday", "Sunday"];45.5119069956;-122.6136928797;The Reclaimory;13;4.5;OR
Can this file be processed with AWS Glue to be input for AWS Athena / Hive (which is used internally in Athena)? In particular, how can I specify the data type for JSON columns? Do I have to do this by hand? Are the JSONs written OK, or should they be reformatted?
Will try to answer all of your questions.
Can this file be processed with AWS Glue to be input for AWS Athena / Hive (which is used internally in Athena)?
Should be. if you structure hive table properly, any csv file can be uploaded there.
how can I specify the data type for JSON columns?
in hive you can store as string. Looking at your json structure, you can easily access elements using expression like this - get_json_object(json_col_str,'$.BusinessParking.garage').
Do I have to do this by hand?
I guess so unless you have some auto DDL creation utility. You can put sample rows in xl and find out the table structure easily.
Are the JSONs written OK, or should they be reformatted?
From the example you gave, i checked last row and json object seems fine to me. I also checked using https://jsonformatter.curiousconcept.com/ which validates and formats it in a pretty format. You can use it in case of any discrepancies.
You should be able to query this data with Athena as long as there are no semi-colons inside the JSON columns. Define your table as CSV with semi-colon as separator, and use string as the type of the JSON columns.
When you query this table you can use the JSON functions to query the JSON columns, for example:
SELECT json_extract_scalar(attributes, '$.AcceptsInsurance')
…

Eslint fix command is not fixing all of the vue/html-indent errors

I have some linting rules in my .eslintrc.js which looks like the following:
module.exports = {
root: true,
env: {
browser: true,
es6: true,
node: true,
},
extends: ['plugin:vue/recommended', 'eslint:recommended'],
parserOptions: {
parser: 'babel-eslint',
},
rules: {
'import/extensions': 0,
'import/no-unresolved': 0,
'import/prefer-default-export': 0,
'no-shadow': 0, // TODO: figure out this error in vuex state
'no-param-reassign': 0, // TODO: figure out this error in vuex state
'no-use-before-define': 0, // TODO: figure out this error in vuex state
'no-underscore-dangle': 0,
'no-useless-escape': 0,
semi: [2, 'never'],
'vue/no-v-html': 0,
'vue/custom-event-name-casing': 0,
'vue/html-indent': [
'error',
4,
{
attribute: 1,
baseIndent: 1,
closeBracket: 0,
alignAttributesVertically: true,
ignores: [],
},
],
'vue/script-indent': [
'error',
2,
{
baseIndent: 1,
switchCase: 1,
ignores: [],
},
],
'vue/max-attributes-per-line': [
'error',
{
singleline: 1,
multiline: {
max: 1,
allowFirstLine: true,
},
},
],
'vue/html-closing-bracket-newline': [
'error',
{
singleline: 'never',
multiline: 'never',
},
],
'vue/html-self-closing': [
'error',
{
html: {
void: 'always',
normal: 'always',
component: 'always',
},
svg: 'always',
math: 'always',
},
],
'vue/attribute-hyphenation': ['error', 'always'],
},
}
I have these setup as my workspace settings:
{
"editor.tabSize": 4,
"editor.insertSpaces": false,
"editor.detectIndentation": false,
"vetur.format.options.useTabs": false,
"vetur.format.defaultFormatterOptions": {
"prettyhtml": {
"printWidth": 120,
"singleQuote": true
},
"js-beautify-html": {
"wrap_attributes": "force-aligned",
"indent_size": 4
}
},
"vetur.format.scriptInitialIndent": true,
"vetur.format.styleInitialIndent": true,
"vetur.format.defaultFormatter.js": "prettier-eslint",
"vetur.format.defaultFormatter.html": "js-beautify-html",
"html.format.wrapAttributes": "force",
"vetur.format.defaultFormatter.css": "none",
"vetur.format.defaultFormatter.scss": "prettier",
"editor.formatOnSave": true,
"vetur.validation.template": false,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
}
When I save a file and format everything works fine, the formatting works. But when I run
eslint --fix --ext js,vue src
This shows the lint warnings and errors, but doesn't comply with the vue/html-indent rule.
If the component looks like this:
<transition
name="slide-fade"
mode="in-out">
<div
v-if="showDesktopSearch"
v-on-clickaway="away"
class="desktop-search-component"
:class="positionClass">
This is the body
</div>
</transition>
If I save the component looks like this:
<transition name="slide-fade"
mode="in-out">
<div v-if="showDesktopSearch"
v-on-clickaway="away"
class="desktop-search-component"
:class="positionClass">
This is the body
</div>
</transition>
But if I run the linting command, it looks like this:
<transition
name="slide-fade"
mode="in-out">
<div
v-if="showDesktopSearch"
v-on-clickaway="away"
class="desktop-search-component"
:class="positionClass">
This is the body
</div>
</transition>
I want to fix all of the vue/html-indent errors when running the lint command, but I have been unsuccessful here. How can I get the vetur/eslint format from cli?
This is my .eslintrc.js
module.exports = {
root: true,
env: {
node: true,
browser: true,
},
extends: ['plugin:vue/essential', 'plugin:prettier/recommended', '#vue/prettier'],
rules: {
'eqeqeq': 'off',
'no-plusplus': 'off',
"no-return-assign": "off",
'max-len': ['error', { code: 120, ignoreUrls: true, ignoreComments: true }],
'linebreak-style': 0,
'vue/max-attributes-per-line': 'off',
'vue/component-name-in-template-casing': ['error', 'PascalCase'],
'no-console': 'off',
'no-restricted-syntax': [
'error',
{
selector:
"CallExpression[callee.object.name='console'][callee.property.name!=/^(log|warn|error|info|trace)$/]",
message: 'Unexpected property on console object was called',
},
],
},
parserOptions: {
parser: 'babel-eslint',
},
};
And .prettierrc
{
"semi": true,
"tabWidth": 2,
"useTabs": false,
"printWidth": 100,
"singleQuote": true,
"editor.insertSpaces": true,
"trailingComma": "all",
"bracketSpacing": true,
"jsxBracketSameLine": true,
"arrowParens": "always"
}
And vue.config.js
module.exports = {
devServer: {
host: '0.0.0.0',
port: 3201,
https: false,
disableHostCheck: true,
},
runtimeCompiler: true,
chainWebpack: (config) => {
config.module
.rule('eslint')
.use('eslint-loader')
.options({
fix: true,
});
},
pluginOptions: {
apollo: {
enableMocks: true,
enableEngine: false,
// Cross-Origin options
cors: '*',
},
},
};

VS Code format splitting comma-separated items in JSON file

VS Code wants to split comma separated arguments into separate lines. I would prefer it not do this. It only happens on one machine and I can't discover the setting that makes this happen.
As an example, consider this text in settings.json
"args": [
"-q", "query",
"-a", "answer"
]
I have format-on-save turned on, and every time I save the file, I get this
"args": [
"-q",
"query",
"-a",
"answer"
]
I would prefer that it leave these alone, like on all of my other machines. Please note that I do not want to turn off auto-format, I just want this wrapping behavior to stop.
[New Info]
I copied the User settings ~/Library/Application Support/Code/User/settings.json from the machine that did not have the wrapping issues to the machine that did have the issues. I'm not sure which setting it was, but that fixed the problem. I'd still love to know which setting caused this behavior. Both files are below.
Wrapping Issues Settings
{
"telemetry.enableTelemetry": false,
"editor.minimap.enabled": false,
"files.autoSave": "afterDelay",
"workbench.sideBar.location": "left",
//"editor.wordWrap": "bounded",
"editor.wordWrapColumn": 132,
"editor.wrappingIndent": "deepIndent",
"go.formatTool": "goimports",
"go.liveErrors": {
"enabled": true,
"delay": 500
},
"go.vetOnSave": "workspace",
"go.gocodeAutoBuild": true,
"git.enableCommitSigning": true,
"go.autocompleteUnimportedPackages": true,
"git.autofetch": true,
"git.confirmSync": false,
"editor.formatOnPaste": true,
"editor.formatOnType": true,
"editor.formatOnSave": true,
"python.testing.unittestEnabled": true,
"python.venvPath": "~/develop/virtualenv",
"python.linting.pep8Enabled": true,
"editor.detectIndentation": false,
"search.quickOpen.includeSymbols": true,
"workbench.colorTheme": "Default Light+",
}
No Wrapping Issues Settings
{
"telemetry.enableTelemetry": false,
"window.zoomLevel": 0,
"files.autoSave": "afterDelay",
"editor.fontSize": 14,
"editor.minimap.enabled": false,
"files.exclude": {
"**/.classpath": true,
"**/.project": true,
"**/.settings": true,
"**/.factorypath": true
},
"editor.wordWrap": "on",
"editor.wrappingIndent": "deepIndent",
"editor.wordWrapColumn": 132,
"go.autocompleteUnimportedPackages": true,
"editor.suggestSelection": "first",
"vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
"go.gocodeAutoBuild": true,
"debug.enableAllHovers": true,
"debug.inlineValues": true,
"git.enableCommitSigning": true,
"python.jediEnabled": false,
"[python]": {
},
"python.testing.unittestEnabled": true,
"git.autofetch": true,
"python.venvPath": "~/develop/virtualenv",
"python.linting.pep8Enabled": true,
"editor.detectIndentation": false,
"editor.formatOnPaste": true,
"window.openFilesInNewWindow": "on",
}
Combined settings with duplicates removed
paul-> cat settings.json.old.json settings.json |sort|uniq
"**/.classpath": true,
"**/.factorypath": true
"**/.project": true,
"**/.settings": true,
"delay": 500
"enabled": true,
"[python]": {
"debug.enableAllHovers": true,
"debug.inlineValues": true,
"editor.detectIndentation": false,
"editor.fontSize": 14,
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
"editor.formatOnType": true,
"editor.minimap.enabled": false,
"editor.suggestSelection": "first",
"editor.wordWrap": "on",
"editor.wordWrapColumn": 132,
"editor.wrappingIndent": "deepIndent",
"files.autoSave": "afterDelay",
"files.exclude": {
"git.autofetch": true,
"git.confirmSync": false,
"git.enableCommitSigning": true,
"go.autocompleteUnimportedPackages": true,
"go.formatTool": "goimports",
"go.gocodeAutoBuild": true,
"go.liveErrors": {
"go.vetOnSave": "workspace",
"python.jediEnabled": false,
"python.linting.pep8Enabled": true,
"python.testing.unittestEnabled": true,
"python.venvPath": "~/develop/virtualenv",
"search.quickOpen.includeSymbols": true,
"telemetry.enableTelemetry": false,
"vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
"window.openFilesInNewWindow": "on",
"window.zoomLevel": 0,
"workbench.colorTheme": "Default Light+",
"workbench.sideBar.location": "left",
//"editor.wordWrap": "bounded",
},
{
}
}{
See https://stackoverflow.com/a/73180702/836330 for a similar case.
Enable this setting: JSON > Format: Keep Lines
With that setting enabled - it is coming in v1.70
"args": [
"-q", "query",
"-a", "answer"
]
will stay exactly that way. Lines with multiple values or multiple key/value pairs will be "kept" as is.

sublime text font size on size bar does not change

Using sublime text 3, I have installed the material theme.
But I notice that the sidebar font size is too small.
Following the doc and searching on stack, I have change the default setting in the file named Material-Theme-Darker.sublime-theme and the other one named Default.sublime-theme like this (the two are the same):
[
{"class": "tab_control", "attributes": ["selected", "file_medium_dark"],"tint_modifier": [255, 255, 255, 80]},
{
"class": "sidebar_label",
"color": [0, 0, 0],
"font.bold": false,
"shadow_color": [250, 250, 250], "shadow_offset": [0, 0],
"font.size": 16
},
]
But nothing change. Where am I wrong ?
This my default user setting Preferences.sublime-settings:
{
"always_show_minimap_viewport": true,
"bold_folder_labels": true,
"caret_extra_bottom": 6,
"caret_extra_top": 6,
"caret_style": "phase",
"color_scheme": "Packages/User/SublimeLinter/itg.dark (SL).tmTheme",
"default_encoding": "UTF-8",
"default_line_ending": "unix",
"draw_minimap_border": true,
"ensure_newline_at_eof_on_save": true,
"fade_fold_buttons": false,
"font-face": "Saab",
"font_options":
[
"gray_antialias",
"subpixel_antialias"
],
"font_size": 15.5,
"highlight_line": true,
"highlight_modified_tabs": true,
"ignored_packages":
[
"Vintage"
],
"indent_guide_options":
[
"draw_normal",
"draw_active"
],
"indent_subsequent_lines": true,
"line_padding_bottom": 1,
"line_padding_top": 1,
"match_brackets": true,
"match_brackets_angle": false,
"match_brackets_braces": true,
"match_brackets_content": true,
"match_brackets_square": true,
"match_selection": true,
"material_theme_bold_tab": true,
"material_theme_compact_sidebar": true,
"material_theme_panel_separator": true,
"material_theme_small_tab": false,
"material_theme_tabs_autowidth": true,
"material_theme_tabs_separator": true,
"material_theme_tree_headings": true,
"overlay_scroll_bars": "enabled",
"quick_panel_small": true,
"save_on_focus_lost": true,
"scroll_past_end": true,
"scroll_speed": 1.5,
"shift_tab_unindent": true,
"show_encoding": true,
"show_line_endings": true,
"spell_check": false,
"tab_size": 4,
"theme": "Material-Theme-Darker.sublime-theme",
"translate_tabs_to_spaces": true,
"trim_trailing_white_space_on_save": true,
"word_wrap": true
}

Polymer 1.0 : How to configure jshint for Polymer behaviours?

I have a globalize-behaviour.html file:
<script>
GlobalizeBehavior = {
// https://www.polymer-project.org/1.0/docs/devguide/behaviors.html#definining-behaviors
i18n: function(key) {
return key;
}
};
</script>
I am including this file in other custom-elements like this:
<link rel="import" href="../globalize-behavior/globalize-behavior.html">
and using it like so (in global-element.html):
<script>
(function() {
Polymer({
is: 'global-element',
behaviors: [GlobalizeBehavior],
openAddTransDialog: function() {},
});
})();
</script>
And, here's the .jshintrc file:
{
"node": true,
"browser": true,
"esnext": true,
"bitwise": true,
"camelcase": true,
"curly": true,
"eqeqeq": true,
"immed": true,
"indent": 2,
"latedef": true,
"noarg": true,
"quotmark": "single",
"undef": true,
"unused": true,
"globals": {
"wrap": true,
"unwrap": true,
"Polymer": true,
"Platform": true,
"page": true,
"app": true
}
}
I am getting following error while running jshint:
globalize-behavior.html line 2 col 1 'GlobalizeBehavior' is not defined.
global-element.html line 104 col 17 'GlobalizeBehavior' is not defined.
How can I fix this?
You could add
"globals": {
"GlobalizeBehavior": true
}
or:
"predef": [
"GlobalizeBehavior"
]
to your .jshintrc file?