diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..47f3db3 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,10 @@ +{ + "files.exclude": { + "**/.git": true, + "generators": true, + "node_modules": true + }, + "prettier.semi": false, + "prettier.printWidth": 120, + "prettier.singleQuote": true +} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 81afe1c..30c95e8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,8 +2,15 @@ Thanks for your interest in contributing to this package! Here are some things to consider when getting started in this repo. -## Development +## Setup * Install yarn and run `yarn install` to install dependencies. + +## Development + +* Use `npm link` in this folder to make `yo` use this folder for the module module: `generator-danger-plugin`. +* Ensure the babel runner is watching for changes: `yarn build -- --watch`. +* Use `yo danger-plugin` to create a new project using the dev template. + * Run tests with `yarn test` * When committing use `yarn commit` instead of `git commit`. This will prompt you to input various fields for a [conventional commit message](https://github.com/semantic-release/semantic-release#default-commit-message-format), which semantic-release uses to determine the next package version number when deploying to NPM (major, minor, patch). diff --git a/README.md b/README.md index c1c03d0..f7815f2 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ $ yo danger-plugin This will create a new directory ready for Danger plugin development with the following technologies: -* [Babel](https://babeljs.io/) +* [Babel](https://babeljs.io/) or [TypeScript](http://www.typescriptlang.org) * [Jest](http://facebook.github.io/jest/) * [semantic-release](https://github.com/semantic-release/semantic-release) for simple NPM package deployment from [Travis CI](https://travis-ci.org/) diff --git a/package.json b/package.json index c02c24f..64fb565 100644 --- a/package.json +++ b/package.json @@ -26,8 +26,7 @@ "yeoman-generator", "generator", "boilerplate", - "danger", - "danger-plugin" + "danger" ], "author": "Macklin Underdown ", "license": "MIT", diff --git a/src/app/__snapshots__/index.test.js.snap b/src/app/__snapshots__/index.test.js.snap index a69eb5e..bc32ed3 100644 --- a/src/app/__snapshots__/index.test.js.snap +++ b/src/app/__snapshots__/index.test.js.snap @@ -61,42 +61,7 @@ THE SOFTWARE IS PROVIDED \\"AS IS\\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR I " `; -exports[`generator:app README.md contains plugin name 1`] = ` -"# danger-plugin-fun-time - -[![Build Status](https://travis-ci.org/macklinu/danger-plugin-fun-time.svg?branch=master)](https://travis-ci.org/macklinu/danger-plugin-fun-time) -[![npm version](https://badge.fury.io/js/danger-plugin-fun-time.svg)](https://badge.fury.io/js/danger-plugin-fun-time) -[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) - -> Danger plugin that tells you to have a fun time - -## Usage - -Install: - -\`\`\`sh -yarn add danger-plugin-fun-time --dev -\`\`\` - -At a glance: - -\`\`\`js -// dangerfile.js -import funTime from 'danger-plugin-fun-time' - -funTime() -\`\`\` -## Changelog - -See the GitHub [release history](https://github.com/macklinu/danger-plugin-fun-time/releases). - -## Contributing - -See [CONTRIBUTING.md](contributing.md). -" -`; - -exports[`generator:app package.json fills package.json with correct information 1`] = ` +exports[`generator:app package.json fills package.json with correct JS information 1`] = ` Object { "author": Object { "email": "email@example.com", @@ -157,9 +122,105 @@ Object { "commit": "git-cz", "commitmsg": "validate-commit-msg", "docs": "esdoc -c .esdoc.json", + "lint": "tslint \\"src/**/*.ts\\"", + "precommit": "lint-staged", + "predocs": "rm -rf docs/", + "prepublish": "npm run build", + "prettier": "prettier", + "prettier-project": "npm run prettier-write -- 'src/**/*.{ts,tsx}'", + "prettier-write": "npm run prettier -- --parser typescript --no-semi --trailing-comma es5 --write --print-width 120", + "semantic-release": "semantic-release pre && npm publish && semantic-release post", + "test": "jest", + }, + "types": "types/index.d.ts", + "version": "0.0.0-development", +} +`; + +exports[`generator:app package.json fills package.json with correct TS information 1`] = ` +Object { + "author": Object { + "email": "email@example.com", + "name": "Macklin Underdown", + }, + "bugs": Object { + "url": "https://github.com/macklinu/danger-plugin-fun-time/issues", + }, + "config": Object { + "commitizen": Object { + "path": "cz-conventional-changelog", + }, + }, + "description": "Danger plugin that tells you to have a fun time", + "devDependencies": Object { + "@types/jest": "^19.2.4", + "commitizen": "^2.9.6", + "cz-conventional-changelog": "^2.0.0", + "danger": "*", + "husky": "^0.13.3", + "jest": "^20.0.1", + "lint-staged": "^3.4.1", + "prettier": "^1.3.1", + "semantic-release": "^6.3.6", + "ts-jest": "^20.0.0", + "tslint": "^5.4.3", + "typescript": "^2.3.2", + "validate-commit-msg": "^2.12.1", + }, + "engines": Object { + "node": ">=4.0.0", + }, + "homepage": "https://github.com/macklinu/danger-plugin-fun-time#readme", + "jest": Object { + "moduleFileExtensions": Array [ + "ts", + "tsx", + "js", + ], + "testPathIgnorePatterns": Array [ + "\\\\.snap$", + "/node_modules/", + ], + "testRegex": "(.test)\\\\.(ts|tsx)$", + "transform": Object { + ".(ts|tsx)": "/node_modules/ts-jest/preprocessor.js", + }, + }, + "keywords": Array [ + "danger", + "danger-plugin", + "fun", + "time", + ], + "license": "MIT", + "lint-staged": Object { + "*.@(ts|tsx)": Array [ + "tslint --fix", + "npm run prettier-write --", + "git add", + ], + }, + "main": "dist/index.js", + "name": "danger-plugin-fun-time", + "optionalDependencies": Object { + "esdoc": "^0.5.2", + }, + "repository": Object { + "type": "git", + "url": "https://github.com/macklinu/danger-plugin-fun-time.git", + }, + "scripts": Object { + "build": "tsc", + "commit": "git-cz", + "commitmsg": "validate-commit-msg", + "docs": "esdoc -c .esdoc.json", + "lint": "tslint \\"src/**/*.ts\\"", "precommit": "lint-staged", "predocs": "rm -rf docs/", "prepublish": "npm run build", + "prettier": "prettier", + "prettier-project": "npm run prettier-write -- 'src/**/*.{ts,tsx}'", + "prettier-write": "npm run prettier -- --parser typescript --no-semi --trailing-comma es5 --write --print-width 120", "semantic-release": "semantic-release pre && npm publish && semantic-release post", "test": "jest", }, @@ -186,13 +247,13 @@ exports[`generator:app src/ generates test file based on plugin name 1`] = ` `; exports[`generator:app types/ generates TypeScript test file 1`] = ` -"import jestTestRunner from './' +"import funTime from './' -jestTestRunner() +funTime() " `; exports[`generator:app types/ generates TypeScript type defintion 1`] = ` -"export default function jestTestRunner(): void +"export default function funTime(): void " `; diff --git a/src/app/defaults.js b/src/app/defaults.js index b2190ba..417f12b 100644 --- a/src/app/defaults.js +++ b/src/app/defaults.js @@ -18,9 +18,6 @@ export const defaultPackageJson = { node: '>=4.0.0', }, devDependencies: { - 'babel-cli': '^6.24.1', - 'babel-jest': '^20.0.1', - 'babel-preset-env': '^1.4.0', commitizen: '^2.9.6', 'cz-conventional-changelog': '^2.0.0', husky: '^0.13.3', @@ -29,7 +26,6 @@ export const defaultPackageJson = { prettier: '^1.3.1', 'semantic-release': '^6.3.6', typescript: '^2.3.2', - 'typings-tester': '^0.2.2', 'validate-commit-msg': '^2.12.1', }, optionalDependencies: { diff --git a/src/app/index.js b/src/app/index.js index 385f056..1576370 100644 --- a/src/app/index.js +++ b/src/app/index.js @@ -7,6 +7,8 @@ import rename from 'gulp-rename' import githubUrl from 'github-url-from-username-repo' import chalk from 'chalk' +import fs from 'fs' + import { defaultEmail, defaultGitHubUsername, defaultName } from './values' import * as validators from './validators' import { defaultPackageJson } from './defaults' @@ -15,11 +17,7 @@ const PLUGIN_PREFIX = 'danger-plugin-' function makeGeneratorName(name) { name = _.kebabCase(name) - - if (name.indexOf(PLUGIN_PREFIX) === 0) { - this.log( - "Adding 'danger-plugin' as a prefix, making it: " + PLUGIN_PREFIX + name - ) + if (!name.startsWith(PLUGIN_PREFIX)) { return PLUGIN_PREFIX + name } return name @@ -86,6 +84,13 @@ export default class extends Generator { default: true, store: true, }, + { + type: 'confirm', + name: 'useTypeScript', + message: 'Use TypeScript?', + default: true, + store: true, + }, ]) this.props = { @@ -109,19 +114,72 @@ export default class extends Generator { this.registerTransformStream( rename(path => { + const extension = this.props.useTypeScript ? '.ts' : '.js' if (path.basename === 'index' && !path.extname) { - path.extname = '.js' + path.extname = extension } if (path.extname === '.test') { path.basename += '.test' - path.extname = '.js' + path.extname = extension } return path }) ) + const platformProperties = {} + if (this.props.useTypeScript) { + platformProperties[ + 'scripts' + ] = Object.assign(defaultPackageJson.scripts, { + build: 'tsc', + prettier: 'prettier', + 'prettier-write': 'npm run prettier -- --parser typescript --no-semi --trailing-comma es5 --write --print-width 120', + 'prettier-project': "npm run prettier-write -- 'src/**/*.{ts,tsx}'", + lint: 'tslint "src/**/*.ts"', + }) + + platformProperties['jest'] = { + moduleFileExtensions: ['ts', 'tsx', 'js'], + transform: { + '.(ts|tsx)': '/node_modules/ts-jest/preprocessor.js', + }, + testRegex: '(.test)\\.(ts|tsx)$', + testPathIgnorePatterns: ['\\.snap$', '/node_modules/'], + } + + platformProperties['devDependencies'] = Object.assign( + { + 'ts-jest': '^20.0.0', + '@types/jest': '^19.2.4', + tslint: '^5.4.3', + danger: '*', + }, + defaultPackageJson.devDependencies + ) + + platformProperties['lint-staged'] = { + '*.@(ts|tsx)': ['tslint --fix', 'npm run prettier-write --', 'git add'], + } + } else { + platformProperties[ + 'scripts' + ] = Object.assign(defaultPackageJson.scripts, { + build: 'babel src --out-dir dist --ignore *.test.js', + }) + + platformProperties['devDependencies'] = Object.assign( + { + 'babel-cli': '^6.24.1', + 'babel-jest': '^20.0.1', + 'babel-preset-env': '^1.4.0', + 'typings-tester': '^0.2.2', + }, + defaultPackageJson.devDependencies + ) + } + const pkg = Object.assign( { name: this.props.pluginName, @@ -142,14 +200,21 @@ export default class extends Generator { ['danger', 'danger-plugin'].concat(this.props.keywords || []) ), }, - defaultPackageJson + defaultPackageJson, + platformProperties ) + this.fs.writeJSON(this.destinationPath('package.json'), pkg) this.fs.copyTpl( this.templatePath('README.md'), this.destinationPath('README.md'), - { ...this.props, pluginFunctionName, githubBaseUrl, repoSlug } + { + ...this.props, + pluginFunctionName, + githubBaseUrl, + repoSlug, + } ) this.fs.copy( @@ -166,41 +231,61 @@ export default class extends Generator { this.fs.copyTpl( this.templatePath('LICENSE.md'), this.destinationPath('LICENSE.md'), - { year: new Date().getUTCFullYear(), authorName: this.props.authorName } - ) - - this.fs.copy( - this.templatePath('editorconfig'), - this.destinationPath('.editorconfig') - ) - - this.fs.copy( - this.templatePath('gitignore'), - this.destinationPath('.gitignore') - ) - - this.fs.copy( - this.templatePath('npmignore'), - this.destinationPath('.npmignore') + { + year: new Date().getUTCFullYear(), + authorName: this.props.authorName, + } ) - this.fs.copy( - this.templatePath('esdoc.json'), - this.destinationPath('.esdoc.json') - ) + const prependDots = [ + 'editorconfig', + 'gitignore', + 'esdoc.json', + 'babelrc', + 'npmignore', + 'vscode', + ] + prependDots.forEach(file => { + const path = this.templatePath(file) + if (fs.existsSync(path)) { + this.fs.copy(path, this.destinationPath('.' + file)) + } + }) - this.fs.copy(this.templatePath('babelrc'), this.destinationPath('.babelrc')) + const moveWithoutDot = ['tsconfig.json', 'tslint.json'] + moveWithoutDot.forEach(file => { + const path = this.templatePath(file) + if (fs.existsSync(path)) { + this.fs.copy(path, this.destinationPath(file)) + } + }) - this.fs.copyTpl(this.templatePath('src/**'), this.destinationPath('src'), { + const srcOptions = { ...this.props, pluginFunctionName, - }) - + } this.fs.copyTpl( - this.templatePath('types/**'), - this.destinationPath('types'), - { pluginFunctionName } + this.templatePath('src/*'), + this.destinationPath('src'), + srcOptions ) + + if (!this.props.useTypeScript) { + this.fs.copyTpl( + this.templatePath('types/**'), + this.destinationPath('types'), + { pluginFunctionName } + ) + } + } + + templatePath(path) { + const sharedPath = super.templatePath('all/' + path) + if (fs.existsSync(sharedPath)) { + return sharedPath + } + const templateFolder = this.props.useTypeScript ? 'ts/' : 'js/' + return super.templatePath(templateFolder + path) } install() { diff --git a/src/app/index.test.js b/src/app/index.test.js index 53d5bd4..eafbdc6 100644 --- a/src/app/index.test.js +++ b/src/app/index.test.js @@ -14,13 +14,20 @@ function readFile(filename, json = false) { return filename.endsWith('.json') || json ? JSON.parse(file) : file } +const exampleSettings = { + pluginName: 'danger-plugin-fun-time', + description: 'Danger plugin that tells you to have a fun time', + authorName: 'Macklin Underdown', + authorEmail: 'email@example.com', + githubUsername: 'macklinu', + keywords: ['fun', 'time'], +} + describe('generator:app', () => { - it('creates expected files', async () => { + it('creates expected JS files', async () => { await helpers.run(__dirname).withPrompts({ - pluginName: 'danger-plugin-fun-time', - description: 'Danger plugin that tells you to have a fun time', - authorName: 'Macklin Underdown', - authorEmail: 'email@example.com', + ...exampleSettings, + useTypeScript: false, }) assert.file([ 'README.md', @@ -41,26 +48,50 @@ describe('generator:app', () => { 'types/types.test.js', ]) }) + it('creates expected TS files', async () => { + await helpers.run(__dirname).withPrompts({ + ...exampleSettings, + useTypeScript: true, + }) + assert.file([ + 'README.md', + 'CONTRIBUTING.md', + 'package.json', + 'CODE_OF_CONDUCT.md', + 'LICENSE.md', + '.editorconfig', + '.gitignore', + '.npmignore', + 'tsconfig.json', + 'tslint.json', + 'src/index.ts', + 'src/index.test.ts', + '.vscode/settings.json', + ]) + assert.noFile([ + 'src/tsconfig.json', + 'src/tslint.json', + 'src/index.js', + 'src/index.test.js', + ]) + }) describe('README.md', () => { beforeEach(async () => { - await helpers.run(__dirname).withPrompts({ - pluginName: 'danger-plugin-fun-time', - description: 'Danger plugin that tells you to have a fun time', - authorName: 'Macklin Underdown', - authorEmail: 'email@example.com', - }) + await helpers.run(__dirname).withPrompts(exampleSettings) }) - it('contains plugin name', () => { - expect(readFile('README.md')).toMatchSnapshot() + it('contains plugin metadata', () => { + const readme = readFile('README.md') + expect(readme).toContain('danger-plugin-fun-time') + expect(readme).toContain( + 'Danger plugin that tells you to have a fun time' + ) }) }) describe('src/', () => { beforeEach(async () => { await helpers.run(__dirname).withPrompts({ - pluginName: 'danger-plugin-fun-time', - description: 'Danger plugin that tells you to have a fun time', - authorName: 'Macklin Underdown', - authorEmail: 'email@example.com', + ...exampleSettings, + useTypeScript: false, }) }) it('generates source file based on plugin name', async () => { @@ -73,10 +104,8 @@ describe('generator:app', () => { describe('types/', () => { beforeEach(async () => { await helpers.run(__dirname).withPrompts({ - pluginName: 'danger-plugin-jest-test-runner', - description: 'Danger plugin that runs Jest tests', - authorName: 'Macklin Underdown', - authorEmail: 'email@example.com', + ...exampleSettings, + useTypeScript: false, }) }) it('generates TypeScript type defintion', () => { @@ -88,36 +117,30 @@ describe('generator:app', () => { }) describe('CODE_OF_CONDUCT.md', () => { it('contains author email', async () => { - await helpers.run(__dirname).withPrompts({ - pluginName: 'danger-plugin-fun-time', - description: 'Danger plugin that tells you to have a fun time', - authorName: 'Macklin Underdown', - authorEmail: 'email@example.com', - }) + await helpers.run(__dirname).withPrompts(exampleSettings) expect(readFile('CODE_OF_CONDUCT.md')).toMatchSnapshot() }) }) describe('LICENSE.md', () => { it('contains the current year and author name', async () => { Date.prototype.getUTCFullYear = jest.fn(() => 2017) - await helpers.run(__dirname).withPrompts({ - pluginName: 'danger-plugin-fun-time', - description: 'Danger plugin that tells you to have a fun time', - authorName: 'Macklin Underdown', - authorEmail: 'email@example.com', - }) + await helpers.run(__dirname).withPrompts(exampleSettings) expect(readFile('LICENSE.md')).toMatchSnapshot() }) }) describe('package.json', () => { - it('fills package.json with correct information', async () => { + it('fills package.json with correct JS information', async () => { await helpers.run(__dirname).withPrompts({ - pluginName: 'danger-plugin-fun-time', - description: 'Danger plugin that tells you to have a fun time', - authorName: 'Macklin Underdown', - authorEmail: 'email@example.com', - githubUsername: 'macklinu', - keywords: ['fun', 'time'], + ...exampleSettings, + useTypeScript: false, + }) + const pkg = readFile('package.json') + expect(pkg).toMatchSnapshot() + }) + it('fills package.json with correct TS information', async () => { + await helpers.run(__dirname).withPrompts({ + ...exampleSettings, + useTypeScript: true, }) const pkg = readFile('package.json') expect(pkg).toMatchSnapshot() @@ -138,5 +161,21 @@ describe('generator:app', () => { const pkg = readFile('package.json') expect(pkg.author.email).toEqual('git@git.com') }) + it('uses tsc for TypeScript builds', async () => { + await helpers.run(__dirname).withPrompts({ + ...exampleSettings, + useTypeScript: true, + }) + const pkg = readFile('package.json') + expect(pkg.scripts.build).toContain('tsc') + }) + it('uses babel for JavaScript builds', async () => { + await helpers.run(__dirname).withPrompts({ + ...exampleSettings, + useTypeScript: false, + }) + const pkg = readFile('package.json') + expect(pkg.scripts.build).toContain('babel') + }) }) }) diff --git a/src/app/templates/CODE_OF_CONDUCT.md b/src/app/templates/all/CODE_OF_CONDUCT.md similarity index 100% rename from src/app/templates/CODE_OF_CONDUCT.md rename to src/app/templates/all/CODE_OF_CONDUCT.md diff --git a/src/app/templates/CONTRIBUTING.md b/src/app/templates/all/CONTRIBUTING.md similarity index 100% rename from src/app/templates/CONTRIBUTING.md rename to src/app/templates/all/CONTRIBUTING.md diff --git a/src/app/templates/LICENSE.md b/src/app/templates/all/LICENSE.md similarity index 100% rename from src/app/templates/LICENSE.md rename to src/app/templates/all/LICENSE.md diff --git a/src/app/templates/README.md b/src/app/templates/all/README.md similarity index 100% rename from src/app/templates/README.md rename to src/app/templates/all/README.md diff --git a/src/app/templates/editorconfig b/src/app/templates/all/editorconfig similarity index 100% rename from src/app/templates/editorconfig rename to src/app/templates/all/editorconfig diff --git a/src/app/templates/gitignore b/src/app/templates/all/gitignore similarity index 100% rename from src/app/templates/gitignore rename to src/app/templates/all/gitignore diff --git a/src/app/templates/npmignore b/src/app/templates/all/npmignore similarity index 100% rename from src/app/templates/npmignore rename to src/app/templates/all/npmignore diff --git a/src/app/templates/babelrc b/src/app/templates/js/babelrc similarity index 100% rename from src/app/templates/babelrc rename to src/app/templates/js/babelrc diff --git a/src/app/templates/esdoc.json b/src/app/templates/js/esdoc.json similarity index 100% rename from src/app/templates/esdoc.json rename to src/app/templates/js/esdoc.json diff --git a/src/app/templates/src/index b/src/app/templates/js/src/index similarity index 100% rename from src/app/templates/src/index rename to src/app/templates/js/src/index diff --git a/src/app/templates/src/index.test b/src/app/templates/js/src/index.test similarity index 100% rename from src/app/templates/src/index.test rename to src/app/templates/js/src/index.test diff --git a/src/app/templates/types/index.d.ts b/src/app/templates/js/types/index.d.ts similarity index 100% rename from src/app/templates/types/index.d.ts rename to src/app/templates/js/types/index.d.ts diff --git a/src/app/templates/types/test.ts b/src/app/templates/js/types/test.ts similarity index 100% rename from src/app/templates/types/test.ts rename to src/app/templates/js/types/test.ts diff --git a/src/app/templates/types/tsconfig.json b/src/app/templates/js/types/tsconfig.json similarity index 100% rename from src/app/templates/types/tsconfig.json rename to src/app/templates/js/types/tsconfig.json diff --git a/src/app/templates/types/types.test b/src/app/templates/js/types/types.test similarity index 100% rename from src/app/templates/types/types.test rename to src/app/templates/js/types/types.test diff --git a/src/app/templates/ts/src/index.test.ts b/src/app/templates/ts/src/index.test.ts new file mode 100644 index 0000000..63746be --- /dev/null +++ b/src/app/templates/ts/src/index.test.ts @@ -0,0 +1,31 @@ +import <%= pluginFunctionName %> from "./index" + +declare const global: any + +describe("<%= pluginFunctionName %>()", () => { + beforeEach(() => { + global.warn = jest.fn() + global.message = jest.fn() + global.fail = jest.fn() + global.markdown = jest.fn() + }) + + afterEach(() => { + global.warn = undefined + global.message = undefined + global.fail = undefined + global.markdown = undefined + }) + + it("Checks for a that message has been called", () => { + global.danger = { + github: { pr: { title: "My Test Title" } }, + } + + <%= pluginFunctionName %>() + + expect(global.message).toHaveBeenCalledWith( + "PR Title: My Test Title", + ) + }) +}) diff --git a/src/app/templates/ts/src/index.ts b/src/app/templates/ts/src/index.ts new file mode 100644 index 0000000..4dcb7fe --- /dev/null +++ b/src/app/templates/ts/src/index.ts @@ -0,0 +1,16 @@ +// Provides dev-time type structures for `danger` - doesn't affect runtime. +import {DangerDSLType} from "../node_modules/danger/distribution/dsl/DangerDSL" +declare var danger: DangerDSLType +export declare function message(message: string): void +export declare function warn(message: string): void +export declare function fail(message: string): void +export declare function markdown(message: string): void + +/** + * <%= description %> + */ +export default function <%= pluginFunctionName %>() { + // Replace this with the code from your Dangerfile + const title = danger.github.pr.title + message(`PR Title: ${title}`) +} diff --git a/src/app/templates/ts/tsconfig.json b/src/app/templates/ts/tsconfig.json new file mode 100755 index 0000000..57a716c --- /dev/null +++ b/src/app/templates/ts/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "target": "es6", + "module": "commonjs", + "rootDir": "src", + "outDir": "dist", + "allowJs": false, + "pretty": true, + "strictNullChecks": true, + "declaration": true + }, + "lib":["es2017"], + "include": [ + "src/**/*.ts", + "src/**/*.tsx", + "dangerfile.ts" + ], + "exclude": [ + "dangerfile.ts", + "node_modules", + "dist" + ] +} diff --git a/src/app/templates/ts/tslint.json b/src/app/templates/ts/tslint.json new file mode 100755 index 0000000..6a1a197 --- /dev/null +++ b/src/app/templates/ts/tslint.json @@ -0,0 +1,32 @@ +{ + "extends": [ + "tslint:recommended" + ], + "rules": { + "arrow-parens": false, + "interface-name": [ + true, + "never-prefix" + ], + "max-classes-per-file": [ + false + ], + "member-access": [ + false, + "check-accessor", + "check-constructor" + ], + "object-literal-sort-keys": false, + "semicolon": [ + true, + "never", + "ignore-interfaces", + "ignore-bound-class-methods" + ], + "switch-default": false, + "trailing-comma": [ + true, + { "multiline": "always", "singleline": "never" } + ] + } +} diff --git a/src/app/templates/ts/vscode/settings.json b/src/app/templates/ts/vscode/settings.json new file mode 100644 index 0000000..2c15f69 --- /dev/null +++ b/src/app/templates/ts/vscode/settings.json @@ -0,0 +1,11 @@ +{ + "prettier.singleQuote": false, + "prettier.trailingComma": "es5", + "prettier.semi": false, + "prettier.printWidth": 120, + "files.exclude": { + "**/.git": true, + "**/dist": true, + "**/node_modules": true + } +}