How to configure Prettier formatter - vscode plugin inconsistent with npm module installed - visual-studio-code

I'm using Prettier 1.14.0 with Prettier Formatter for Visual Studio Code. I've encountered problem with inconstancy of function arguments formatting.
For example demands me to keep string compose(field('tags'), orEmpty, commaList, usertag())()(user), inline while the second one forces it to be like this
compose(
field('tags'),
orEmpty,
commaList,
usertag(),
)()(user),
I want both to be like the second case. It looks like parser does not apply in package.json...
Here are some pieces of configs:
package.json
"prettier": {
"parser": "flow",
"printWidth": 80
},
"eslintConfig": {
"parser": "babel-eslint",
"extends": [
"standard",
"prettier",
"plugin:import/recommended"
],
"plugins": [
"prettier",
"simple-complexity",
"import",
"import-order-autofix",
"filenames"
],
"settings": {
"import/resolver": "webpack",
"import/ignore": [
"node_modules"
]
},
"rules": {
"filenames/match-exported": [
"error"
],
"import-order-autofix/order": [
"error",
{
"newlines-between": "always"
}
],
"prettier/prettier": [
"error",
{
"parser": "flow",
"printWidth": 80,
"singleQuote": true,
"trailingComma": "all",
"bracketSpacing": false,
"semi": false,
"requirePragma": true,
"insertPragma": true
}
],
"comma-dangle": [
"error",
{
"arrays": "always-multiline",
"objects": "always-multiline",
"imports": "always-multiline",
"exports": "always-multiline",
"functions": "always-multiline"
}
],
"complexity": [
"error",
{
"max": 15
}
],
"max-nested-callbacks": [
"error",
{
"max": 3
}
],
"max-statements": [
"error",
{
"max": 10
}
],
"max-params": [
"error",
{
"max": 4
}
],
"max-lines": [
"error",
{
"max": 350,
"skipBlankLines": true,
"skipComments": true
}
],
"max-depth": [
"error",
{
"max": 3
}
],
"simple-complexity/max-indent": [
"error",
{
"max": 20
}
]
}
},
.eslintrc
{
"extends": "react-app",
"plugins": [
"prettier",
"simple-complexity",
"import",
"import-order-autofix",
"filenames"
],
"rules": {
"filenames/match-exported": ["error"],
"import-order-autofix/order": [
"error",
{
"newlines-between": "always"
}
],
"prettier/prettier": [
"error",
{
"singleQuote": true,
"trailingComma": "all",
"bracketSpacing": false,
"semi": false,
"requirePragma": true,
"insertPragma": true
}
],
"comma-dangle": [
"error",
{
"arrays": "always-multiline",
"objects": "always-multiline",
"imports": "always-multiline",
"exports": "always-multiline",
"functions": "always-multiline"
}
],
"complexity": [
"error",
{
"max": 15
}
],
"max-nested-callbacks": [
"error",
{
"max": 3
}
],
"max-statements": [
"error",
{
"max": 10
}
],
"max-params": [
"error",
{
"max": 4
}
],
"max-lines": [
"error",
{
"max": 350,
"skipBlankLines": true,
"skipComments": true
}
],
"max-depth": [
"error",
{
"max": 3
}
],
"simple-complexity/max-indent": [
"error",
{
"max": 20
}
]
}
}
.vscode/settings
{
"[javascript]": {
"editor.formatOnSave": true,
},
"prettier.eslintIntegration": true,
"editor.tabSize": 2,
"files.watcherExclude": {
"**/.git/objects/**": true,
"**/.git/subtree-cache/**": true,
"**/node_modules/*/**": true
},
}

Related

Eslint + typescript paths aliasing with craco Unable to resolve path to module '#SomeFolder/SomeComponent'

