I'm trying to configure eslint for #material-ui with this specific case:
I'd like to import just so: import Typography from '#material-ui/core/Typography';
and disable import like: import { Typography } from '#material-ui/core';
I have configured the no-restricted-imports rule to:
"no-restricted-imports": [
"error",
{
"patterns": ["#material-ui/core", "!#material-ui/core/*"]
}
]
In my logic it should work like: disable all imports from #material-ui/core except #material-ui/core/*. What am I doing wrong and how to configure it to my case?
I used path:
{
...
"no-restricted-imports": [
"error",
{
paths: [
{ name: "#material-ui/core", message: "no named import from material ui core" },
{ name: "#material-ui/lab", message: "no named import from material ui lab" },
],
},
],
}
Related
i'm trying to deploy a hello world smart contract to testnet. This is the contract I'm trying to deploy:
./contracts/NonFungibleToken.cdc
pub contract NonFungibleToken {
// Declare a stored state field in HelloWorld
//
pub let greeting: String
// Declare a function that can be called by anyone
// who imports the contract
//
pub fun hello(): String {
return self.greeting
}
init() {
self.greeting = "Hello World!"
}
}
This is my config file (flow.json):
{
"emulators": {
"default": {
"port": 3569,
"serviceAccount": "emulator-account"
}
},
"contracts": {
"NonFungibleToken": "./contracts/NonFungibleToken.cdc"
},
"networks": {
"emulator": "127.0.0.1:3569",
"mainnet": "access.mainnet.nodes.onflow.org:9000",
"testnet": "access.devnet.nodes.onflow.org:9000"
},
"accounts": {
"emulator-account": {
"address": "f8d6e0586b0a20c7",
"key": "privatekey"
},
"testnet-account": {
"address": "0x2ca684c2732d60e6",
"key": "privatekey"
}
},
"deployments": {
"emulator": {
"emulator-account": [
"NonFungibleToken"
]
},
"testnet": {
"testnet-account": [
"NonFungibleToken"
]
}
}
}
When I try to deploy, this is the error I get:
MacBook-Air:nft-app alberthu$ flow project deploy
❌ Config Error: deployment contains nonexisting contract NonFungbileToken
Does anyone know how to fix this issue?
Ah the problem was that I needed to add the --network=testnet flag
flow project deploy --network=testnet
In my react project when I use in:
//package.json
"name": "app"
then intellisense is not working for absolute path imports
//SomeComponent.js
import {StorageKeys} from 'app/Constants' // inellisense don't work
import {StorageKeys} from '../../Constants' // intellisense works
Tried some suggestions regarding "jsconfig.json" and setting compiler's base url but with no success.
Any Idea?
{
"compilerOptions": {
"target": "ES6",
"baseUrl": "./",
"paths" : {
"app/*" : ["./*"]
}
},
"exclude": [
"node_modules",
"**/node_modules/*"
]
}
I'm trying to setup axios in a Rollup's project but I can't make it works. I have uploaded an example to Github:
Github repo
As you can see, I have made many configurations but it doesn't works. This is my rollup.config.js:
import resolve from '#rollup/plugin-node-resolve';
import commonjs from '#rollup/plugin-commonjs';
import json from '#rollup/plugin-json';
import builtins from 'rollup-plugin-node-builtins';
import globals from 'rollup-plugin-node-globals';
import babel from 'rollup-plugin-babel';
// import pkg from './package.json';
export default {
input: 'src/index.js',
output: {
file: 'dist/bundle.js',
format: 'umd',
},
external: ['axios'],
plugins: [
commonjs({
browser: false,
namedExports: {
'axios': ['axios']
}
}),
resolve({
browser: true,
preferBuiltins: false
}),
builtins(),
globals(),
babel({exclude: 'node_modules/**', runtimeHelpers: true}),
json()
]
}
This is a bundle for browser, right?
The order of plugins is important, and for me this is perfectly working:
[
json(),
replace({ options }),
nodeResolve({ preferBuiltins: true, browser: true }),
commonjs({ options }),
babel({ options }),
]
I am trying to give the option to customise a VS Code Extension with user defined settings (configuration) of their preferred quote style. I have configured it in my package.json:
"contributes": {
"configuration": {
"type": "object",
"title": "Jasmine code snippets configuration",
"properties": {
"jasmineSnippets.quoteStyle": {
"type": "string",
"enum": [
"'",
"\"",
"`"
],
"default": "'",
"description": "Code snippets quote style"
}
}
}
},
And can access it in my settings.json like this:
"jasmineSnippets.quoteStyle": "`"
How can I now use that value in my snippets.json file? For this snippet, for example, I want to change the hardcoded ` to the configured property.
"it": {
"prefix": "it",
"body": "it(`${1:should behave...}`, () => {\n\t$2\n});",
"description": "creates a test method",
"scope": "source.js"
},
All I could find from the docs is not helpful as it assumes you're reading it from a JavaScript file not a JSON file:
You can read these values from your extension using vscode.workspace.getConfiguration('myExtension').
I think this requires implementing a CompletionItemProvider and returning the snippet from that, rather than statically declaring it in a JSON. Here's an example of what that might look like:
'use strict';
import * as vscode from 'vscode';
export function activate(context: vscode.ExtensionContext) {
vscode.languages.registerCompletionItemProvider('javascript', {
provideCompletionItems(doc, pos, token, context) {
var quote = vscode.workspace.getConfiguration('jasmineSnippets').get("quoteStyle", "`");
return [
{
label: "it",
insertText: new vscode.SnippetString(
`it(${quote}\${1:should behave...}${quote}, () => {\n\t$2\n});`),
detail: "creates a test method",
kind: vscode.CompletionItemKind.Snippet,
},
];
}
});
}
And then with "jasmineSnippets.quoteStyle": "\"" in the settings:
How can I use the Airbnb JavaScript styling guide without using any additional tools? I already installed Tern (Tern IDE) for my Eclipse oxygen. I downloaded the latest release of the eslint-config-airbnb-base-v12.0.1 and selected under
Project -> Properties -> Tern ->Validation -> ESLint the .eslintrc file from the release. My Tern configuration is stored in a .tern-project file:
{
"ecmaVersion": 6,
"plugins": {
"guess-types": {
},
"outline": {
},
"eslint": {
"configFile": "C:\\dev\\workspace\\pyqt_web\\eslint-config-airbnb-base\\.eslintrc"
},
"browser-extension": {
},
"bootstrap": {
}
},
"libs": [
"browser",
"jquery"
]
}
The .eslintrc looks like:
{
"extends": "./index.js",
"rules": {
// disable requiring trailing commas because it might be nice to revert to
// being JSON at some point, and I don't want to make big changes now.
"comma-dangle": 0
},
}
and index.js:
module.exports = {
extends: [
'./rules/best-practices',
'./rules/errors',
'./rules/node',
'./rules/style',
'./rules/variables',
'./rules/es6',
'./rules/imports',
].map(require.resolve),
parserOptions: {
ecmaVersion: 2017,
sourceType: 'module',
ecmaFeatures: {
experimentalObjectRestSpread: true,
},
},
rules: {
strict: 'error',
},
};
From here i dont know how to go further. I would expect, that i get new warning which match these of airbnb style guide. Would this work for js code in html files?