I use the swagger plugin from nestjs to annotate all dto models for swagger, but it selects the *.entity.ts models too.
My nest-cli.json:
{
"$schema": "https://json.schemastore.org/nest-cli",
"collection": "#nestjs/schematics",
"sourceRoot": "src",
"compilerOptions": {
"plugins": [
{
"name": "#nestjs/swagger",
"options": {
"dtoFileNameSuffix": [".dto.ts"]
}
}
]
}
}
Is there any way I can force the plugin to ignore the entity models?
Related
I have created a NX plugin/lib named nx.
The plugin's package.json defines the linting target:
"lint": {
"executor": "#nrwl/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": [
"libs/nx/executors.json",
"libs/nx/package.json",
"libs/nx/src/executors",
"libs/nx/src/generators"
]
}
}
The .eslintrc.json is:
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"]
}
The extended .eslintrc.json is:
{
"root": true,
"ignorePatterns": ["**/*"],
"plugins": ["#nrwl/nx"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {
"#nrwl/nx/enforce-module-boundaries": [
"error",
{
"enforceBuildableLibDependency": true,
"allow": [],
"depConstraints": [
{
"sourceTag": "*",
"onlyDependOnLibsWithTags": ["*"]
}
]
}
]
}
},
{
"files": ["*.ts", "*.tsx"],
"extends": ["plugin:#nrwl/nx/typescript"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"extends": ["plugin:#nrwl/nx/javascript"],
"rules": {}
},
{
"files": "*.json",
"parser": "jsonc-eslint-parser",
"rules": {}
}
]
}
The problem is that the generator dir contains templates for generating ts apps and each app has its own .eslintrc.json file. So when I run linting for some reason it parses these files resulting in an error:
Failed to load config "../../.eslintrc.base.json" to extend from.
Referenced from:
[...]/libs/nx/src/generators/application/template/.eslintrc.json
I tried to update the ignorePatterns of my config
{
"ignorePatterns": ["!**/*", "**/*.eslintrc.json"]
}
but without success. How can I solve this problem?
How can I prefix the file, css, and assets in a Vite manifest.json file with a CDN URL?
export default defineConfig({
base: 'https://my-cdn.com/',
build: {
manifest: true,
rollupOptions: {
input: '/path/to/main.js'
}
}
})
but the end result is:
{
"main.js": {
"file": "assets/main.4889e940.js",
"src": "main.js",
"isEntry": true,
"dynamicImports": [],
"css": ["assets/main.b82dbe22.css"],
"assets": ["assets/asset.0ab0f9cd.png"]
}
}
instead of:
{
"main.js": {
"file": "https://my-cdn.com/assets/main.4889e940.js",
"src": "main.js",
"isEntry": true,
"dynamicImports": [],
"css": ["https://my-cdn.com/assets/main.b82dbe22.css"],
"assets": ["https://my-cdn.com/assets/asset.0ab0f9cd.png"]
}
}
To achieve that, you need to add a base property with the URL or path in the project.json file under targets/build/options.
Here is an example project.json config file:
{
"name": "app",
"$schema": "node_modules/nx/schemas/project-schema.json",
"sourceRoot": "./src",
"projectType": "application",
"targets": {
"build": {
"executor": "#nrwl/vite:build",
"outputs": ["{options.outputPath}"],
"defaultConfiguration": "production",
"options": {
"outputPath": "dist/app",
"base": "https://my-cdn.com"
}
}
}
}
And if you are using vite without NX, then you can provide a base argument to the vite build command.
An example:
vite build --base="https://my-cdn.com"
I'm writing up some API documentation for a Node/Express app with JSDoc. I have a simple configuration file set up when running jsdoc ./routes -c config.json:
{
"source": {
"includePattern": ".+\\.js(doc)?$",
"excludePattern": "(^|\\/|\\\\)_"
},
"tags": {
"allowUnknownTags": true,
"dictionaries": ["jsdoc", "closure"]
},
"plugins": ["plugins/markdown"],
"templates": {
"cleverLinks": true,
"monospaceLinks": true
},
"opts": {
"destination": "docs",
"recurse": true,
"readme": "README.md"
}
}
The command outputs a folder /docs with fonts, scripts, styles, and index.html. Is there a way to configure JSDoc to exclude outputting all directories besides a simple HTML file?I was thinking something like:
"output": {
"exclude": ["fonts", "scripts", "styles"]
}
I use create-react-app and just want to add rules to my package.json. I see that I can disable this rule, but how? In the official document, only the phrase "If you don't want to enforce a style for using equality operators, then it's safe to disable this rule."
https://github.com/eslint/eslint/blob/master/docs/rules/eqeqeq.md#when-not-to-use-it
I found that i can write this:
// package.json
{
"name": "mypackage",
...,
"eslintConfig": {
"rules": {
"eqeqeq": "off"
}
}
}
but it not works.
I would like to clarify the question. The reason for my question here is not that I don't know how to disable the rule, I do not know how to disable it in the package.json. I just don't want to clutter up the project's root directory with an additional file.
you can add an eslint configuration file .eslintrc and disable the rules you want inside it.
docs
{
"root": true,
"ignorePatterns": [
"projects/**/*"
],
"overrides": [
{
"files": [
"*.ts"
],
"parserOptions": {
"project": [
"tsconfig.json",
"e2e/tsconfig.json"
],
"createDefaultProgram": true
},
"extends": [
"plugin:#angular-eslint/recommended",
"plugin:#angular-eslint/template/process-inline-templates"
],
"rules": {
"#angular-eslint/directive-selector": [
"error",
{
"type": "attribute",
"prefix": "app",
"style": "camelCase"
}
],
"#angular-eslint/component-selector": [
"error",
{
"type": "element",
"prefix": "app",
"style": "kebab-case"
}
]
}
},
{
"files": [
"*.html"
],
"extends": [
"plugin:#angular-eslint/template/recommended"
],
"rules": {
"#angular-eslint/template/eqeqeq": "off"
}
}
]
}
Look at the last rule
Now as how to turn it to "smart" rather than "off" I'm yet to figure that out.
** Notice how its in the "files": [.html] or "files": [.ts]. I put mine in the .html rules because my errors were in html files but if they were in a ts file I'd put the rule there instead.
EDIT 1: I found this website useful https://github.com/nrwl/nx-examples/blob/master/.eslintrc.json
Go to your project root folder (where is packaje.json) and create a file named .eslintrc.json
Inside this add the following:
{
"rules": {
"eqeqeq": "off",
}
}
Then re launch the app and the rule should be disabled.
You may locate the eslint configuration file, and change eqeqeq rule to off:
eqeqeq: 'off',
Also, make sure that you don't override the setting farther.
Go to .eslintrc.js then add
rules: {
eqeqeq: 'off',
},
I have followed the loopback offline sync example and create my own model with embedded document.
I created a Model named Project where ProjectMembers are embedded model. Here are my model:
Project.json
{
"name": "Project",
"base": "PersistedModel",
"strict": "throw",
"persistUndefinedAsNull": true,
"trackChanges": true,
"properties": {
...
},
"relations": {
"members": {
"type": "embedsMany",
"model": "ProjectMember",
"property": "members",
"options": {
"validate": true,
"forceId": false
}
}
}
}
ProjectMember.json
{
"name": "ProjectMember",
"base": "Model",
"idInjection": true,
"properties": {
...
},
"validations": [],
"relations": {},
"acls": [],
"methods": []
}
In the server side model-config.json I updated the datasource as below:
"Project": {
"dataSource": "my_db"
},
"ProjectMember": {
"dataSource": "transient"
}
And in the client side in lbclient/models/ I added 2 files local-project.json and remote-project.json as exactly same as local-todo.json and remote-todo.json.
I updated the client side model-config.json file as below:
"RemoteProject": {
"dataSource": "remote"
},
"LocalProject": {
"dataSource": "local"
}
In the client controller I run the following codes:
ProjectModel.create($scope.project)
.then(function(project) {
var owner = loginDetails.getLoginUser();// the member
owner.role = 'owner';
owner.status = 'active';
project.members.create(owner); //shows error: couldn't read property
$scope.project = {};
$scope.$apply();
});
It creates the Project but failed to create the embedded model. It displays "Couldn't read property create undefined"? Is there any way to create embedded model in the client side?
UPDATE
The embedded model works only on server side. But when the browserify create the browse.bundle.js, it fails to add the embedded model.
I followed the trial and error method and has come to a solution about offline embedded model.
As previously,I only defined the relations between Project and ProjectMember in the "common/models/" directory. What I find is, I have to define the relations in the client side model too. So I did the following steps and it works.
I created a json file - "lbclient/models/local-project-member.json".
{
"name": "LocalProjectMember",
"base": "ProjectMember"
}
Added the following lines in "lbclient/model-config.json".
"LocalProjectMember":{
"dataSource": "local"
}
Modified the "lbclient/models/local-project.json" file as below.
{
"name": "LocalProject",
"base": "Project",
"relations":{
"members": {
"type": "embedsMany",
"model": "LocalProjectMember",
"property": "memberList",
"options": {
"persist": true,
"validate": true,
"forceId": false
}
}
}
}
So the conclusion is if you want your embedded model work on offline you have to redefine the relations in the client side model.