In vue component it is possible to use keyPrefix of i18n in order to use a shorter path to the translated key.
So, for example if my lang file looks like that:
{"a":{"b":{"c":{"placeholder": "my placeholder"}}}}
and in my vue component, set i18nOptions like that:
export default {
i18nOptions: {
keyPrefix: 'a.b.c',
},
I am able to consume the key like that:
$t(`placeholder`)
it works great! the problem is that eslint won't allow that (#intlify/vue-i18n/no-missing-keys)
I didn't find any way to teach eslint to handle that correctly...
did anyone manage to do it?
Related
I'm writing a nuxt module following this guide.
Now I would like my module to add a proxy rule to the host application. Its a lot of guesswork and nothing has done the trick so far. I tried
nuxt.options.proxy.options.push(
{
target: 'https://target-url.com',
changeOrigin: true,
pathFilter: ['path/to/match']
}
)
}
but my IDE complains that proxy is not a known property of NuxtOptions. I did shorten the above code for the sake of this post. In my code I also made sure the respective objects exist before assigning something to them.
next best guess (based on the example for adding a css library) was to do the same thing, but on the runtimeConfig like so:
nuxt.options.runtimeConfig.proxy.options.push(...)
no complaints by the IDE anymore (duh, the runtimeConfig object is of type any) but no sign of the proxy actually working.
In deno you can load related modules or other code by just referencing the relative path to those ES6 modules. Deno will handle loading them appropriately. What's the way to do this for non-es6 modules? For example: say I wanted to include some custom css with my deno project? Deno doesn't allow doing import mycss from "./relative.css";.
Deno file operations do work for local files, but they're evaluated relative to the cwd not the current file, and they don't work for arbitrary URLs. fetch, on the other hand, should be perfect, but currently doesn't support file schemes and the decision isn't being actively considered. Combining these yields the only solution I can come up with, but I really don't like it:
async function loadLocal(relative: string): Promise<string> {
const url = new URL(relative, import.meta.url);
if (url.protocol === 'file:') {
return await Deno.readTextFile(url.pathname);
} else {
const resp = await fetch(url.href);
return await resp.text();
}
}
This seems like it should mostly work, but it seems like a terrible way to hack in something that I expected would be supported by design in deno. It also must be redeclared in each file, or have the callers URL passed in, although there might be a way to avoid that. It doesn't work on windows without modifying the path delimiter.
Update
Deno.emit seems close to what I would want, however for some reason it has different behavior than standard importing:
If the rootSpecifier is a relative path, then the current working directory of the Deno process will be used to resolve the specifier. (Not relative to the current module!)
It also still requires that the paths be to valid modules, instead of arbitrary text.
As #Zwiers pointed out, deno 1.6 now supports fetch with the file protocol, so this is now irrelevant.
Some modules just seem to be invisible to Flow. For example I have react-native-overlay installed via npm into my node_modules directory but I get a whole bunch of errors like this from Flow:
[js/components/DatePickerOverlay.js:18
18: let Overlay = require('react-native-overlay');
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ react-native-overlay. Required module not found
This module doesn't have types so it would be fine if I could just get Flow to ignore it entirely.
Here's my .flowconfig (based on React Native's one):
https://gist.github.com/almost/20c6caf6d18d0e5c689f
As you can see I'm on flow 0.20.1 and I have module.system=haste (as required by React Native)
I tried adding a //$FlowIgnore comment to the import lines but then Flow complains about an unneeded ignore comment! I also tried creating a react-native-flow.js.flow file with a dummy export which seemed to work at first but then after a flow restart stopped working.
Any ideas for how to either help Flow find this module or make it ignore the import line completely?
Looks like you're ignoring it here: https://gist.github.com/almost/20c6caf6d18d0e5c689f#file-flowconfig-L42-L50
If you don't mind manually typing it up, add a react-native-overlay.js to your interfaces and type up a couple signatures.
This is happening because the library doesn't exist in flow-typed.
A simple fix could be creating the following entry in the .flowconfig file:
[ignore]
<PROJECT_ROOT>/libdefs.js
[libs]
./libdefs.js
If using flowtype < 0.60.0 add in libdefs.js
// #flow
declare module "react-native-overlay" {
declare var exports: any;
}
Or if using flowtype > 0.60.0
declare module 'react-native-overlay' {
declare module.exports: any;
}
Note: any is an unsafe type so you can always take advantage of improve the definition of the library
Hope that helps,
I am using urigo:angular2-meteor. When I add an empty main.ts in server folder, it always shows:
Cannot compile namespaces when the '--isolatedModules' flag is
provided.
Even I added the code below on the top of main.ts, it still shows same thing.
/// <reference path="../typings/angular2-meteor.d.ts" />
I faced similar issue in react + ts. I had commented out all my code.
Turns out
A global file cannot be compiled using '--isolatedModules'. Ensure your file contains imports, exports, or an 'export {}' statement.
So, added something like:
export const foo = 'foo';
or
export {}
It's a temporary solution, else you can delete the file with commented code or update tsconfig.json
I had the same problem and I added tsconfig.json into the root directory of my project.
{
"compilerOptions": {
"isolatedModules": false
}
}
I didn't have the time to dive into it, but it solved the problem.
I was getting this error when file was not imported in any other file.
Importing it in any other file (import {} from "/the-filename-having-compilation-error"), removed this error.
I had the same problem. I was made a component and never use that. When I imported that component In one of my page and use that and RERUN the project again , error was disappear.
This error occurs mostly when working with React + TypeScript
Simplest Solution for the same is to add 'export' keyword before the class creation or export the class in the end using
export default className;
If you have eslint installed check the rules section in .eslintrc.json file for any contradicting action.If the action you perforned is against the rule defined then error appears.
In a .eslintrc file, we can use:
"extends": "eslint:recommended"
to extend the recommended rules provided by eslint, and in the rule list, many of them are marked as "recommended".
My question what is the exact rule definitions for them? I searched in the repo of eslint, but not found it.
Freewind's answer is pointing to a specific commit – now outdated.
The current eslint:recommended rules can be found at github.com/eslint/eslint/blob/master/conf/eslint-recommended.js.
Run this terminal command from the project root to output a complete list of definitions being applied in your setup.
./node_modules/.bin/eslint --print-config *.* > "./.eslintrc.js_fullsettings.js"
If you only have extends: ['eslint:recommended'] in the .eslint file you'll get what you're looking for.
All entries with a checkmark in this list: https://eslint.org/docs/rules/
There's a list here.
Old answer
Eslint no longer shows the list of recommended rules in a single file, so here's a way to get the current list with Node.js:
const { Linter } = require('eslint')
const rules = [...new Linter().getRules().entries()] // all rules
.filter(data => data[1].meta.docs.recommended) // filter out unrecommended
.map(data => data[0]) // get rule names
console.log(rules.join('\n'))
Here's a live example that can also create an object that basically represents the entire recommended config, a handy markdown chart, or just a simple list of rule names if that's what you need.
From the source code, I found:
https://github.com/eslint/eslint/blob/3642d0bb6ced17eeed50c030531a3ddbeb939f29/lib/config.js#L189-L192
So the real config is here: https://github.com/eslint/eslint/blob/3642d0bb6ced17eeed50c030531a3ddbeb939f29/conf/eslint.json