eslint error in html file: Parsing error: Unexpected token < - html

why eslint give me this error
Parsing error: Unexpected token < in html file?
how can i solve this error?
my .eslint.json configs:
{
"env": {
"browser": true,
"commonjs": true,
"es2021": true
},
"extends": [
"airbnb-base"
],
"parserOptions": {
"ecmaVersion": 12
},
"rules": {
"strict": "off"
}
}

you need eslint-plugin-html to lint html file. the details can be found in this link: https://www.npmjs.com/package/eslint-plugin-html

Adding the below to ".eslintrc.json" file worked for me:
"ignorePatterns": [
"**/*.html"
]

One other option can be to add an .eslintignorefile. See the exmple below.
.eslintignore
.vscode/*
dist/*
assets/*
node_modules/*
**/index.html
**/index.*.html
**/assets/*.html

Related

Editing Prettier options in Vscode

I need to enable .tpl files to be formatted like HTML by Prettier.
I've found on GitHub this block of code who should do it :
overrides: [
{
files: '*.html.tpl',
options: { parser: 'html' },
},
],
How should I implement it?
Go to File -> Preferences -> Settings.
In the search for box, search for "Associations" and then click on "Edit on settings.json".
Add the following to the JSON file:
"files.associations": {
"*.html.tpl": "html"
}
You have multiple options as of the syntax you want to use.
Here is an exemple in JSON:
//.prettierrc.json
{
"semi": false,
"overrides": [
{
"files": "*.html.tpl",
"options": { "parser": "html" },
},
],
}
You have more exemples on the documentation.

Invalid json format, please check. Reason: invalid character 'a' looking for beginning of object key string

could you please assist me here? I have validated JSON but the issue appears.. also the strange thing is that when I create the JSON file with the wizard the issue does not appear. Thank you in advance.
Validate JSON:
{
"agent": {
"metrics_collection_interval": 60,
"run_as_user": "root"
},
"logs": {
"logs_collected": {
"files": {
"collect_list": [
{
"file_path": "/var/log/messages",
"log_group_name": "messages",
"log_stream_name": "{instance_id}"
}
]
}
}
},
"metrics": {
"append_dimensions": {
"AutoScalingGroupName": "${aws:AutoScalingGroupName}",
"ImageId": "${aws:ImageId}",
"InstanceId": "${aws:InstanceId}",
"InstanceType": "${aws:InstanceType}"
},
"metrics_collected": {
"collectd": {
"metrics_aggregation_interval": 60
},
"cpu": {
"measurement": [
"cpu_usage_idle",
"cpu_usage_iowait",
"cpu_usage_user",
"cpu_usage_system"
],
"metrics_collection_interval": 60,
"totalcpu": false
},
"disk": {
"measurement": [
"used_percent",
"inodes_free"
],
"metrics_collection_interval": 60,
"resources": [
"*"
]
},
"diskio": {
"measurement": [
"io_time",
"write_bytes",
"read_bytes",
"writes",
"reads"
],
"metrics_collection_interval": 60,
"resources": [
"*"
]
},
"mem": {
"measurement": [
"mem_used_percent"
],
"metrics_collection_interval": 60
},
"netstat": {
"measurement": [
"tcp_established",
"tcp_time_wait"
],
"metrics_collection_interval": 60
},
"statsd": {
"metrics_aggregation_interval": 60,
"metrics_collection_interval": 10,
"service_address": ":8125"
},
"swap": {
"measurement": [
"swap_used_percent"
],
"metrics_collection_interval": 60
}
}
}
}
sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a append-config -m ec2 -c file:/opt/aws/amazon-cloudwatch-agent/bin/config.json -s
/opt/aws/amazon-cloudwatch-agent/bin/config-downloader --output-dir /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.d --download-source file:/opt/aws/amazon-cloudwatch-agent/bin/config.json --mode ec2 --config /opt/aws/amazon-cloudwatch-agent/etc/common-config.toml --multi-config append
Successfully fetched the config and saved in /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.d/file_config.json.tmp
Start configuration validation...
/opt/aws/amazon-cloudwatch-agent/bin/config-translator --input /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json --input-dir /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.d --output /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.toml --mode ec2 --config /opt/aws/amazon-cloudwatch-agent/etc/common-config.toml --multi-config append
2019/08/26 07:58:17 Reading json config file path: /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json ...
/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json does not exist or cannot read. Skipping it.
2019/08/26 07:58:17 Reading json config file path: /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.d/default ...
2019/08/26 07:58:17 Reading json config file path: /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.d/file_config.json.tmp ...
2019/08/26 07:58:17 Invalid json format, please check. Reason: invalid character 'a' looking for beginning of object key string
2019/08/26 07:58:17 I! AmazonCloudWatchAgent Version 1.223987.0.
2019/08/26 07:58:17 Configuration validation first phase failed. Agent version: 1.223987.0. Verify the JSON input is only using features supported by this version.
I managed to fix the java error this by adding \ in front of the $. Then there was a terraform error message when I used terraform apply and added a second dollar sign to skip the interpolation.
"AutoScalingGroupName": "\$${aws:AutoScalingGroupName}",
"ImageId": "\$${aws:ImageId}",
"InstanceId": "\$${aws:InstanceId}",
"InstanceType": "\$${aws:InstanceType}"
Hope this will help somebody in the future.

Eslint won't respect custom settings of .eslintrc.json

I want to use tab indention instead of spaces while using Airbnb settings in eslint. I have created the .eslintrc.json file using eslint --init in the root of my project
Problem is eslint won't respect the custom settings of this file.
I still get error:
[eslint] Unexpected tab character. (no-tabs)
The error is the same in VS Code, Vim, Sublime.
What am I missing here? According to what I read, this new .eslintrc.json file should work with my custom settings.
.eslintrc.json file:
{
"extends": "airbnb-base",
"env": {
"browser": true,
"node": true
},
"rules": {
"comma-dangle": "off",
"indent": ["error", "tab"],
"no-console": "off"
}
}
I first installed eslint globally and locally
{
"extends": "airbnb",
"env": {
"browser": true,
"node": true
},
"rules": {
"comma-dangle": "off",
"indent": ["error", "tab"],
"no-tabs": 0,
"no-console": "off"
}
}
Needed no-tabs: 0

Cannot parse config file using grunt command for execution

I'm getting an error while working with grunt,
Error cannot parse config file unexpected token in default.json
I tried correcting the code but I'm receiving the same error
This is my default.json file:
{
"Amazon" : {
"lambda-arn" : "arn:aws:lambda:us-east-1:286506727102:function:myPandora",
},
"Pb": {
"url": "https://aiaas.xxx",
"app_id": "1xxxx1",
"user_key": "070xxxxxx",
"botname": "alexa"
},
}
Please help me with this error, Thank you.
Delete the commas at the end of lines 3 and 10 in your JSON to make it valid. E.g.
{
"Amazon": {
"lambda-arn": "arn:aws:lambda:us-east-1:286506727102:function:myPandora"
},
"Pb": {
"url": "https://aiaas.xxx",
"app_id": "1xxxx1",
"user_key": "070xxxxxx",
"botname": "alexa"
}
}

folder path in sublime text build system

My sublime project looks like this:
{
"folders":
[
{
"folder_exclude_patterns":
[
".bzr",
"build",
"webapps",
"work",
".settings"
],
"path": "/home/charles/project/Editor/trunk"
}
],
"settings":
{
"build_on_save": true,
"filename_filter": "\\.(java)$",
"tab_size": 4,
"translate_tabs_to_spaces": false
},
"build_systems":
[
{
"name": "compile",
"cmd": ["ant", "-f", "dev.xml", "compile"]
}
]
}
When I save a file the console says:
Buildfile: dev.xml does not exist!
Build failed
[Finished in 0.2s with exit code 1]
I know that I need to put something before dev.xml but I don't know what.
I found some possibilities here: http://sublimetext.info/docs/en/reference/build_systems.html#variables
But What I need is the folder path "/home/charles/project/Editor/trunk" in my case...
Any idea how I can achieve this?
You are missing "working_dir" in your "build_systems" setup. The example below will use the directory that holds the sublime project file as the build starting directory.
"build_systems":
[
{
"name": "compile",
"working_dir": "${project_path}",
"cmd": ["ant", "-f", "dev.xml", "compile"]
}
]
More information can be found at: http://www.sublimetext.com/docs/2/projects.html