Eslint won't respect custom settings of .eslintrc.json - 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

Related

vscode launch.json configuration

I have an issue with launch a cpp project file with vscode, here is my error
launch program {workspace domain}\build\Debug\outDebug does not exist.
and that's true, but i want to know can I add a parameter to my launch.json file or edit it, to work like : if a there is no directory to put the build file into it, so make it!
is it possible to do that ?
here is my launch.json file source
{
"version": "0.2.0",
"configurations": [
{
"name": "C/C++ Runner: Debug Session",
"type": "cppdbg",
"request": "launch",
"args": [],
"stopAtEntry": false,
"cwd": "o:\\Developing\\Projects\\Training\\c++\\School",
"environment": [],
"program": "o:\\Developing\\Projects\\Training\\c++\\School\\build\\Debug\\outDebug",
"internalConsoleOptions": "openOnSessionStart",
"MIMode": "gdb",
"miDebuggerPath": "gdb",
"externalConsole": false,
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
See docs:
https://code.visualstudio.com/docs/cpp/launch-json-reference
May be there is solve.

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

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

PhpStorm: what are php-cs-fixer files and how to ignore them

I keep getting "Multiple definitions exist for class..." warnings in PhpStorm, and upon inspection, I see these a bunch of these huge php-cs-fixer files (100K+ lines) with the comment "This file is part of PHP CS Fixer.".
I found that there are multiple copies of several other files named phploc, composer, php-scoper, etc., under vendor/library_name/tools/ in various libraries for some reason. They are all huge compiled files that PhpStorm detects.
I tried ignoring these files in PhpStorm one by one, and once re-indexing finishes, these files disappear, leading me to believe they're IDE-generated files. However, it makes no sense the IDE would generate them and in turn include them hinting code.
composer.json
{
"name": "magento/project-community-edition",
"description": "eCommerce Platform for Growth (Community Edition)",
"type": "project",
"license": [
"OSL-3.0",
"AFL-3.0"
],
"config": {
"preferred-install": "dist",
"sort-packages": true
},
"require": {
"magento/composer-root-update-plugin": "~1.0",
"magento/product-community-edition": "2.4.1"
},
"require-dev": {
"allure-framework/allure-phpunit": "~1.2.0",
"dealerdirect/phpcodesniffer-composer-installer": "^0.5.0",
"friendsofphp/php-cs-fixer": "~2.16.0",
"lusitanian/oauth": "~0.8.10",
"magento/magento-coding-standard": "*",
"magento/magento2-functional-testing-framework": "^3.0",
"pdepend/pdepend": "~2.7.1",
"phpcompatibility/php-compatibility": "^9.3",
"phpmd/phpmd": "^2.8.0",
"phpstan/phpstan": ">=0.12.3 <=0.12.23",
"phpunit/phpunit": "^9",
"sebastian/phpcpd": "~5.0.0",
"squizlabs/php_codesniffer": "~3.5.4"
},
"conflict": {
"gene/bluefoot": "*"
},
"autoload": {
"psr-4": {
"Magento\\Framework\\": "lib/internal/Magento/Framework/",
"Magento\\Setup\\": "setup/src/Magento/Setup/",
"Magento\\": "app/code/Magento/",
"Zend\\Mvc\\Controller\\": "setup/src/Zend/Mvc/Controller/"
},
"psr-0": {
"": [
"app/code/",
"generated/code/"
]
},
"files": [
"app/etc/NonComposerComponentRegistration.php",
"app/helper.php"
],
"exclude-from-classmap": [
"**/dev/**",
"**/update/**",
"**/Test/**"
]
},
"autoload-dev": {
"psr-4": {
"Magento\\Sniffs\\": "dev/tests/static/framework/Magento/Sniffs/",
"Magento\\Tools\\": "dev/tools/Magento/Tools/",
"Magento\\Tools\\Sanity\\": "dev/build/publication/sanity/Magento/Tools/Sanity/",
"Magento\\TestFramework\\Inspection\\": "dev/tests/static/framework/Magento/TestFramework/Inspection/",
"Magento\\TestFramework\\Utility\\": "dev/tests/static/framework/Magento/TestFramework/Utility/",
"Magento\\PhpStan\\": "dev/tests/static/framework/Magento/PhpStan/"
}
},
"version": "2.4.0",
"minimum-stability": "stable",
"repositories": [
{
"type": "composer",
"url": "https://repo.magento.com/"
}
],
"extra": {
"magento-force": "override"
}
}
PhpStorm ignored files (adding php-cs-fixer and phploc here somehow removed all/multiple copies from the vendor directories):
These files are in your vendor directory as you must have install your dependencies from sources, not distributions.
Let's use sebastian/code-unit as an example to see how it works:
the file obviously is in the repository: https://github.com/sebastianbergmann/code-unit/tree/1.0.8/tools
but excluded from being exported to distribution (the archive file you are actually downloading from GitHub when installing package): https://github.com/sebastianbergmann/code-unit/blob/1.0.8/.gitattributes#L6 - you can see that it's not present in file you download from https://github.com/sebastianbergmann/code-unit/releases/tag/1.0.8
So, you must have install your dependencies using composer install --prefer-source (or composer update --prefer-source as it's the other command with that option) and you want to use --prefer-dist or actually not using any of these flags as the latter is the default. You can find more information about it in official documentation: https://getcomposer.org/doc/03-cli.md#install-i
Remove your vendor directory and install dependencies once more without --prefer-source flag.
AFAIR there was also an issue when you did not have curl extension installed, then simply add this extension.

In vscode errors generated by a task with isWatching are not always cleared after they have been fixed

I'm using a gulp task in vscode (0.9) to try to get errors from both typescript and tslint.
The gulp task is watching for changes on my ts files and run both the gulp-tslint and gulp-typescript on changes.
I also defined a task in vscode tasks.json and problem matchers to parse the results.
The errors are parsed and reported correctly into vscode.
However they are sometimes kept even when code is fixed and saved.
Is there some additional config to provide to vscode problem matcher so that it clear errors properly or is it a vscode bug?
As a workaround is there a way to manually clear all errors? The only way I found to clear them is to restart vscode which is not great.
Note that this works fine if the task is not a watch task but a simple execution.
My vscode tasks.json
{
"version": "0.1.0",
"command": "gulp",
"isShellCommand": true,
"tasks": [
{
"taskName": "watch",
// Make this the default build command.
"isBuildCommand": true,
// Watching
"isWatching": true,
// Show the output window only if unrecognized errors occur.
"showOutput": "always",
// Use the standard less compilation problem matcher.
"problemMatcher": [
{
"owner": "gulp-tslint",
"fileLocation": [
"relative",
"${workspaceRoot}/app"
],
"pattern": {
"regexp": ".*\\[gulp-tslint\\] (error|warning) (.*)\\[(\\d*), (\\d*)\\]: (.*)",
"severity": 1,
"file": 2,
"line": 3,
"column": 4,
"message": 5
}
},
{
"owner": "gulp-typescript",
"fileLocation": "absolute",
"pattern": {
"regexp": "\\[gulp-typescript\\] (.*)\\((\\d*),(\\d*)\\): (error|warning) (.*)",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
]
}
]
}
My gulp task definition:
const tslint = require('gulp-tslint');
const typescript = require('gulp-typescript');
gulp.task('watch', function () {
gulp.watch(srcTsFiles, ['tslint', 'compile']);
});
gulp.task('tslint', function () {
return gulp.src(srcTsFiles)
.pipe(tslint())
.pipe(tslint.report('prose', {
emitError: false,
summarizeFailureOutput: true
}));
});
var tsProject = typescript.createProject('tsconfig.json');
gulp.task('compile', function () {
tsProject.src()
.pipe(typescript(tsProject, undefined, typescript.reporter.longReporter()))
.pipe(gulp.dest('dist'));
});
This is a bug in VSCode. Somehow, it doesn't apply any updates to open files. If the files are closed, any obsolete errors are removed.
So, the workaround is to click the little "close all files" icon in the "Working Files" header.
If you want to figure out yourself what the problem is, look into the JS files in the VSCode resources; in OSX, those reside in the application package. Look for workbench.main.js. You will find the tsc-watch problem matcher in there, and it will have applyTo:c.ApplyToKind.closedDocuments set. I tried to change that to allDocuments, but to no avail.
This is fixed in the latest insider build (I tested it) and will likely go into production next week.
https://github.com/Microsoft/vscode/issues/909

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