can someone pls explain to me why I am still getting the error when I'm using
import SomeComponent from '#someFolder/SomeComponent';
this is my error
Unable to resolve the path to module '#SomeFolder/SomeComponent'
this is part of my esLint
"settings": {
"import/resolver": {
"alias": {
"map": [["#", "./src"], ["#someFolder", "./src/components/SomeFolder/*"]],
"extensions": [".ts", ".tsx", ".js", ".jsx", ".json"]
},
}
}
and this is part of my craco.config
webpack: {
alias: {
'#convertor': path.resolve(__dirname, `src/convertors`),
'#someFolder': path.resolve(__dirname, `src/components/SomeFolder`),
},
},
jest: {
configure: {
moduleNameMapper: {
'^#someFolder(.*)$': '<rootDir>/src/components/SomeFolder',
},
},
}, webpack: {
alias: {
'#convertor': path.resolve(__dirname, `src/convertors`),
'#someFolder': path.resolve(__dirname, `src/components/SomeFolder`),
},
},
jest: {
configure: {
moduleNameMapper: {
'^#someFolder(.*)$': '<rootDir>/src/components/SomeFolder',
},
},
},
this is tsconfig.paths.json
{
"compilerOptions": {
"baseUrl": "src",
"paths": {
"#someFolder/*": [ "src/components/SomeFolder/*" ],
"#convertor/*": [ "src/convertors/*" ],
}
}
}
this is full eslingrc
{
"plugins": ["import"],
"extends": [
"airbnb-typescript-prettier",
"plugin:react/recommended",
"plugin:import/recommended",
"plugin:import/typescript"
],
"rules": {
"no-param-reassign": ["error", {
"props": true,
"ignorePropertyModificationsFor": [
"state"
]
}],
"#typescript-eslint/no-explicit-any": 0,
"#typescript-eslint/no-empty-function": 0,
"#typescript-eslint/camelcase": 0,
"#typescript-eslint/no-unused-vars": "warn",
"#typescript-eslint/ban-ts-comment": "warn",
"#typescript-eslint/no-shadow": "warn",
"#typescript-eslint/ban-types": 0,
"react/jsx-props-no-spreading": 0,
"#typescript-eslint/no-use-before-define": 0,
"jsx-a11y/alt-text": 0,
"max-classes-per-file": ["error", 10],
"prettier/prettier": [
"warn",
{
"endOfLine": "auto"
}
],
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx", ".ts", ".tsx"] }],
"react/prop-types": 0,
"react/jsx-no-bind": 0,
"react/destructuring-assignment": "warn",
"react/require-default-props": "warn",
"react/react-in-jsx-scope": 0,
"react/button-has-type": 0,
"react/no-array-index-key": "warn",
"react/display-name": 0,
"jsx-a11y/click-events-have-key-events": 0,
"jsx-a11y/no-noninteractive-element-interactions": 0,
"jsx-a11y/no-static-element-interactions": 0,
"jsx-a11y/anchor-is-valid": 0,
"react-hooks/exhaustive-deps": "warn",
"radix": ["error", "as-needed"],
"no-nested-ternary": "warn",
"no-plusplus": 0,
"import/prefer-default-export": 0,
"import/order": "warn",
"import/extensions": "warn",
"import/no-cycle": 0,
"consistent-return": 0,
"camelcase": "warn",
"guard-for-in": 0,
"no-restricted-syntax": 0,
"no-debugger": 1
},
"overrides": [
{
"files": ["**/*.test.js", "**/*.test.jsx", "**/*.test.ts", "**/*.test.tsx"],
"env": {
"jest": true
}
}
],
"settings": {
"import/resolver": {
"alias": {
"map": [["#", "./src"], ["#someFolder", "./src/components/SomeFolder/*"]],
"extensions": [".ts", ".tsx", ".js", ".jsx", ".json"]
},
"node": {
"paths": ["src"],
"extensions": [".js", ".jsx", ".ts", ".tsx"]
}
}
}
}
PS pls don't suggest disabling import/no-unresolved. this isn't fixing problem it's just ignoring it

Inserting data in private ipfs network from outside of server throws timeout error

