Skip to content

Adds tslint #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Jun 6, 2018
Merged
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "italia-utils",
"version": "3.7.1",
"version": "3.7.2",
"description": "Tools and utilities for the Digital Citizenship project",
"repository": "https://github.com/teamdigitale/italia-utils",
"author": "https://teamdigitale.governo.it",
Expand Down Expand Up @@ -41,7 +41,12 @@
"jest": "^22.4.3",
"rimraf": "^2.6.2",
"ts-jest": "^22.4.5",
"typescript": "^2.9.1"
"tslint": "^5.10.0",
"tslint-config-prettier": "^1.13.0",
"tslint-plugin-prettier": "^1.3.0",
"tslint-sonarts": "^1.7.0",
"typescript": "^2.9.1",
"typestrict": "^0.0.9"
},
"jest": {
"testEnvironment": "node",
Expand Down
4 changes: 2 additions & 2 deletions src/gen-api-models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as fs from "fs-extra";
import * as nunjucks from "nunjucks";
import * as prettier from "prettier";
import * as SwaggerParser from "swagger-parser";
import { Spec, Schema } from "swagger-schema-official";
import { Schema, Spec } from "swagger-schema-official";

function renderAsync(
env: nunjucks.Environment,
Expand Down Expand Up @@ -125,7 +125,7 @@ export function initNunJucksEnvironment(): nunjucks.Environment {
});

env.addFilter("camelCase", (item: string) => {
return item.replace(/(\_\w)/g, function(m) {
return item.replace(/(\_\w)/g, (m: string) => {
return m[1].toUpperCase();
});
});
Expand Down
20 changes: 10 additions & 10 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/usr/bin/env node

import yargs = require("yargs");

import { initNunJucksEnvironment, generateApi } from "./gen-api-models";
import { generateApi, initNunJucksEnvironment } from "./gen-api-models";

//
// parse command line
Expand All @@ -11,9 +10,9 @@ import { initNunJucksEnvironment, generateApi } from "./gen-api-models";
const argv = yargs
.option("api-spec", {
demandOption: true,
string: true,
description: "Path to input OpenAPI spec file",
normalize: true,
description: "Path to input OpenAPI spec file"
string: true
})
.option("strict", {
boolean: false,
Expand All @@ -22,15 +21,15 @@ const argv = yargs
})
.option("out-dir", {
demandOption: true,
string: true,
description: "Output directory to store generated definition files",
normalize: true,
description: "Output directory to store generated definition files"
string: true
})
.option("ts-spec-file", {
string: true,
normalize: true,
description:
"If defined, converts the OpenAPI specs to TypeScript source and writes it to this file"
"If defined, converts the OpenAPI specs to TypeScript source and writes it to this file",
normalize: true,
string: true
})
.help().argv;

Expand All @@ -44,5 +43,6 @@ generateApi(
argv["api-spec"],
argv["out-dir"],
argv["ts-spec-file"],
argv["strict"]
argv.strict
// tslint:disable-next-line:no-console
).then(() => console.log("done"), err => console.log(`Error: ${err}`));
17 changes: 17 additions & 0 deletions tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"defaultSeverity": "warn",
"extends": [
"typestrict",
"tslint:recommended",
"tslint-sonarts",
"tslint-plugin-prettier",
"tslint-config-prettier"
],
"jsRules": {},
"rules": {
"no-null-keyword": true,
"no-any": true,
"prettier": true
},
"rulesDirectory": []
}
84 changes: 80 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ aws4@^1.2.1, aws4@^1.6.0:
version "1.7.0"
resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.7.0.tgz#d4d0e9b9dbfca77bf08eeb0a8a471550fe39e289"

babel-code-frame@^6.26.0, babel-code-frame@^6.8.0:
babel-code-frame@^6.22.0, babel-code-frame@^6.26.0, babel-code-frame@^6.8.0:
version "6.26.0"
resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.26.0.tgz#63fd43f7dc1e3bb7ce35947db8fe369a3f58c74b"
dependencies:
Expand Down Expand Up @@ -608,7 +608,7 @@ buffer-from@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.0.0.tgz#4cb8832d23612589b0406e9e2956c17f06fdf531"

builtin-modules@^1.0.0:
builtin-modules@^1.0.0, builtin-modules@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-1.1.1.tgz#270f076c5a72c02f5b65a47df94c5fe3a278892f"

Expand Down Expand Up @@ -813,7 +813,7 @@ [email protected], combined-stream@^1.0.5, combined-stream@~1.0.5:
dependencies:
delayed-stream "~1.0.0"

commander@^2.13.0, commander@^2.7.1:
commander@^2.12.1, commander@^2.13.0, commander@^2.7.1:
version "2.15.1"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.15.1.tgz#df46e867d0fc2aec66a34662b406a9ccafff5b0f"

Expand Down Expand Up @@ -1212,6 +1212,13 @@ esdoc@^0.5.2:
minimist "1.2.0"
taffydb "2.7.2"

eslint-plugin-prettier@^2.2.0:
version "2.6.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-2.6.0.tgz#33e4e228bdb06142d03c560ce04ec23f6c767dd7"
dependencies:
fast-diff "^1.1.1"
jest-docblock "^21.0.0"

esprima@^3.1.3:
version "3.1.3"
resolved "https://registry.yarnpkg.com/esprima/-/esprima-3.1.3.tgz#fdca51cee6133895e3c88d535ce49dbff62a4633"
Expand Down Expand Up @@ -1339,6 +1346,10 @@ fast-deep-equal@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz#c053477817c86b51daa853c81e059b733d023614"

fast-diff@^1.1.1:
version "1.1.2"
resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.1.2.tgz#4b62c42b8e03de3f848460b639079920695d0154"

fast-json-stable-stringify@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz#d5142c0caee6b1189f87d3a76111064f86c8bbf2"
Expand Down Expand Up @@ -1820,6 +1831,10 @@ ignore-walk@^3.0.1:
dependencies:
minimatch "^3.0.4"

immutable@^3.8.2:
version "3.8.2"
resolved "https://registry.yarnpkg.com/immutable/-/immutable-3.8.2.tgz#c2439951455bb39913daf281376f1530e104adf3"

import-local@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/import-local/-/import-local-1.0.0.tgz#5e4ffdc03f4fe6c009c6729beb29631c2f8227bc"
Expand Down Expand Up @@ -2227,6 +2242,10 @@ jest-diff@^22.4.3:
jest-get-type "^22.4.3"
pretty-format "^22.4.3"

jest-docblock@^21.0.0:
version "21.2.0"
resolved "https://registry.yarnpkg.com/jest-docblock/-/jest-docblock-21.2.0.tgz#51529c3b30d5fd159da60c27ceedc195faf8d414"

jest-docblock@^22.4.3:
version "22.4.3"
resolved "https://registry.yarnpkg.com/jest-docblock/-/jest-docblock-22.4.3.tgz#50886f132b42b280c903c592373bb6e93bb68b19"
Expand Down Expand Up @@ -3552,7 +3571,7 @@ [email protected]:
version "1.1.7"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b"

resolve@^1.1.7:
resolve@^1.1.7, resolve@^1.3.2:
version "1.7.1"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.7.1.tgz#aadd656374fd298aee895bc026b8297418677fd3"
dependencies:
Expand Down Expand Up @@ -4056,6 +4075,56 @@ ts-jest@^22.4.5:
pkg-dir "^2.0.0"
yargs "^11.0.0"

tslib@^1.7.1, tslib@^1.8.0, tslib@^1.8.1:
version "1.9.2"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.2.tgz#8be0cc9a1f6dc7727c38deb16c2ebd1a2892988e"

tslint-config-prettier@^1.13.0:
version "1.13.0"
resolved "https://registry.yarnpkg.com/tslint-config-prettier/-/tslint-config-prettier-1.13.0.tgz#189e821931ad89e0364e4e292d5c44a14e90ecd6"

tslint-microsoft-contrib@^5.0.3:
version "5.0.3"
resolved "https://registry.yarnpkg.com/tslint-microsoft-contrib/-/tslint-microsoft-contrib-5.0.3.tgz#6fc3e238179cd72045c2b422e4d655f4183a8d5c"
dependencies:
tsutils "^2.12.1"

tslint-plugin-prettier@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/tslint-plugin-prettier/-/tslint-plugin-prettier-1.3.0.tgz#7eb65d19ea786a859501a42491b78c5de2031a3f"
dependencies:
eslint-plugin-prettier "^2.2.0"
tslib "^1.7.1"

tslint-sonarts@^1.7.0:
version "1.7.0"
resolved "https://registry.yarnpkg.com/tslint-sonarts/-/tslint-sonarts-1.7.0.tgz#1bcaf9f524c86b8d4cf9a2afae736edffd2e0dea"
dependencies:
immutable "^3.8.2"

tslint@^5.10.0:
version "5.10.0"
resolved "https://registry.yarnpkg.com/tslint/-/tslint-5.10.0.tgz#11e26bccb88afa02dd0d9956cae3d4540b5f54c3"
dependencies:
babel-code-frame "^6.22.0"
builtin-modules "^1.1.1"
chalk "^2.3.0"
commander "^2.12.1"
diff "^3.2.0"
glob "^7.1.1"
js-yaml "^3.7.0"
minimatch "^3.0.4"
resolve "^1.3.2"
semver "^5.3.0"
tslib "^1.8.0"
tsutils "^2.12.1"

tsutils@^2.12.1:
version "2.27.1"
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-2.27.1.tgz#ab0276ac23664f36ce8fd4414daec4aebf4373ee"
dependencies:
tslib "^1.8.1"

tunnel-agent@^0.6.0:
version "0.6.0"
resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd"
Expand All @@ -4076,6 +4145,13 @@ typescript@^2.9.1:
version "2.9.1"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.9.1.tgz#fdb19d2c67a15d11995fd15640e373e09ab09961"

typestrict@^0.0.9:
version "0.0.9"
resolved "https://registry.yarnpkg.com/typestrict/-/typestrict-0.0.9.tgz#e4c882afb55a698e6f8b1ca125c50c229593d72c"
dependencies:
tslint-microsoft-contrib "^5.0.3"
tslint-sonarts "^1.7.0"

uglify-js@^2.6:
version "2.8.29"
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.8.29.tgz#29c5733148057bb4e1f75df35b7a9cb72e6a59dd"
Expand Down