I'm trying to configure my tslint to allow submodules from the Parse
library ( https://www.npmjs.com/package/parse-js ) so I can use parse/react-native
, but it doesn't work.
I have tried to do add both "no-submodule-imports": [true, "parse", "parse/react-native"]
and "no-submodule-imports": false
in my tslint but I still get the following error:
ERROR: src/App.tsx:2:19 - Submodule import paths from this package are disallowed; import from the root instead
The declaration in @types/parse
for this submodule in node_modules is:
declare module "parse/node" {
export = Parse;
}
declare module "parse" {
import * as parse from "parse/node";
export = parse
}
declare module "parse/react-native" {
import * as parse from "parse/node";
export = parse
}
The code does work fine, but if I run tslint I get that error. I tried different combinations of it and still have the issue.
Here's what my tslint.json looks like:
{
"extends": [
"tslint:latest",
"tslint-react",
"tslint-react-a11y",
"tslint-config-prettier"
],
"no-submodule-imports": [true, "parse", "parse/react-native"],
"import-blacklist": false,
"defaultSeverity": "error",
"rules": {
"ban": {
"options": [
["_", "extend", "use object spread: { ...a, ...b }"],
["_", "isNull", "use plain JS: == null"],
["_", "isDefined", "use plain JS: != null"],
["Object", "assign", "use object spread: { ...a, ...b }"],
["Object", "getOwnPropertyNames", "use Object.keys()"],
["describe", "only", "should not be committed to repo"],
["it", "only", "should not be committed to repo"],
["test", "only", "should not be committed to repo"]
]
},
"no-object-literal-type-assertion": false,
"ordered-imports": [
true,
{
"import-sources-order": "any",
"named-imports-order": "any"
}
],
"no-any": true,
"interface-over-type-literal": false,
"linebreak-style": {
"options": ["LF"]
},
"quotemark": [true, "single"],
"jsx-boolean-value": ["never"],
"member-access": [true],
"no-console": false,
"no-implicit-dependencies": false,
"no-invalid-this": {
"options": ["check-function-in-method"]
},
"interface-name": false,
"max-classes-per-file": false,
"jsx-no-lambda": false,
"no-trailing-whitespace": true,
"no-this-assignment": [
true,
{
"allow-destructuring": true
}
],
"no-unnecessary-callback-wrapper": false,
"no-unnecessary-initializer": true,
"object-literal-sort-keys": false,
"prefer-conditional-expression": false,
"variable-name": {
"options": [
"allow-leading-underscore",
"allow-pascal-case",
"ban-keywords",
"check-format"
]
},
"member-ordering": [
true,
"private-before-public",
"static-before-instance",
"variables-before-functions"
],
"trailing-comma": [
true,
{
"multiline": "always",
"singleline": "never",
"esSpecCompliant": true
}
]
},
"jsRules": {
"object-literal-sort-keys": false
},
"linterOptions": {
"exclude": [
"/**/packages/newrelic-webpack-plugin/embedded.js",
"/**/coverage/**/*",
"/**/*.json",
"/**/build/**/*"
]
}
}
Thanks in advance for the help.
I ran across this also. It looks like for an angular project the rule needs to be in the tslint file inside of the src folder.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.