I installed private ipfs network on my server and after that i tested it with entering a file and getting it which works perfectly,now when i try to follow the same steps from my local machine,getting data is working with the url - http://{server's ip}:8080/ipfs/{hash} but when i created api on Nodejs to insert data using url - http://{server's ip}:5001 then i am getting the error of timeout,though this api is working on deploying on server and changing the server's ip to localhost.
IPFS config is as follows -
{
"API": {
"HTTPHeaders": {
"Access-Control-Allow-Methods": [
"PUT",
"GET",
"POST"
],
"Access-Control-Allow-Origin": [
"*"
]
}
},
"Addresses": {
"API": "/ip4/0.0.0.0/tcp/5001",
"Announce": [],
"Gateway": "/ip4/0.0.0.0/tcp/8080",
"NoAnnounce": [],
"Swarm": [
"/ip4/0.0.0.0/tcp/4001",
"/ip6/::/tcp/4001"
]
},
"Bootstrap": [
"/ip4/{server's ip}/tcp/4001/ipfs/<peer identity hash of bootnode>"
],
"Datastore": {
"BloomFilterSize": 0,
"GCPeriod": "1h",
"HashOnRead": false,
"Spec": {
"mounts": [
{
"child": {
"path": "blocks",
"shardFunc": "/repo/flatfs/shard/v1/next-to-last/2",
"sync": true,
"type": "flatfs"
},
"mountpoint": "/blocks",
"prefix": "flatfs.datastore",
"type": "measure"
},
{
"child": {
"compression": "none",
"path": "datastore",
"type": "levelds"
},
"mountpoint": "/",
"prefix": "leveldb.datastore",
"type": "measure"
}
],
"type": "mount"
},
"StorageGCWatermark": 90,
"StorageMax": "10GB"
},
"Discovery": {
"MDNS": {
"Enabled": true,
"Interval": 10
}
},
"Experimental": {
"FilestoreEnabled": false,
"Libp2pStreamMounting": false,
"P2pHttpProxy": false,
"QUIC": false,
"ShardingEnabled": false,
"UrlstoreEnabled": false
},
"Gateway": {
"APICommands": [],
"HTTPHeaders": {
"Access-Control-Allow-Headers": [
"X-Requested-With",
"Range"
],
"Access-Control-Allow-Methods": [
"GET"
],
"Access-Control-Allow-Origin": [
"*"
]
},
"PathPrefixes": [],
"RootRedirect": "",
"Writable": false
},
"Identity": {
"PeerID": "<peer identity hash of bootnode>"
},
"Ipns": {
"RecordLifetime": "",
"RepublishPeriod": "",
"ResolveCacheSize": 128
},
"Mounts": {
"FuseAllowOther": false,
"IPFS": "/ipfs",
"IPNS": "/ipns"
},
"Pubsub": {
"DisableSigning": false,
"Router": "",
"StrictSignatureVerification": false
},
"Reprovider": {
"Interval": "12h",
"Strategy": "all"
},
"Routing": {
"Type": "dht"
},
"Swarm": {
"AddrFilters": null,
"ConnMgr": {
"GracePeriod": "20s",
"HighWater": 900,
"LowWater": 600,
"Type": "basic"
},
"DisableBandwidthMetrics": false,
"DisableNatPortMap": false,
"DisableRelay": false,
"EnableRelayHop": true
}
}

Google smart home action always failing on command execution

I am developing fanSpeed and colorSetting trait for Google Actions, but whenever I execute command for setting fan speed or setting light colour, it fails. Here is my JSON for sync,query and execute step:
sync
{
"requestId":"d25ty67q-98jui-581aa-j891-b1f6dhuas"
"payload":{
"devices": [
{
"id": "AA96A0#16",
"type": "action.devices.types.FAN",
"traits": [
"action.devices.traits.OnOff",
"action.devices.traits.FanSpeed"
],
"roomHint": "ROOM",
"deviceInfo": {
"manufacturer": "smart Homes"
},
"name": {
"defaultNames": [
"fan"
],
"name": "fan"
},
"willReportState": true,
"customData": {
},
"attributes": {
"commandOnlyOnOff": false,
"commandOnlyFanSpeed": false,
"reversible": false,
"availableFanSpeeds": {
"speeds": [
{"speed_name": "speed_low", "speed_values": [{"speed_synonym": ["low", "low speed", "slow"], "lang": "en"}]},
{"speed_name": "speed_medium", "speed_values": [{"speed_synonym": ["medium", "medium speed", "med"], "lang": "en"}]},
{"speed_name": "speed_high", "speed_values": [{"speed_synonym": [ "high speed", "high"], "lang": "en"}]},
{"speed_name": "speed_highest", "speed_values": [{"speed_synonym": [ "highest speed", "highest"], "lang": "en"}]}
],
"ordered": true
}
}
},
{
"id": "240A50#0",
"type": "action.devices.types.LIGHT",
"traits": [
"action.devices.traits.OnOff",
"action.devices.traits.ColorSetting"
],
"roomHint": "ROOM",
"deviceInfo": {
"manufacturer": "smart Homes"
},
"name": {
"defaultNames": [
"light"
],
"name": "light"
},
"willReportState": false,
"customData": {
},
"attributes": {
"commandOnlyColorSetting": true,
"colorModel": "hsv"
}
}
],
"agentUserId": "Home555"
}
}
Execute Fan:
{
"commands": [
{
"ids": [
"AA96A0#16"
],
"status": "SUCCESS",
"states": {
"online": true,
"on": true,
"currentFanSpeedSetting": "speed_highest"
}
}
]
}
Query Fan:
{
"requestId":"167278043664013971",
"payload":{
"devices": {
"AA96A0#16": {
"status": "SUCCESS",
"online": true,
"on": true,
"currentFanSpeedSetting": "speed_highest"
}
}
}
}
Execute color-light:
{
"commands": [
{
"ids": [
"240A50#0"
],
"status": "SUCCESS",
"states": {
"online": true,
"on": true,
"color": {
"spectrumHSV": {
"hue": 120,
"saturation": 1,
"value": 1
}
}
}
}
]
}
Query color-light:
{
"requestId":"167278043664013971",
"payload":{
"devices": {
"240A50#0": {
"status": "SUCCESS",
"online": true,
"on": true,
"color": {
"spectrumHSV": {
"hue": 0,
"saturation": 0,
"value": 1
}
}
}
}
}
}
Speaker response: Sorry, it looks like smart homes is unavailable right now.
However my request is always executing and I can see state change on my device. Can anyone point out Why it is failing?
The json for execute for both the fan and the bulb has missing values for requestId. This might be causing the failures with the execution commands.

