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

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: '*',
},
},
};

Related

update data in vue with method and axios

I want to display a graph on my web interface. I want to implement the web interface with vue js. For this I pass data from my backend to my frontend with axios. I can display an empty graph on my rsurface. But the data I pass is not displayed. What is wrong with my code that my data is not displayed on the graph.
In the following you can see my implemented code.
<b-container class="ml-auto">
<b-row>
<b-col>
<vue-plotly :data="dataA" :layout="layout" :options="options"/>
</b-col>
</b-row>
</b-container>
export default {
components: {
VuePlotly,
},
data() {
return {
dataA: [{
x: [],
y: [],
}],
layout: {
title: 'ScreePlot',
bargap: 0.05,
xaxis: {
range: [0, 9],
title: 'x',
tick0: 0,
dtick: 1,
},
yaxis: {
range: [0, 2000],
title: 'y',
tick0: 0,
dtick: 1,
},
},
options: {
displayModeBar: false,
responsive: true,
watchShallow: true,
autoResize: true,
},
};
},
mounted() {
this.getScreePlot();
},
methods: {
getScreePlot() {
const path = 'http://localhost:5000/Diagramm';
axios.get(path)
.then((res) => {
this.dataA.x = res.data.x;
this.dataA.y = res.data.y;
})
.catch((error) => {
// eslint-disable-next-line
console.error(error);
});
},
},
};
In case this definition
dataA: [{
x: [],
y: [],
}],
You should fill like this:
.then((res) => {
this.dataA.push(
{
x: res.data.x,
y: res.data.y
}) ;
})

Gulp cannot parse .hintrc file

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.

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?

json help. correct my json

