Take a babel config using the env preset, like this:
{
"presets": [
["env", {
"targets": {
"node": "10.6"
},
"modules": false
}]
]
}
In this case, the target is Node 10.6 with the --experimental-modules flag enabled.
I'm curious to see the list of actual Babel plugins the above config would resolve to. Is there some way to do this? (Not just for this case, but for any Babel config.)
Related
I saw a colleague in webShtom highlighting of unused exports, how to enable this in VS Code?
The screenshot pretty much shows what you need: ESLint + TypeScript ESLint plugin + the no-unused-vars lint rule.
The minimal .eslintrc.json config file for this might look similar to this:
{
"root": true,
"extends": [
"eslint:recommended",
"plugin:#typescript-eslint/recommended"
],
"parser": "#typescript-eslint/parser",
"parserOptions": {
},
"plugins": [
"#typescript-eslint"
],
"rules": {
"#typescript-eslint/no-unused-vars": ["warn"],
}
}
Note that TypeScript itself supports emitting warnings / errors for unused local variables via its noUnusedLocals tsconfig setting.
My eslint parser as for now is #typescript-eslint/parser. I want to use #babel/plugin-proposal-optional-chaining plugin, which requires babel-eslint parser.
I saw the eslint-multiple-parsers but it says that it was deprecated :
Use ESLint configuration based on glob patterns (overrides). See https://eslint.org/docs/user-guide/configuring/#configuration-based-on-glob-patterns.
How can I set multiple parses that way?
From the Configuration Based on Glob Patterns
A glob specific configuration works almost the same as any other ESLint config. Override blocks can contain any configuration options that are valid in a regular config, with the exception of root and ignorePatterns.
In your eslint config file you can add an overrides section which is an array of objects. Each object is required to have files key where you define the glob pattern. Any file which match will then use the overriden config. Example:
{
// estree parser
"env": {
"es6": true
},
"extends": [
"eslint:recommended",
"plugin:security/recommended"
],
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"plugins": [
"security"
],
"rules": {
"indent": [ "error", 4 ]
},
// rest of your "normal" configuration here
"overrides": [{
// for files matching this pattern
"files": ["*.ts"],
// following config will override "normal" config
"parser": "babel-eslint",
"parserOptions": {
// override parser options
},
"plugins": [
"#babel/plugin-proposal-optional-chaining"
],
"rules": [
// override rules
],
},
}]
}
However if you already use #typescript-eslint/parser then you probably already match *.ts files, and overriding would only make every *.ts file use babel-eslint instead, which doesn't solve your issue.
I assume you want both parsers (typescript-eslint and babel) to run against same file, but I don't know easy solution for that.
Is your goal to run parser A against files X and parser B against files Y?
#enterthenamehere-bohemian’s anwser is the solution.
Is your goal to run both parsers against the same files?
It depends…
Is your eslint running inside your editor?
As of today, I can see no solution inside a single eslint config file. You would need a single config file if you want to run it inside your editor.
Is your eslint running in your commandline or Continuous Integration environment?
You need three config files.
File .eslintrc.json
{
"parser": "#typescript-eslint/parser",
"extends": ["./eslint-common-rules.json"],
"rules": {
…typescript parser rules here
}
…
}
File .eslintrc.babel.json
{
"parser": "babel-eslint",
"extends": ["./eslint-common-rules.json"],
"rules": {
…babel parser rules here
}
…
}
File eslint-rules.json
{
"rules": { …
…common eslint rules here
}
…
}
Having that, you can run both in your comanndline:
eslint # <- runs .eslintrc.json
eslint --config .eslintrc.babel.json
Despite clearly indicating in esignore that I want to ignore everything inside lib directory, vscode is saying 9 problems found in that minimized file.
If I run eslint inside foldera in command line everything is fine
using this extension
My directory structure:
foldera/
.eslintrc
.eslintignore
src/
file.js
lib/
wantoignore.min.js
folderb/
morefiles.js
.eslintrc
.eslintignore
.eslintrc file
{
"env": {
"browser": true,
"commonjs": true,
"es6": true
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 2017,
"ecmaFeatures": {
"experimentalObjectRestSpread": true,
"jsx": true
},
"sourceType": "module"
},
"plugins": [
"react"
],
"rules": {
"no-console": "off"
}
}
.eslintignore
lib/*
workspace settings:
"eslint.workingDirectories": [
"./client", "./server"
]
I solved this problem following the official doc here.
Basically you need to add the following content to the vscode workspace settings (usually located in your project's root/.vscode/settings.json), so that vscode knows which configs to honor when you're working on a specific script file:
{
"eslint.workingDirectories": [ "./reactApp" ],
}
I had a similar problem, figured out need to set workingDirectory to nested folder:
module
lib
src
index.ts
.eslintrc.js
.eslintignore
VSCode setting should be:
"eslint.workingDirectories": [ "./module/lib" ]
And not
"eslint.workingDirectories": [ "./module" ]
My solutions is:
Source map
root/.vscode/settings.json
Script
{
"eslint.workingDirectories": [{ "mode": "auto" }],
}
I'm writing a node application, where I would like to mix Reason and raw JavaScript.
This section in the bucklescript documentation describes it
When user has an existing JS project, it makes sense to output the JS
file in the same directory as vanilla JS, the schema added a key
called in-source so that generate JS file next to ML file.
I assume that this is in the bsconfig.json file? But what value should the key have? The schema documentation does not mention this option.
I'm running Bucklescript version 1.9.1 - so the functionality should be available (available since 1.9.0).
How do I use the in-source option?
My bsconfig.json file looks like this:
{
"name": "re-server",
"version": "0.1.0",
"bsc-flags": ["-bs-super-errors"],
"in-source": true, // I tried adding the key here
"sources": [{
"dir": "src",
"in-source": true // I tried adding the key here
}
],
"bs-dependencies" : [
"bs-express"
]
}
It should be in the "package-specs" section:
{
...
"package-specs" : [{
"module": ...,
"in-source": true
}]
}
So your bsconfig.json should look like:
{
"name": "re-server",
"version": "0.1.0",
"bsc-flags": ["-bs-super-errors"],
"package-specs" : [{
"module": "commonjs",
"in-source": true
}],
"sources": [{
"dir": "src"
}
],
"bs-dependencies" : [
"bs-express"
]
}
i am trying to use the openui5-googlemaps library, but the WebIDE looks at a different path than my SAP-System then the app is deployed.
libs: ["sap.m", "sap.ui.layout", "sap.ushell", "openui5.googlemaps"],
my SAP-System looks at path resources/openui5/googlemaps.
However this does not work in the WebIDE.
Any ideas why and how i can fix it?
Thanks
Either change the path, or load via your index.
API With Example
In Index
~ update may 2017 ~
You can now use the manifest to add libraries:
"resources": {
"css": [
{
"uri": "css/style.css"
},
{
"uri": "css/croppie.css"
}
],
"js": [
{
"uri": "library/croppie.min.js"
}
]