ESlint - #connect react-redux unexpected character

I have a problem with configuring ESlint:
I have this code:
#connect((store) => {
return {
user: store.user.user,
userFetched: store.user.fetched,
tweets: store.tweets.tweets,
};
})
and I can't find a way to configure ESlint, so it does not throw an 'Unexpected token' for the '#connect'.
This is my '.eslintrc.json':
{
"env": {
"browser": true,
"commonjs": true,
"es6": true
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaFeatures": {
"experimentalObjectRestSpread": true,
"jsx": true
},
"sourceType": "module"
},
"plugins": [
"react"
],
"rules": {
"indent": [
1,
2
],
"linebreak-style": [
0,
"unix"
],
"quotes": [
1,
"double"
],
"semi": [
2,
"always"
]
}
}
Can someone help me with this problem?
I am most certain that there is a plugin for that but I can't find one.
Thanks!

Need help in mongodb $pull

I have a mongodb document that is like this:
{
"_id": ObjectId("5231718f042f8bc215000007"),
"ApplicationId": "YVo9bEQiDLg2",
"Network": {
"Millennial Media": {
"Active": true,
"RefreshInterval": 300000,
"NetworkId": 352,
"App": [
{
"AppId": "APID - Banner",
"AppValue": "76970",
"Priority": 100
}
]
},
"Buzzcity": {
"Active": true,
"RefreshInterval": 300000,
"NetworkId": 353,
"App": [
{
"AppId": "Partner ID",
"AppValue": "80624",
"Priority": 100
}
]
},
"Adiquity": {
"Active": true,
"RefreshInterval": 300000,
"NetworkId": 354,
"App": [
{
"AppId": "package",
"AppValue": "com.ristomobile.giftntake",
"Priority": 0
},
{
"AppId": "Site ID",
"AppValue": "adqkkqkk-14eo91zj-qv6qt",
"Priority": 100
},
{
"AppId": "appName",
"AppValue": "Gift&Take",
"Priority": 0
}
]
},
"Smaato": {
"Active": true,
"RefreshInterval": 300000,
"NetworkId": 351,
"App": [
{
"AppId": "Adspace ID",
"AppValue": "65766605",
"Priority": 100
}
],
"Partner": [
{
"PartnerId": "Publisher ID",
"PartnerValue": "923862008"
}
]
},
"AdNear": {
"Active": true,
"RefreshInterval": 300000,
"NetworkId": 367,
"Partner": [
{
"PartnerId": "pubid",
"PartnerValue": "rs-1328"
},
{
"PartnerId": "api_key",
"PartnerValue": "RSW78:QH8HHM389M7YP"
}
]
},
"twinpine": {
"Active": true,
"RefreshInterval": 300000,
"NetworkId": 371,
"Partner": [
{
"PartnerId": "pid",
"PartnerValue": "1551a74d1df075a"
},
{
"PartnerId": "alid",
"PartnerValue": "405"
}
]
},
"Vserv.mobi": {
"Active": true,
"RefreshInterval": 300000,
"NetworkId": 370,
"Partner": [
{
"PartnerId": "Zone Id",
"PartnerValue": "32024"
},
{
"PartnerId": "Publisher Id",
"PartnerValue": "12649"
}
]
}
},
"LastUpdate": ISODate("2013-06-24T01:44:22.865Z")
}
and i tried to pull away the Millenial Media data:
db.MediationSetup.update(
{
ApplicationId: "YVo9bEQiDLg2"
},
{
$pull: {
Network: {
"Millennial Media": {
"Active": true,
"RefreshInterval": 300000,
"NetworkId": 352,
"App": [
{
"AppId": "APID - Banner",
"AppValue": "76970",
"Priority": 100
}
]
}
}
}
})
but it gives
Cannot apply $pull/$pullAll modifier to non-array
I am puzzled, I am indeed pulling an array! so what is going on?
When I understood you correctly, you want to remove an entry from the array in Network.Millennial Media.App. In that case you have to reference a field nested in sub-documents by using the dot-notation:
db.MediationSetup.update(
{
ApplicationId: "YVo9bEQiDLg2"
},
{
$pull: { "Network.Millennial Media.App": {
"AppId": "APID - Banner",
"AppValue": "76970",
"Priority": 100
}
}
});