I want to know where my json is incorrect... I know that there is a syntax error so please correct it for me.
({
ageRestriction: false,
allowedCountries: [
],
user: {
ip: '184.173.107.5',
name: ''
},
player: {
bufferTime: 60,
debug: false,
window: false,
panel: false,
autoplay: true,
smoothing: true,
scale: 'letterbox'/*none,
stretch,
letterbox,
zoom*/,
iframeControl: false
},
similar: {
path: '/actions/control/similaritems/50e54d84d681c00e603935e3',
preview: '//s.dogannet.tv/q/i/76/600x336/50e54e8cd681c00e603935e4'
},
watermark: {
path: '//s.dogannet.tv/n/s/content/images/watermark.png?v=2',
position: 'bottomright'
},
media: {
id: '50e54d84d681c00e603935e3',
controller: 'osmf',
defaultServiceUrl: 'http: //media.netd.com.tr',
serviceUrl: 'http: //37.48.66.141',
path: 'S1/HLS_VOD/5ea1_1536/index.m3u8?key=49bfee85b05d117a2906368428094e94&app=com.dcom&max=1500',
preview: '//s.dogannet.tv/q/i/76/1600x900/50e54e8cd681c00e603935e4'
},
playlog: {
callback: function(data){
data.Application='com.dcom';data.UserName='';data.SessionId='m443qmsgz3mdlnwing2h4qno';data.AnonymId='d241c910-6ae1-4f73-afc4-7cb5991517d4';data.ItemId='50e54d84d681c00e603935e3';data.Url='http: //www.netd.com/diziler/yerli/kanit/kanit-1-sezon/kanit-1-bolum';data.extraData={
'Agent': navigator.userAgent
};$.ajax({
type: "POST",
url: "http://stats.dogannet.tv/playlog.ashx",
data: data,
global: false,
async: true,
cache: false
});
}
},
heartbeat: {
interval: 10000,
callback: function(data){
data.Application='com.dcom';data.UserName='';data.SessionId='m443qmsgz3mdlnwing2h4qno';data.AnonymId='d241c910-6ae1-4f73-afc4-7cb5991517d4';data.ItemId='50e54d84d681c00e603935e3';data.Url='http: //www.netd.com/diziler/yerli/kanit/kanit-1-sezon/kanit-1-bolum';data.SessionId='m443qmsgz3mdlnwing2h4qno';data.extraData={
'Agent': navigator.userAgent
};$.ajax({
type: "POST",
url: "http://stats.dogannet.tv/heartbeat.ashx",
data: data,
global: false,
async: false,
cache: false
});
}
},
gemius: {
materialIdentifier: '1',
identifier: 'AfVAtKMRq0Ff4WlROmmKr7Po31j_P7s.VdXOiWt3SGL.x7',
hitCollector: 'http: //str.hit.gemius.pl'
},
comscore: {
c1: '1',
c2: '17476642'
},
advert: {
display: true,
skipShowDuration: 9,
preroll: 'http: //app.medyanetads.com/vast.a2?target=netd_videoad_arsivdizi_preroll&channel=50e54d84d681c00e603935e3&category=11534404&keywords=kanit,
prof_dr_sevil_atasoy,
engin_benli,
inci_demirkaya,
deniz_celiloglu&videoid=463_50e54d84d681c00e603935e3',
midroll: 'http: //app.medyanetads.com/vast.a2?target=netd_videoad_arsivdizi_midroll&channel=50e54d84d681c00e603935e3',
postroll: 'http: //app.medyanetads.com/vast.a2?target=netd_videoad_arsivdizi_postroll&channel=50e54d84d681c00e603935e3',
overlay: 'http: //app.medyanetads.com/vast.a2?target=netd_videoad_arsivdizi_overlay&channel=50e54d84d681c00e603935e3',
pauseroll: 'http: //app.medyanetads.com/vast.a2?target=netd_videoad_pauseroll&channel=50e54d84d681c00e603935e3',
viscaleShowDuration: 30,
viscaleRatio: 0.3889,
viscale: "http://app.medyanetads.com/vast.a2?target=netd_videoad_viscale&channel=52fddcab68f7320be461c2e9"
},
survey: {
display: true,
path: 'http: //app.medyanetads.com/survey/survey.swf',
domain: 'netd.com'
}
});
});
PLEASE CORRECT I dont know where is mistake. I wanted to correct it with http://jsonlint.com/ But I can't done
You should wrap your keys inside double quotes like this:
{
"ageRestriction": false,
"allowedCountries": [
],
"user": {
"ip": "184.173.107.5"
...
If your values are also strings, then they should also be inside double quotes, like in the example above.
See here the exact specification: http://www.json.org/

Highcharts load date values in X axis

I have a Highcharts chart which gets it's data from a JSON request.
function slowips(target){
var options = {
chart: {
renderTo: target,
type: 'spline',
borderColor: '#0072C6',
borderWidth: 3
},
title: {
text: 'Responsetime'
},
subtitle: {
text: 'Nr.1 is slowest'
},
legend: {
enabled: true,
layout: 'vertical',
align: 'right',
verticalAlign: 'middle'
},
yAxis: {
title: {
text: 'Milliseconds'
},
min: 0
},
exporting: {
enabled: false
},
credits: {
enabled: false
},
xAxis: {
type: 'datetime',
dateTimeLabelFormats: {
month: '%e. %b',
year: '%Y'
},
labels: {
enabled: true,
},
minorTickLength: 0,
tickLength: 0,
},
plotOptions: {
spline: {
animation: false,
enableMouseTracking: false,
marker: {
enabled: false
}
}
},
series: [{}]
};
$.getJSON('graphs/test.php', function(data) {
options.series = data;
var chart = new Highcharts.Chart(options);
});
}
slowips();
This is an example JSON input:
[ { "name":"sddf", "data": [ ["2013-02-01 00:01:00", 2 ], ["2013-02-02 00:02:00", 2.55 ] ] } ]
Also tried:
[ { "name":"sddf", "data": [ [Date.UTC(12, 3, 09), 2 ], [Date.UTC(12, 3, 10), 2.55 ] ] } ]
The first JSON example renders a chart, but with incorrect X axis data. The second JSON does not render the chart.
Please help out!
You need to use timestamps, so when you load first JSON, then you need to parse it by Date.UTC() / Data.parse(), but functions cannot be places in json inside (as you have in second example).