Run eslint on models generated by tests
This commit is contained in:
parent
f52ba8f4c4
commit
57c6c307b0
@ -36,7 +36,7 @@ module.exports = {
|
||||
settings: {
|
||||
"import/resolver": {
|
||||
node: {
|
||||
extensions: [".js", ".jsx", ".ts", ".tsx"]
|
||||
extensions: [".ts"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
16
package-lock.json
generated
16
package-lock.json
generated
@ -274,12 +274,28 @@
|
||||
"resolved": "https://registry.npmjs.org/@types/color-name/-/color-name-1.1.1.tgz",
|
||||
"integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ=="
|
||||
},
|
||||
"@types/eslint": {
|
||||
"version": "6.1.3",
|
||||
"resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-6.1.3.tgz",
|
||||
"integrity": "sha512-llYf1QNZaDweXtA7uY6JczcwHmFwJL9TpK3E6sY0B18l6ulDT6VWNMAdEjYccFHiDfxLPxffd8QmSDV4QUUspA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/estree": "*",
|
||||
"@types/json-schema": "*"
|
||||
}
|
||||
},
|
||||
"@types/eslint-visitor-keys": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz",
|
||||
"integrity": "sha512-OCutwjDZ4aFS6PB1UZ988C4YgwlBHJd6wCeQqaLdmadZ/7e+w79+hbMUFC1QXDNCmdyoRfAFdm0RypzwR+Qpag==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/estree": {
|
||||
"version": "0.0.41",
|
||||
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.41.tgz",
|
||||
"integrity": "sha512-rIAmXyJlqw4KEBO7+u9gxZZSQHaCNnIzYrnNmYVpgfJhxTqO0brCX0SYpqUTkVI5mwwUwzmtspLBGBKroMeynA==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/events": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/events/-/events-3.0.0.tgz",
|
||||
|
@ -45,6 +45,7 @@
|
||||
"@types/chai": "^4.2.7",
|
||||
"@types/chai-as-promised": "^7.1.2",
|
||||
"@types/chai-subset": "^1.3.3",
|
||||
"@types/eslint": "^6.1.3",
|
||||
"@types/fs-extra": "^8.0.1",
|
||||
"@types/handlebars": "^4.1.0",
|
||||
"@types/inquirer": "^6.5.0",
|
||||
|
@ -13,7 +13,7 @@ import { {{toEntityName .}} } from './{{toFileName .}}'
|
||||
{ name: "{{name}}", referencedColumnName: "{{toPropertyName referencedColumnName}}" },
|
||||
{{/inline}}
|
||||
{{#*inline "Relation"}}
|
||||
@{{relationType}}(()=>{{toEntityName relatedTable}},{{toEntityName relatedTable}}=>{{toEntityName relatedTable}}.{{toPropertyName relatedField}}{{#if relationOptions}},{ {{json relationOptions}} }{{/if}})
|
||||
@{{relationType}}(()=>{{toEntityName relatedTable}},{{toEntityName relatedTable}}_=>{{toEntityName relatedTable}}_.{{toPropertyName relatedField}}{{#if relationOptions}},{ {{json relationOptions}} }{{/if}})
|
||||
{{#if joinColumnOptions}}@JoinColumn([{{#joinColumnOptions}}{{> JoinColumnOptions}}{{/joinColumnOptions}}]){{/if}}
|
||||
{{#joinTableOptions}}@JoinTable({ name:"{{name}}", joinColumns:[{{#joinColumns}}{{> JoinColumnOptions}}{{/joinColumns}}],inverseJoinColumns:[{{#inverseJoinColumns}}{{> JoinColumnOptions}}{{/inverseJoinColumns}}],{{#database}}database:"{{.}}",{{/database}}{{#schema}}schema:"{{.}}"{{/schema}} }){{/joinTableOptions}}
|
||||
{{printPropertyVisibility}}{{toPropertyName fieldName}}{{strictMode}}:{{toRelation (toEntityName relatedTable) relationType}};
|
||||
|
30
test/configs/.eslintrc.js
Normal file
30
test/configs/.eslintrc.js
Normal file
@ -0,0 +1,30 @@
|
||||
module.exports = {
|
||||
env: {
|
||||
node: true,
|
||||
},
|
||||
extends: [
|
||||
"airbnb-base",
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
"prettier",
|
||||
"prettier/@typescript-eslint"
|
||||
],
|
||||
parser: "@typescript-eslint/parser",
|
||||
parserOptions: {
|
||||
project: "test/configs/tsconfig.json"
|
||||
},
|
||||
plugins: ["@typescript-eslint"],
|
||||
rules: { // TODO: remove some rule overrides after disabling eslint on model customization tests(?)
|
||||
"import/extensions": ["off"],
|
||||
"import/prefer-default-export": ["off"],
|
||||
"@typescript-eslint/no-explicit-any": ["off"],
|
||||
"@typescript-eslint/camelcase": ["off"],
|
||||
"@typescript-eslint/class-name-casing": ["off"]
|
||||
},
|
||||
settings: {
|
||||
"import/resolver": {
|
||||
node: {
|
||||
extensions: [".ts"]
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
17
test/configs/tsconfig.json
Normal file
17
test/configs/tsconfig.json
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es2017",
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"moduleResolution": "node",
|
||||
"newLine": "LF",
|
||||
"typeRoots": [
|
||||
"../../node_modules/@types"
|
||||
],
|
||||
"resolveJsonModule": true,
|
||||
},
|
||||
"include": [
|
||||
"../../output"
|
||||
]
|
||||
}
|
@ -6,6 +6,7 @@ import * as path from "path";
|
||||
import * as chaiSubset from "chai-subset";
|
||||
import * as flatMap from "array.prototype.flatmap";
|
||||
import yn from "yn";
|
||||
import { CLIEngine } from "eslint";
|
||||
import EntityFileToJson from "../utils/EntityFileToJson";
|
||||
import { createDriver, dataCollectionPhase } from "../../src/Engine";
|
||||
import * as GTU from "../utils/GeneralTestUtils";
|
||||
@ -277,6 +278,15 @@ export function compileGeneratedModel(filesGenPath: string, drivers: string[]) {
|
||||
compiledWithoutErrors,
|
||||
"Errors detected while compiling generated model"
|
||||
).to.equal(true);
|
||||
|
||||
|
||||
const cli = new CLIEngine({ configFile: "test/configs/.eslintrc.js" });
|
||||
const lintReport = cli.executeOnFiles(currentDirectoryFiles)
|
||||
lintReport.results.forEach(result => result.messages.forEach(message => {
|
||||
console.error(`${result.filePath}:${message.line} - ${message.message}`)
|
||||
}))
|
||||
expect(lintReport.errorCount).to.equal(0)
|
||||
expect(lintReport.warningCount).to.equal(0)
|
||||
}
|
||||
|
||||
async function prepareTestRuns(
|
||||
|
@ -1,29 +1,30 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es2017",
|
||||
"noImplicitAny": false,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"sourceMap": true,
|
||||
"declaration": false,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noImplicitReturns": true,
|
||||
"stripInternal": true,
|
||||
"strictNullChecks": true,
|
||||
"moduleResolution": "node",
|
||||
"newLine": "LF",
|
||||
"outDir": "dist",
|
||||
"lib": [
|
||||
"es2019","es2019.array"
|
||||
],
|
||||
"typeRoots": [
|
||||
"./node_modules/@types"
|
||||
],
|
||||
"resolveJsonModule": true,
|
||||
},
|
||||
"include": [
|
||||
"src",
|
||||
"test"
|
||||
]
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es2017",
|
||||
"noImplicitAny": false,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"sourceMap": true,
|
||||
"declaration": false,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noImplicitReturns": true,
|
||||
"stripInternal": true,
|
||||
"strictNullChecks": true,
|
||||
"moduleResolution": "node",
|
||||
"newLine": "LF",
|
||||
"outDir": "dist",
|
||||
"lib": [
|
||||
"es2019",
|
||||
"es2019.array"
|
||||
],
|
||||
"typeRoots": [
|
||||
"./node_modules/@types"
|
||||
],
|
||||
"resolveJsonModule": true,
|
||||
},
|
||||
"include": [
|
||||
"src",
|
||||
"test",
|
||||
]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user