├── .editorconfig ├── .gitignore ├── .travis.yml ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── bin └── check.js ├── fixtures ├── tslint.all.json ├── tslint.empty.json ├── tslint.error.json └── tslint.false.json ├── package.json ├── src ├── .prettierrc ├── codelyzer │ ├── import-destructuring-spacing │ │ ├── __snapshots__ │ │ │ └── test.ts.snap │ │ ├── test.ts │ │ └── tslint.json │ └── tslint.json ├── tsconfig.json ├── tslint-consistent-codestyle │ └── tslint.json ├── tslint-divid │ ├── no-semicolon-interface │ │ ├── __snapshots__ │ │ │ └── test.ts.snap │ │ ├── test.ts │ │ └── tslint.json │ └── tslint.json ├── tslint-eslint-rules │ ├── array-bracket-spacing │ │ ├── __snapshots__ │ │ │ └── test.ts.snap │ │ ├── test.ts │ │ └── tslint.json │ ├── block-spacing │ │ ├── __snapshots__ │ │ │ └── test.ts.snap │ │ ├── test.ts │ │ └── tslint.json │ ├── brace-style │ │ ├── __snapshots__ │ │ │ └── test.ts.snap │ │ ├── test.ts │ │ └── tslint.json │ ├── no-extra-semi │ │ ├── .prettierrc │ │ ├── __snapshots__ │ │ │ └── test.ts.snap │ │ ├── test.ts │ │ └── tslint.json │ ├── no-multi-spaces │ │ ├── __snapshots__ │ │ │ └── test.ts.snap │ │ ├── test.ts │ │ └── tslint.json │ ├── object-curly-spacing │ │ ├── __snapshots__ │ │ │ └── test.ts.snap │ │ ├── test.ts │ │ └── tslint.json │ ├── space-in-parens │ │ ├── __snapshots__ │ │ │ └── test.ts.snap │ │ ├── test.ts │ │ └── tslint.json │ ├── ter-arrow-parens │ │ ├── __snapshots__ │ │ │ └── test.ts.snap │ │ ├── test.ts │ │ └── tslint.json │ ├── ter-arrow-spacing │ │ ├── __snapshots__ │ │ │ └── test.ts.snap │ │ ├── test.ts │ │ └── tslint.json │ ├── ter-computed-property-spacing │ │ ├── __snapshots__ │ │ │ └── test.ts.snap │ │ ├── test.ts │ │ └── tslint.json │ ├── ter-func-call-spacing │ │ ├── __snapshots__ │ │ │ └── test.ts.snap │ │ ├── test.ts │ │ └── tslint.json │ ├── ter-indent │ │ ├── __snapshots__ │ │ │ └── test.ts.snap │ │ ├── test.ts │ │ └── tslint.json │ ├── ter-max-len │ │ ├── __snapshots__ │ │ │ └── test.ts.snap │ │ ├── test.ts │ │ └── tslint.json │ ├── ter-no-irregular-whitespace │ │ ├── __snapshots__ │ │ │ └── test.ts.snap │ │ ├── test.ts │ │ └── tslint.json │ ├── ter-no-tabs │ │ ├── .prettierrc │ │ ├── __snapshots__ │ │ │ └── test.ts.snap │ │ ├── test.ts │ │ └── tslint.json │ ├── ter-padded-blocks │ │ ├── __snapshots__ │ │ │ └── test.ts.snap │ │ ├── test.ts │ │ └── tslint.json │ └── tslint.json ├── tslint-immutable │ └── tslint.json ├── tslint-microsoft-contrib │ ├── no-empty-line-after-opening-brace │ │ ├── __snapshots__ │ │ │ └── test.ts.snap │ │ ├── test.ts │ │ └── tslint.json │ ├── no-unnecessary-semicolons │ │ ├── __snapshots__ │ │ │ └── test.ts.snap │ │ ├── test.ts │ │ └── tslint.json │ ├── react-tsx-curly-spacing │ │ ├── __snapshots__ │ │ │ └── test.tsx.snap │ │ ├── test.tsx │ │ └── tslint.json │ └── tslint.json ├── tslint-misc-rules │ ├── jsx-attribute-spacing │ │ ├── __snapshots__ │ │ │ └── test.tsx.snap │ │ ├── test.tsx │ │ └── tslint.json │ ├── jsx-expression-spacing │ │ ├── __snapshots__ │ │ │ └── test.tsx.snap │ │ ├── test.tsx │ │ └── tslint.json │ ├── jsx-no-closing-bracket-newline │ │ ├── __snapshots__ │ │ │ └── test.tsx.snap │ │ ├── test.tsx │ │ └── tslint.json │ ├── no-unnecessary-parens-for-arrow-function-arguments │ │ ├── __snapshots__ │ │ │ └── test.ts.snap │ │ ├── test.ts │ │ └── tslint.json │ └── tslint.json ├── tslint-react │ ├── jsx-alignment │ │ ├── __snapshots__ │ │ │ └── test.tsx.snap │ │ ├── test.tsx │ │ └── tslint.json │ ├── jsx-curly-spacing │ │ ├── __snapshots__ │ │ │ └── test.tsx.snap │ │ ├── test.tsx │ │ └── tslint.json │ ├── jsx-equals-spacing │ │ ├── __snapshots__ │ │ │ └── test.tsx.snap │ │ ├── test.tsx │ │ └── tslint.json │ ├── jsx-no-multiline-js │ │ ├── __snapshots__ │ │ │ └── test.tsx.snap │ │ ├── test.tsx │ │ └── tslint.json │ ├── jsx-space-before-trailing-slash │ │ ├── __snapshots__ │ │ │ └── test.tsx.snap │ │ ├── test.tsx │ │ └── tslint.json │ ├── jsx-wrap-multiline │ │ ├── __snapshots__ │ │ │ └── test.tsx.snap │ │ ├── test.tsx │ │ └── tslint.json │ └── tslint.json ├── tslint │ ├── align │ │ ├── __snapshots__ │ │ │ └── test.ts.snap │ │ ├── test.ts │ │ └── tslint.json │ ├── arrow-parens │ │ ├── __snapshots__ │ │ │ └── test.ts.snap │ │ ├── test.ts │ │ └── tslint.json │ ├── eofline │ │ ├── __snapshots__ │ │ │ └── test.ts.snap │ │ ├── test.ts │ │ └── tslint.json │ ├── import-spacing │ │ ├── __snapshots__ │ │ │ └── test.ts.snap │ │ ├── test.ts │ │ └── tslint.json │ ├── indent │ │ ├── __snapshots__ │ │ │ └── test.ts.snap │ │ ├── test.ts │ │ └── tslint.json │ ├── linebreak-style │ │ ├── __snapshots__ │ │ │ └── test.ts.snap │ │ ├── test.ts │ │ └── tslint.json │ ├── max-line-length │ │ ├── __snapshots__ │ │ │ └── test.ts.snap │ │ ├── test.ts │ │ └── tslint.json │ ├── new-parens │ │ ├── __snapshots__ │ │ │ └── test.ts.snap │ │ ├── test.ts │ │ └── tslint.json │ ├── newline-per-chained-call │ │ ├── __snapshots__ │ │ │ └── test.ts.snap │ │ ├── test.ts │ │ └── tslint.json │ ├── no-consecutive-blank-lines │ │ ├── __snapshots__ │ │ │ └── test.ts.snap │ │ ├── test.ts │ │ └── tslint.json │ ├── no-irregular-whitespace │ │ ├── __snapshots__ │ │ │ └── test.ts.snap │ │ ├── test.ts │ │ └── tslint.json │ ├── no-trailing-whitespace │ │ ├── __snapshots__ │ │ │ └── test.ts.snap │ │ ├── test.ts │ │ └── tslint.json │ ├── number-literal-format │ │ ├── __snapshots__ │ │ │ └── test.ts.snap │ │ ├── test.ts │ │ └── tslint.json │ ├── object-literal-key-quotes │ │ ├── __snapshots__ │ │ │ └── test.ts.snap │ │ ├── test.ts │ │ └── tslint.json │ ├── one-line │ │ ├── __snapshots__ │ │ │ └── test.ts.snap │ │ ├── test.ts │ │ └── tslint.json │ ├── quotemark │ │ ├── __snapshots__ │ │ │ └── test.ts.snap │ │ ├── test.ts │ │ └── tslint.json │ ├── semicolon │ │ ├── __snapshots__ │ │ │ └── test.ts.snap │ │ ├── test.ts │ │ └── tslint.json │ ├── space-before-function-paren │ │ ├── __snapshots__ │ │ │ └── test.ts.snap │ │ ├── test.ts │ │ └── tslint.json │ ├── space-within-parens │ │ ├── __snapshots__ │ │ │ └── test.ts.snap │ │ ├── test.ts │ │ └── tslint.json │ ├── trailing-comma │ │ ├── __snapshots__ │ │ │ └── test.ts.snap │ │ ├── test.ts │ │ └── tslint.json │ ├── type-literal-delimiter │ │ ├── __snapshots__ │ │ │ └── test.ts.snap │ │ ├── test.ts │ │ └── tslint.json │ ├── typedef-whitespace │ │ ├── __snapshots__ │ │ │ └── test.ts.snap │ │ ├── test.ts │ │ └── tslint.json │ └── whitespace │ │ ├── __snapshots__ │ │ └── test.ts.snap │ │ ├── test.ts │ │ └── tslint.json └── vrsource-tslint-rules │ ├── conditional-expression-parens │ ├── __snapshots__ │ │ └── test.ts.snap │ ├── test.ts │ └── tslint.json │ ├── literal-spacing │ ├── __snapshots__ │ │ └── test.ts.snap │ ├── test.ts │ └── tslint.json │ ├── multiline-arrow │ ├── .prettierrc │ ├── __snapshots__ │ │ └── test.ts.snap │ ├── test.ts │ └── tslint.json │ └── tslint.json ├── tools ├── __snapshots__ │ └── checker.test.ts.snap ├── checker.test.ts ├── checker.ts ├── generate.ts ├── runtime.ts └── transform.ts ├── tsconfig.checker.json ├── tsconfig.json ├── tslint.json └── yarn.lock /.editorconfig: -------------------------------------------------------------------------------- 1 | #root = true 2 | 3 | [*] 4 | indent_style = space 5 | end_of_line = lf 6 | charset = utf-8 7 | trim_trailing_whitespace = true 8 | insert_final_newline = true 9 | max_line_length = 100 10 | indent_size = 2 11 | 12 | [*.md] 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .awcache 2 | .DS_Store 3 | .idea 4 | .nyc_output 5 | .vscode 6 | *.log 7 | build 8 | coverage 9 | lib 10 | node_modules 11 | package-lock.json 12 | yarn-error.log 13 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | branches: 3 | only: 4 | - master 5 | - /^greenkeeper/.*$/ 6 | cache: 7 | directories: 8 | - node_modules 9 | notifications: 10 | email: false 11 | node_js: 12 | - node 13 | install: 14 | - yarn install 15 | script: 16 | - npm run lint 17 | - npm run test -- --ci --verbose --coverage 18 | after_success: 19 | - npm run semantic-release 20 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to contribute 2 | 3 | We're really glad you're reading this, because we need volunteer developers to help this project come to fruition. :clap: 4 | 5 | If you want to know more about this project please check our [README.md](https://github.com/prettier/tslint-config-prettier/blob/master/README.md).This project uses [semantic-release](https://github.com/semantic-release/semantic-release) to keep a clean CI/CD pipe. 6 | 7 | So, you only will be required to follow [conventional-commit](https://github.com/commitizen/conventional-commit-types) messages. Everything else happens magically. 8 | 9 | ## Forking repo 10 | 11 | Fork the repo. Then, clone it and install dependencies: 12 | 13 | ```bash 14 | git clone https://github.com/YOUR-USERNAME/tslint-config-prettier 15 | npm install 16 | ``` 17 | 18 | This will set up the pre-push and commit-msg hooks, making sure your commits have the correct style, tests are passing and the coverage is met, so your commit don't break the build. 19 | 20 | You can run the command npm run commit to make you easier to write a conventional commit. Keep every PR as scoped as possible. 21 | 22 | Finally, Submit your changes by pull request :point_down:! 23 | 24 | ## Submitting changes 25 | 26 | Please send a [GitHub Pull Request](https://github.com/prettier/tslint-config-prettier/pull/new/master) with a clear list of what you've done (read more about [pull requests](http://help.github.com/pull-requests/)). When you send a pull request, we will love you forever if you include test and keep the coverage up, since checked when you submit a PR by our CI server. Make sure all of your commits are atomic (one feature per commit). 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2017 Alex Jover Morales 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # tslint-config-prettier 2 | 3 | [![npm](https://img.shields.io/npm/v/tslint-config-prettier.svg)](https://www.npmjs.com/package/tslint-config-prettier) 4 | [![Travis](https://img.shields.io/travis/alexjoverm/tslint-config-prettier.svg)](https://travis-ci.org/prettier/tslint-config-prettier) 5 | [![downloads](https://img.shields.io/npm/dm/tslint-config-prettier.svg)](https://www.npmjs.com/package/tslint-config-prettier) 6 | [![dependencies Status](https://img.shields.io/david/prettier/tslint-config-prettier.svg)](https://david-dm.org/prettier/tslint-config-prettier) 7 | [![devDependencies Status](https://img.shields.io/david/dev/prettier/tslint-config-prettier.svg)](https://david-dm.org/prettier/tslint-config-prettier?type=dev) 8 | 9 |

:cop: TSLint + :nail_care: Prettier = :heart_eyes:

10 | 11 | Do you want to use [TSLint](https://palantir.github.io/tslint/) and [Prettier](https://github.com/prettier/prettier) without conflicts? `tslint-config-prettier` disables all [conflicting rules](https://unpkg.com/tslint-config-prettier) that may cause such problems. Prettier takes care of the formatting whereas tslint takes care of all the other things. 12 | 13 | > Check how it works in **[this tutorial](https://alexjoverm.github.io/2017/06/12/Use-Prettier-with-TSLint-and-be-happy/)**. 14 | 15 | ### Get started 16 | 17 | ```bash 18 | yarn add --dev tslint-config-prettier 19 | # or 20 | npm install --save-dev tslint-config-prettier 21 | ``` 22 | 23 | Make sure you've already set up [TSLint](https://palantir.github.io/tslint/) and [Prettier](https://github.com/prettier/prettier). 24 | 25 | Then, extend your `tslint.json`, and make sure `tslint-config-prettier` is **at the end**: 26 | 27 | ```json 28 | { 29 | "extends": [ 30 | "tslint:latest", 31 | "tslint-config-prettier" 32 | ] 33 | } 34 | ``` 35 | 36 | ### More configuration 37 | 38 | `tslint-config-prettier` also turns off formatting rules from the following rulesets, so you can use them safely. 39 | 40 | - [codelyzer](https://github.com/mgechev/codelyzer) 41 | - [tslint](https://github.com/palantir/tslint) 42 | - [tslint-consistent-codestyle](https://github.com/ajafff/tslint-consistent-codestyle) 43 | - [tslint-divid](https://github.com/jonaskello/tslint-divid) 44 | - [tslint-eslint-rules](https://github.com/buzinas/tslint-eslint-rules) 45 | - [tslint-immutable](https://github.com/jonaskello/tslint-immutable) 46 | - [tslint-microsoft-contrib](https://github.com/Microsoft/tslint-microsoft-contrib) 47 | - [tslint-misc-rules](https://github.com/jwbay/tslint-misc-rules) 48 | - [tslint-react](https://github.com/palantir/tslint-react) 49 | - [vrsource-tslint-rules](https://github.com/vrsource/vrsource-tslint-rules) 50 | 51 | ```json 52 | { 53 | "extends": [ 54 | "tslint:latest", 55 | "tslint-react", 56 | "tslint-eslint-rules", 57 | "tslint-config-prettier" 58 | ] 59 | } 60 | ``` 61 | 62 | ### CLI helper tool 63 | 64 | `tslint-config-prettier` is shipped with a little CLI tool to help you check if your configuration contains any rules that are in conflict with Prettier. (require `tslint` installed) 65 | 66 | In order to execute the CLI tool, first add a script for it to `package.json`: 67 | 68 | ```json 69 | { 70 | "scripts": { 71 | "tslint-check": "tslint-config-prettier-check ./tslint.json" 72 | } 73 | } 74 | ``` 75 | 76 | Then run `yarn tslint-check` or `npm run tslint-check`. 77 | 78 | Or simply run `npx tslint-config-prettier-check ./tslint.json`. 79 | 80 | ### Tutorials 81 | 82 | - [Using TSlint with Prettier](https://alexjoverm.github.io/2017/06/12/Use-Prettier-with-TSLint-and-be-happy/) 83 | - [Use Prettier with TSLint without conflicts (video)](https://egghead.io/lessons/typescript-use-prettier-with-tslint-without-conflicts-c39670eb/) 84 | 85 | ### Contributing 86 | 87 | Please read [CONTRIBUTING.md](https://github.com/prettier/tslint-config-prettier/blob/master/CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us. 88 | 89 | ### Related 90 | 91 | - [tslint-plugin-prettier](https://github.com/ikatyang/tslint-plugin-prettier) - Runs Prettier as a TSLint rule and reports differences as individual TSLint issues. 92 | 93 | ### Credits 94 | 95 | Made with :heart: by [@alexjoverm](https://twitter.com/alexjoverm) and all its [contributors](https://github.com/prettier/tslint-config-prettier/graphs/contributors) 96 | -------------------------------------------------------------------------------- /bin/check.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | require("../lib/checker").check(process.argv.slice(2)); 3 | -------------------------------------------------------------------------------- /fixtures/tslint.all.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "tslint:all" 3 | } 4 | -------------------------------------------------------------------------------- /fixtures/tslint.empty.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /fixtures/tslint.error.json: -------------------------------------------------------------------------------- 1 | ---can-not-be-parsed--- 2 | -------------------------------------------------------------------------------- /fixtures/tslint.false.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "semicolon": false 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tslint-config-prettier", 3 | "version": "0.0.0-development", 4 | "description": "Do you wanna use tslint and prettier without conflicts? tslint-config-prettier disables all conflicting rules that may cause such problems. Prettier takes care of formatting and tslint the rest.", 5 | "keywords": [ 6 | "lint", 7 | "tslint", 8 | "ts-lint", 9 | "prettier", 10 | "config", 11 | "typescript" 12 | ], 13 | "files": [ 14 | "bin/check.js", 15 | "lib/index.json", 16 | "lib/checker.js" 17 | ], 18 | "main": "lib/index.json", 19 | "bin": { 20 | "tslint-config-prettier-check": "bin/check.js" 21 | }, 22 | "author": "Alex Jover Morales ", 23 | "repository": { 24 | "type": "git", 25 | "url": "https://github.com/prettier/tslint-config-prettier.git" 26 | }, 27 | "license": "MIT", 28 | "engines": { 29 | "node": ">=4.0.0" 30 | }, 31 | "scripts": { 32 | "prepublish": "yarn build-tools && yarn generate-config && yarn build-checker", 33 | "lint": "tslint 'tools/**/*.ts'", 34 | "test": "yarn clean && jest --no-cache", 35 | "clean": "rimraf ./node_modules/vrsource-tslint-rules/rules/*.ts", 36 | "build-tools": "tsc", 37 | "build-checker": "tsc -p ./tsconfig.checker.json", 38 | "generate-config": "node ./build/generate.js", 39 | "semantic-release": "semantic-release", 40 | "commit": "git-cz", 41 | "prepush": "yarn test && yarn lint", 42 | "commitmsg": "validate-commit-msg" 43 | }, 44 | "config": { 45 | "commitizen": { 46 | "path": "node_modules/cz-conventional-changelog" 47 | }, 48 | "validate-commit-msg": { 49 | "types": "conventional-commit-types", 50 | "helpMessage": "Use \"npm run commit\" instead, we use conventional-changelog format :) (https://github.com/commitizen/cz-cli)" 51 | } 52 | }, 53 | "jest": { 54 | "testEnvironment": "node", 55 | "moduleFileExtensions": [ 56 | "ts", 57 | "tsx", 58 | "js", 59 | "json" 60 | ], 61 | "testMatch": [ 62 | "**/src/**/test.{ts,tsx}", 63 | "**/tools/*.test.ts" 64 | ], 65 | "transform": { 66 | "/src/.+\\.tsx?$": "/build/transform.js", 67 | "/tools/.+\\.ts$": "ts-jest/preprocessor" 68 | }, 69 | "coverageThreshold": { 70 | "global": { 71 | "branches": 95, 72 | "functions": 95, 73 | "lines": 95, 74 | "statements": 95 75 | } 76 | } 77 | }, 78 | "devDependencies": { 79 | "@types/jest": "^23.1.2", 80 | "@types/make-dir": "^1.0.1", 81 | "@types/node": "^13.13.4", 82 | "@types/prettier": "^2.0.0", 83 | "codelyzer": "6.0.2", 84 | "commitizen": "^3.0.0", 85 | "cz-conventional-changelog": "^2.0.0", 86 | "husky": "^1.0.0", 87 | "jest": "^24.1.0", 88 | "lodash": "^4.17.4", 89 | "make-dir": "^1.0.0", 90 | "prettier": "2.3.0", 91 | "rimraf": "^3.0.2", 92 | "semantic-release": "^15.0.0", 93 | "ts-jest": "^24.0.0", 94 | "tslint": "6.1.3", 95 | "tslint-consistent-codestyle": "1.16.0", 96 | "tslint-divid": "1.3.0", 97 | "tslint-eslint-rules": "5.4.0", 98 | "tslint-immutable": "6.0.1", 99 | "tslint-microsoft-contrib": "6.2.0", 100 | "tslint-misc-rules": "3.6.0", 101 | "tslint-react": "5.0.0", 102 | "typescript": "4.3.2", 103 | "validate-commit-msg": "^2.10.1", 104 | "vrsource-tslint-rules": "6.0.0" 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /src/.prettierrc: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /src/codelyzer/import-destructuring-spacing/__snapshots__/test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | ERROR: (import-destructuring-spacing) /src/codelyzer/import-destructuring-spacing/test.ts[1, 8]: Import statement's curly braces must be spaced exactly by a space to the right and a space to the left 7 | 8 | ====== 9 | no error 10 | 11 | >>>>>> after 12 | " 13 | `; 14 | 15 | exports[`should be pretty after formatting 1`] = ` 16 | " 17 | <<<<<< before 18 | import {Foo,Bar} from './foo'; 19 | 20 | ====== 21 | import { Foo, Bar } from \\"./foo\\"; 22 | 23 | >>>>>> after 24 | " 25 | `; 26 | -------------------------------------------------------------------------------- /src/codelyzer/import-destructuring-spacing/test.ts: -------------------------------------------------------------------------------- 1 | import {Foo,Bar} from './foo'; 2 | -------------------------------------------------------------------------------- /src/codelyzer/import-destructuring-spacing/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tslint.json", 3 | "rules": { 4 | "import-destructuring-spacing": true 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/codelyzer/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rulesDirectory": ["../../node_modules/codelyzer"] 3 | } 4 | -------------------------------------------------------------------------------- /src/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "strict": true, 4 | "jsx": "preserve" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/tslint-consistent-codestyle/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rulesDirectory": ["../../node_modules/tslint-consistent-codestyle/rules"] 3 | } 4 | -------------------------------------------------------------------------------- /src/tslint-divid/no-semicolon-interface/__snapshots__/test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | no error 7 | 8 | ====== 9 | ERROR: (no-semicolon-interface) /src/tslint-divid/no-semicolon-interface/test.ts[2, 3]: Use comma instead of semicolon in interfaces. 10 | ERROR: (no-semicolon-interface) /src/tslint-divid/no-semicolon-interface/test.ts[3, 3]: Use comma instead of semicolon in interfaces. 11 | 12 | >>>>>> after 13 | " 14 | `; 15 | 16 | exports[`should be pretty after formatting 1`] = ` 17 | " 18 | <<<<<< before 19 | interface Foo { 20 | bar: string, 21 | zoo(): number, 22 | } 23 | 24 | ====== 25 | interface Foo { 26 | bar: string; 27 | zoo(): number; 28 | } 29 | 30 | >>>>>> after 31 | " 32 | `; 33 | -------------------------------------------------------------------------------- /src/tslint-divid/no-semicolon-interface/test.ts: -------------------------------------------------------------------------------- 1 | interface Foo { 2 | bar: string, 3 | zoo(): number, 4 | } 5 | -------------------------------------------------------------------------------- /src/tslint-divid/no-semicolon-interface/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tslint.json", 3 | "rules": { 4 | "no-semicolon-interface": true 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/tslint-divid/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rulesDirectory": ["../../node_modules/tslint-divid/rules"] 3 | } 4 | -------------------------------------------------------------------------------- /src/tslint-eslint-rules/array-bracket-spacing/__snapshots__/test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | ERROR: (array-bracket-spacing) /src/tslint-eslint-rules/array-bracket-spacing/test.ts[1, 13]: There should be no space after \\"[\\" 7 | ERROR: (array-bracket-spacing) /src/tslint-eslint-rules/array-bracket-spacing/test.ts[1, 28]: There should be no space before \\"]\\" 8 | ERROR: (array-bracket-spacing) /src/tslint-eslint-rules/array-bracket-spacing/test.ts[2, 7]: There should be no space after \\"[\\" 9 | ERROR: (array-bracket-spacing) /src/tslint-eslint-rules/array-bracket-spacing/test.ts[2, 14]: There should be no space before \\"]\\" 10 | 11 | ====== 12 | no error 13 | 14 | >>>>>> after 15 | " 16 | `; 17 | 18 | exports[`should be pretty after formatting 1`] = ` 19 | " 20 | <<<<<< before 21 | const arr = [ 'foo', 'bar' ]; 22 | const [ x, y ] = arr; 23 | 24 | ====== 25 | const arr = [\\"foo\\", \\"bar\\"]; 26 | const [x, y] = arr; 27 | 28 | >>>>>> after 29 | " 30 | `; 31 | -------------------------------------------------------------------------------- /src/tslint-eslint-rules/array-bracket-spacing/test.ts: -------------------------------------------------------------------------------- 1 | const arr = [ 'foo', 'bar' ]; 2 | const [ x, y ] = arr; 3 | -------------------------------------------------------------------------------- /src/tslint-eslint-rules/array-bracket-spacing/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tslint.json", 3 | "rules": { 4 | "array-bracket-spacing": [true, "never"] 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/tslint-eslint-rules/block-spacing/__snapshots__/test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | ERROR: (block-spacing) /src/tslint-eslint-rules/block-spacing/test.ts[1, 16]: Requires a space 7 | ERROR: (block-spacing) /src/tslint-eslint-rules/block-spacing/test.ts[2, 10]: Requires a space 8 | 9 | ====== 10 | no error 11 | 12 | >>>>>> after 13 | " 14 | `; 15 | 16 | exports[`should be pretty after formatting 1`] = ` 17 | " 18 | <<<<<< before 19 | function foo() {return true;} 20 | if (foo) { bar = 0;} 21 | 22 | ====== 23 | function foo() { 24 | return true; 25 | } 26 | if (foo) { 27 | bar = 0; 28 | } 29 | 30 | >>>>>> after 31 | " 32 | `; 33 | -------------------------------------------------------------------------------- /src/tslint-eslint-rules/block-spacing/test.ts: -------------------------------------------------------------------------------- 1 | function foo() {return true;} 2 | if (foo) { bar = 0;} 3 | -------------------------------------------------------------------------------- /src/tslint-eslint-rules/block-spacing/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tslint.json", 3 | "rules": { 4 | "block-spacing": [true, "always"] 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/tslint-eslint-rules/brace-style/__snapshots__/test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | ERROR: (brace-style) /src/tslint-eslint-rules/brace-style/test.ts[4, 1]: Opening curly brace does not appear on the same line as controlling statement. 7 | 8 | ====== 9 | no error 10 | 11 | >>>>>> after 12 | " 13 | `; 14 | 15 | exports[`should be pretty after formatting 1`] = ` 16 | " 17 | <<<<<< before 18 | if (foo) { 19 | bar(); 20 | } 21 | else { 22 | baz(); 23 | } 24 | 25 | ====== 26 | if (foo) { 27 | bar(); 28 | } else { 29 | baz(); 30 | } 31 | 32 | >>>>>> after 33 | " 34 | `; 35 | -------------------------------------------------------------------------------- /src/tslint-eslint-rules/brace-style/test.ts: -------------------------------------------------------------------------------- 1 | if (foo) { 2 | bar(); 3 | } 4 | else { 5 | baz(); 6 | } 7 | -------------------------------------------------------------------------------- /src/tslint-eslint-rules/brace-style/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tslint.json", 3 | "rules": { 4 | "brace-style": [true, "1tbs"] 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/tslint-eslint-rules/no-extra-semi/.prettierrc: -------------------------------------------------------------------------------- 1 | { "semi": false } 2 | -------------------------------------------------------------------------------- /src/tslint-eslint-rules/no-extra-semi/__snapshots__/test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | no error 7 | 8 | ====== 9 | ERROR: (no-extra-semi) /src/tslint-eslint-rules/no-extra-semi/test.ts[1, 1]: unnecessary semicolon 10 | 11 | >>>>>> after 12 | " 13 | `; 14 | 15 | exports[`should be pretty after formatting 1`] = ` 16 | " 17 | <<<<<< before 18 | ({ x }) = foo() 19 | 20 | ====== 21 | ;({ x } = foo()) 22 | 23 | >>>>>> after 24 | " 25 | `; 26 | -------------------------------------------------------------------------------- /src/tslint-eslint-rules/no-extra-semi/test.ts: -------------------------------------------------------------------------------- 1 | ({ x }) = foo() 2 | -------------------------------------------------------------------------------- /src/tslint-eslint-rules/no-extra-semi/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tslint.json", 3 | "rules": { 4 | "no-extra-semi": true 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/tslint-eslint-rules/no-multi-spaces/__snapshots__/test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | ERROR: (no-multi-spaces) /src/tslint-eslint-rules/no-multi-spaces/test.ts[1, 11]: Multiple spaces found before '='. 7 | 8 | ====== 9 | no error 10 | 11 | >>>>>> after 12 | " 13 | `; 14 | 15 | exports[`should be pretty after formatting 1`] = ` 16 | " 17 | <<<<<< before 18 | let x = 1; 19 | 20 | ====== 21 | let x = 1; 22 | 23 | >>>>>> after 24 | " 25 | `; 26 | -------------------------------------------------------------------------------- /src/tslint-eslint-rules/no-multi-spaces/test.ts: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | -------------------------------------------------------------------------------- /src/tslint-eslint-rules/no-multi-spaces/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tslint.json", 3 | "rules": { 4 | "no-multi-spaces": true 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/tslint-eslint-rules/object-curly-spacing/__snapshots__/test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | ERROR: (object-curly-spacing) /src/tslint-eslint-rules/object-curly-spacing/test.ts[1, 11]: A space is required after '{' 7 | ERROR: (object-curly-spacing) /src/tslint-eslint-rules/object-curly-spacing/test.ts[1, 15]: A space is required before '}' 8 | 9 | ====== 10 | no error 11 | 12 | >>>>>> after 13 | " 14 | `; 15 | 16 | exports[`should be pretty after formatting 1`] = ` 17 | " 18 | <<<<<< before 19 | const x = {a:1}; 20 | 21 | ====== 22 | const x = { a: 1 }; 23 | 24 | >>>>>> after 25 | " 26 | `; 27 | -------------------------------------------------------------------------------- /src/tslint-eslint-rules/object-curly-spacing/test.ts: -------------------------------------------------------------------------------- 1 | const x = {a:1}; 2 | -------------------------------------------------------------------------------- /src/tslint-eslint-rules/object-curly-spacing/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tslint.json", 3 | "rules": { 4 | "object-curly-spacing": [true ,"always"] 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/tslint-eslint-rules/space-in-parens/__snapshots__/test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | ERROR: (space-in-parens) /src/tslint-eslint-rules/space-in-parens/test.ts[1, 10]: there should be no spaces inside this paren. 7 | ERROR: (space-in-parens) /src/tslint-eslint-rules/space-in-parens/test.ts[1, 17]: there should be no spaces inside this paren. 8 | 9 | ====== 10 | no error 11 | 12 | >>>>>> after 13 | " 14 | `; 15 | 16 | exports[`should be pretty after formatting 1`] = ` 17 | " 18 | <<<<<< before 19 | var x = ( 1 + 2 ) * 3; 20 | 21 | ====== 22 | var x = (1 + 2) * 3; 23 | 24 | >>>>>> after 25 | " 26 | `; 27 | -------------------------------------------------------------------------------- /src/tslint-eslint-rules/space-in-parens/test.ts: -------------------------------------------------------------------------------- 1 | var x = ( 1 + 2 ) * 3; 2 | -------------------------------------------------------------------------------- /src/tslint-eslint-rules/space-in-parens/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tslint.json", 3 | "rules": { 4 | "space-in-parens": [true, "never"] 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/tslint-eslint-rules/ter-arrow-parens/__snapshots__/test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | no error 7 | 8 | ====== 9 | ERROR: (ter-arrow-parens) /src/tslint-eslint-rules/ter-arrow-parens/test.ts[1, 8]: Unexpected parentheses around single function argument. 10 | 11 | >>>>>> after 12 | " 13 | `; 14 | 15 | exports[`should be pretty after formatting 1`] = ` 16 | " 17 | <<<<<< before 18 | [].map(x => 1); 19 | 20 | ====== 21 | [].map((x) => 1); 22 | 23 | >>>>>> after 24 | " 25 | `; 26 | -------------------------------------------------------------------------------- /src/tslint-eslint-rules/ter-arrow-parens/test.ts: -------------------------------------------------------------------------------- 1 | [].map(x => 1); 2 | -------------------------------------------------------------------------------- /src/tslint-eslint-rules/ter-arrow-parens/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tslint.json", 3 | "rules": { 4 | "ter-arrow-parens": [true, "as-needed"] 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/tslint-eslint-rules/ter-arrow-spacing/__snapshots__/test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | ERROR: (ter-arrow-spacing) /src/tslint-eslint-rules/ter-arrow-spacing/test.ts[1, 14]: Missing space before =>. 7 | ERROR: (ter-arrow-spacing) /src/tslint-eslint-rules/ter-arrow-spacing/test.ts[1, 14]: Missing space after =>. 8 | 9 | ====== 10 | no error 11 | 12 | >>>>>> after 13 | " 14 | `; 15 | 16 | exports[`should be pretty after formatting 1`] = ` 17 | " 18 | <<<<<< before 19 | const fn = ()=>{}; 20 | 21 | ====== 22 | const fn = () => {}; 23 | 24 | >>>>>> after 25 | " 26 | `; 27 | -------------------------------------------------------------------------------- /src/tslint-eslint-rules/ter-arrow-spacing/test.ts: -------------------------------------------------------------------------------- 1 | const fn = ()=>{}; 2 | -------------------------------------------------------------------------------- /src/tslint-eslint-rules/ter-arrow-spacing/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tslint.json", 3 | "rules": { 4 | "ter-arrow-spacing": [true, { "before": true, "after": true }] 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/tslint-eslint-rules/ter-computed-property-spacing/__snapshots__/test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | no error 7 | 8 | ====== 9 | ERROR: (ter-computed-property-spacing) /src/tslint-eslint-rules/ter-computed-property-spacing/test.ts[1, 4]: A space is required after '['. 10 | ERROR: (ter-computed-property-spacing) /src/tslint-eslint-rules/ter-computed-property-spacing/test.ts[1, 8]: A space is required before ']'. 11 | ERROR: (ter-computed-property-spacing) /src/tslint-eslint-rules/ter-computed-property-spacing/test.ts[2, 4]: A space is required after '['. 12 | ERROR: (ter-computed-property-spacing) /src/tslint-eslint-rules/ter-computed-property-spacing/test.ts[2, 10]: A space is required before ']'. 13 | 14 | >>>>>> after 15 | " 16 | `; 17 | 18 | exports[`should be pretty after formatting 1`] = ` 19 | " 20 | <<<<<< before 21 | obj[ foo ]; 22 | obj[ 'foo' ]; 23 | 24 | ====== 25 | obj[foo]; 26 | obj[\\"foo\\"]; 27 | 28 | >>>>>> after 29 | " 30 | `; 31 | -------------------------------------------------------------------------------- /src/tslint-eslint-rules/ter-computed-property-spacing/test.ts: -------------------------------------------------------------------------------- 1 | obj[ foo ]; 2 | obj[ 'foo' ]; 3 | -------------------------------------------------------------------------------- /src/tslint-eslint-rules/ter-computed-property-spacing/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tslint.json", 3 | "rules": { 4 | "ter-computed-property-spacing": [true, "always"] 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/tslint-eslint-rules/ter-func-call-spacing/__snapshots__/test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | ERROR: (ter-func-call-spacing) /src/tslint-eslint-rules/ter-func-call-spacing/test.ts[1, 12]: Unexpected space between function name and paren. 7 | 8 | ====== 9 | no error 10 | 11 | >>>>>> after 12 | " 13 | `; 14 | 15 | exports[`should be pretty after formatting 1`] = ` 16 | " 17 | <<<<<< before 18 | console.log (42); 19 | 20 | ====== 21 | console.log(42); 22 | 23 | >>>>>> after 24 | " 25 | `; 26 | -------------------------------------------------------------------------------- /src/tslint-eslint-rules/ter-func-call-spacing/test.ts: -------------------------------------------------------------------------------- 1 | console.log (42); 2 | -------------------------------------------------------------------------------- /src/tslint-eslint-rules/ter-func-call-spacing/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tslint.json", 3 | "rules": { 4 | "ter-func-call-spacing": [true, "never"] 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/tslint-eslint-rules/ter-indent/__snapshots__/test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | ERROR: (ter-indent) /src/tslint-eslint-rules/ter-indent/test.ts[2, 1]: Expected indentation of 2 spaces but found 0. 7 | 8 | ====== 9 | no error 10 | 11 | >>>>>> after 12 | " 13 | `; 14 | 15 | exports[`should be pretty after formatting 1`] = ` 16 | " 17 | <<<<<< before 18 | if (true) { 19 | console.log(123); 20 | } 21 | 22 | ====== 23 | if (true) { 24 | console.log(123); 25 | } 26 | 27 | >>>>>> after 28 | " 29 | `; 30 | -------------------------------------------------------------------------------- /src/tslint-eslint-rules/ter-indent/test.ts: -------------------------------------------------------------------------------- 1 | if (true) { 2 | console.log(123); 3 | } 4 | -------------------------------------------------------------------------------- /src/tslint-eslint-rules/ter-indent/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tslint.json", 3 | "rules": { 4 | "ter-indent": [true, 2] 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/tslint-eslint-rules/ter-max-len/__snapshots__/test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | ERROR: (ter-max-len) /src/tslint-eslint-rules/ter-max-len/test.ts[1, 1]: Line 1 exceeds the maximum line length of 80. 7 | 8 | ====== 9 | no error 10 | 11 | >>>>>> after 12 | " 13 | `; 14 | 15 | exports[`should be pretty after formatting 1`] = ` 16 | " 17 | <<<<<< before 18 | this.is.a.long().long().long().long().long().long().long().long().long().long().method(); 19 | 20 | ====== 21 | this.is.a 22 | .long() 23 | .long() 24 | .long() 25 | .long() 26 | .long() 27 | .long() 28 | .long() 29 | .long() 30 | .long() 31 | .long() 32 | .method(); 33 | 34 | >>>>>> after 35 | " 36 | `; 37 | -------------------------------------------------------------------------------- /src/tslint-eslint-rules/ter-max-len/test.ts: -------------------------------------------------------------------------------- 1 | this.is.a.long().long().long().long().long().long().long().long().long().long().method(); 2 | -------------------------------------------------------------------------------- /src/tslint-eslint-rules/ter-max-len/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tslint.json", 3 | "rules": { 4 | "ter-max-len": [true, 80] 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/tslint-eslint-rules/ter-no-irregular-whitespace/__snapshots__/test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | ERROR: (ter-no-irregular-whitespace) /src/tslint-eslint-rules/ter-no-irregular-whitespace/test.ts[1, 5]: irregular whitespace not allowed 7 | 8 | ====== 9 | no error 10 | 11 | >>>>>> after 12 | " 13 | `; 14 | 15 | exports[`should be pretty after formatting 1`] = ` 16 | " 17 | <<<<<< before 18 | let   abc; 19 | 20 | ====== 21 | let abc; 22 | 23 | >>>>>> after 24 | " 25 | `; 26 | -------------------------------------------------------------------------------- /src/tslint-eslint-rules/ter-no-irregular-whitespace/test.ts: -------------------------------------------------------------------------------- 1 | let   abc; 2 | -------------------------------------------------------------------------------- /src/tslint-eslint-rules/ter-no-irregular-whitespace/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tslint.json", 3 | "rules": { 4 | "ter-no-irregular-whitespace": [true] 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/tslint-eslint-rules/ter-no-tabs/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "useTabs": true 3 | } 4 | -------------------------------------------------------------------------------- /src/tslint-eslint-rules/ter-no-tabs/__snapshots__/test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | no error 7 | 8 | ====== 9 | ERROR: (ter-no-tabs) /src/tslint-eslint-rules/ter-no-tabs/test.ts[2, 1]: Unexpected tab character. 10 | 11 | >>>>>> after 12 | " 13 | `; 14 | 15 | exports[`should be pretty after formatting 1`] = ` 16 | " 17 | <<<<<< before 18 | if (true) { 19 | // <--- this indentation 20 | } 21 | 22 | ====== 23 | if (true) { 24 | // <--- this indentation 25 | } 26 | 27 | >>>>>> after 28 | " 29 | `; 30 | -------------------------------------------------------------------------------- /src/tslint-eslint-rules/ter-no-tabs/test.ts: -------------------------------------------------------------------------------- 1 | if (true) { 2 | // <--- this indentation 3 | } 4 | -------------------------------------------------------------------------------- /src/tslint-eslint-rules/ter-no-tabs/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tslint.json", 3 | "rules": { 4 | "ter-no-tabs": true 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/tslint-eslint-rules/ter-padded-blocks/__snapshots__/test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | no error 7 | 8 | ====== 9 | ERROR: (ter-padded-blocks) /src/tslint-eslint-rules/ter-padded-blocks/test.ts[1, 11]: Block must be padded by blank lines. 10 | ERROR: (ter-padded-blocks) /src/tslint-eslint-rules/ter-padded-blocks/test.ts[3, 1]: Block must be padded by blank lines. 11 | 12 | >>>>>> after 13 | " 14 | `; 15 | 16 | exports[`should be pretty after formatting 1`] = ` 17 | " 18 | <<<<<< before 19 | if (true) { 20 | 21 | somebody.doSomething(); 22 | 23 | } 24 | 25 | ====== 26 | if (true) { 27 | somebody.doSomething(); 28 | } 29 | 30 | >>>>>> after 31 | " 32 | `; 33 | -------------------------------------------------------------------------------- /src/tslint-eslint-rules/ter-padded-blocks/test.ts: -------------------------------------------------------------------------------- 1 | if (true) { 2 | 3 | somebody.doSomething(); 4 | 5 | } 6 | -------------------------------------------------------------------------------- /src/tslint-eslint-rules/ter-padded-blocks/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tslint.json", 3 | "rules": { 4 | "ter-padded-blocks": [true, "always"] 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/tslint-eslint-rules/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rulesDirectory": ["../../node_modules/tslint-eslint-rules/dist/rules"] 3 | } 4 | -------------------------------------------------------------------------------- /src/tslint-immutable/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rulesDirectory": ["../../node_modules/tslint-immutable/rules"] 3 | } 4 | -------------------------------------------------------------------------------- /src/tslint-microsoft-contrib/no-empty-line-after-opening-brace/__snapshots__/test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | ERROR: (no-empty-line-after-opening-brace) /src/tslint-microsoft-contrib/no-empty-line-after-opening-brace/test.ts[2, 1]: Opening brace cannot be followed by empty line 7 | 8 | ====== 9 | no error 10 | 11 | >>>>>> after 12 | " 13 | `; 14 | 15 | exports[`should be pretty after formatting 1`] = ` 16 | " 17 | <<<<<< before 18 | if (true) { 19 | 20 | console.log('something'); 21 | } 22 | 23 | ====== 24 | if (true) { 25 | console.log(\\"something\\"); 26 | } 27 | 28 | >>>>>> after 29 | " 30 | `; 31 | -------------------------------------------------------------------------------- /src/tslint-microsoft-contrib/no-empty-line-after-opening-brace/test.ts: -------------------------------------------------------------------------------- 1 | if (true) { 2 | 3 | console.log('something'); 4 | } 5 | -------------------------------------------------------------------------------- /src/tslint-microsoft-contrib/no-empty-line-after-opening-brace/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tslint.json", 3 | "rules": { 4 | "no-empty-line-after-opening-brace": true 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/tslint-microsoft-contrib/no-unnecessary-semicolons/__snapshots__/test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | ERROR: (no-unnecessary-semicolons) /src/tslint-microsoft-contrib/no-unnecessary-semicolons/test.ts[3, 2]: unnecessary semi-colon 7 | 8 | ====== 9 | no error 10 | 11 | >>>>>> after 12 | " 13 | `; 14 | 15 | exports[`should be pretty after formatting 1`] = ` 16 | " 17 | <<<<<< before 18 | while (true) { 19 | console.log('semi'); 20 | }; 21 | 22 | ====== 23 | while (true) { 24 | console.log(\\"semi\\"); 25 | } 26 | 27 | >>>>>> after 28 | " 29 | `; 30 | -------------------------------------------------------------------------------- /src/tslint-microsoft-contrib/no-unnecessary-semicolons/test.ts: -------------------------------------------------------------------------------- 1 | while (true) { 2 | console.log('semi'); 3 | }; 4 | -------------------------------------------------------------------------------- /src/tslint-microsoft-contrib/no-unnecessary-semicolons/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tslint.json", 3 | "rules": { 4 | "no-unnecessary-semicolons": true 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/tslint-microsoft-contrib/react-tsx-curly-spacing/__snapshots__/test.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | ERROR: (react-tsx-curly-spacing) /src/tslint-microsoft-contrib/react-tsx-curly-spacing/test.tsx[2, 23]: There should be no space after '{' 7 | ERROR: (react-tsx-curly-spacing) /src/tslint-microsoft-contrib/react-tsx-curly-spacing/test.tsx[3, 23]: There should be no space before '}' 8 | 9 | ====== 10 | no error 11 | 12 | >>>>>> after 13 | " 14 | `; 15 | 16 | exports[`should be pretty after formatting 1`] = ` 17 | " 18 | <<<<<< before 19 | const a = ; 20 | const b = ; 21 | const c = ; 22 | 23 | ====== 24 | const a = ; 25 | const b = ; 26 | const c = ; 27 | 28 | >>>>>> after 29 | " 30 | `; 31 | -------------------------------------------------------------------------------- /src/tslint-microsoft-contrib/react-tsx-curly-spacing/test.tsx: -------------------------------------------------------------------------------- 1 | const a = ; 2 | const b = ; 3 | const c = ; 4 | -------------------------------------------------------------------------------- /src/tslint-microsoft-contrib/react-tsx-curly-spacing/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tslint.json", 3 | "rules": { 4 | "react-tsx-curly-spacing": [true, "never"] 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/tslint-microsoft-contrib/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rulesDirectory": ["../../node_modules/tslint-microsoft-contrib"] 3 | } 4 | -------------------------------------------------------------------------------- /src/tslint-misc-rules/jsx-attribute-spacing/__snapshots__/test.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | ERROR: (jsx-attribute-spacing) /src/tslint-misc-rules/jsx-attribute-spacing/test.tsx[3, 11]: jsx attribute 'className' should not have whitespace around '=' 7 | ERROR: (jsx-attribute-spacing) /src/tslint-misc-rules/jsx-attribute-spacing/test.tsx[4, 11]: jsx attribute 'className' should not have whitespace around '=' 8 | ERROR: (jsx-attribute-spacing) /src/tslint-misc-rules/jsx-attribute-spacing/test.tsx[5, 11]: jsx attribute 'className' should not have whitespace around '=' 9 | ERROR: (jsx-attribute-spacing) /src/tslint-misc-rules/jsx-attribute-spacing/test.tsx[6, 11]: jsx attribute 'className' should not have whitespace around '=' 10 | ERROR: (jsx-attribute-spacing) /src/tslint-misc-rules/jsx-attribute-spacing/test.tsx[7, 11]: jsx attribute 'className' should not have whitespace around '=' 11 | ERROR: (jsx-attribute-spacing) /src/tslint-misc-rules/jsx-attribute-spacing/test.tsx[8, 11]: jsx attribute 'className' should not have whitespace around '=' 12 | 13 | ====== 14 | no error 15 | 16 | >>>>>> after 17 | " 18 | `; 19 | 20 | exports[`should be pretty after formatting 1`] = ` 21 | " 22 | <<<<<< before 23 | const fails = ( 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
32 | ); 33 | 34 | ====== 35 | const fails = ( 36 |
37 | 38 | 39 | 40 | 41 | 42 | 43 |
44 | ); 45 | 46 | >>>>>> after 47 | " 48 | `; 49 | -------------------------------------------------------------------------------- /src/tslint-misc-rules/jsx-attribute-spacing/test.tsx: -------------------------------------------------------------------------------- 1 | const fails = ( 2 |
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | ); 11 | -------------------------------------------------------------------------------- /src/tslint-misc-rules/jsx-attribute-spacing/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tslint.json", 3 | "rules": { 4 | "jsx-attribute-spacing": true 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/tslint-misc-rules/jsx-expression-spacing/__snapshots__/test.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | ERROR: (jsx-expression-spacing) /src/tslint-misc-rules/jsx-expression-spacing/test.tsx[3, 7]: jsx expression should have one space after opening '{' 7 | ERROR: (jsx-expression-spacing) /src/tslint-misc-rules/jsx-expression-spacing/test.tsx[3, 37]: jsx expression should have one space before closing '}' 8 | ERROR: (jsx-expression-spacing) /src/tslint-misc-rules/jsx-expression-spacing/test.tsx[4, 7]: jsx expression should have one space after opening '{' 9 | ERROR: (jsx-expression-spacing) /src/tslint-misc-rules/jsx-expression-spacing/test.tsx[5, 29]: jsx expression should have one space before closing '}' 10 | 11 | ====== 12 | ERROR: (jsx-expression-spacing) /src/tslint-misc-rules/jsx-expression-spacing/test.tsx[3, 5]: jsx expression should have one space after opening '{' 13 | ERROR: (jsx-expression-spacing) /src/tslint-misc-rules/jsx-expression-spacing/test.tsx[3, 35]: jsx expression should have one space before closing '}' 14 | ERROR: (jsx-expression-spacing) /src/tslint-misc-rules/jsx-expression-spacing/test.tsx[4, 5]: jsx expression should have one space after opening '{' 15 | ERROR: (jsx-expression-spacing) /src/tslint-misc-rules/jsx-expression-spacing/test.tsx[4, 23]: jsx expression should have one space before closing '}' 16 | ERROR: (jsx-expression-spacing) /src/tslint-misc-rules/jsx-expression-spacing/test.tsx[5, 5]: jsx expression should have one space after opening '{' 17 | ERROR: (jsx-expression-spacing) /src/tslint-misc-rules/jsx-expression-spacing/test.tsx[5, 24]: jsx expression should have one space before closing '}' 18 | 19 | >>>>>> after 20 | " 21 | `; 22 | 23 | exports[`should be pretty after formatting 1`] = ` 24 | " 25 | <<<<<< before 26 | const fails = ( 27 |
28 | {missingOpeningAndClosingSpace} 29 | { extraLeadingSpace } 30 | { extraTrailingSpace } 31 |
32 | ); 33 | 34 | ====== 35 | const fails = ( 36 |
37 | {missingOpeningAndClosingSpace} 38 | {extraLeadingSpace} 39 | {extraTrailingSpace} 40 |
41 | ); 42 | 43 | >>>>>> after 44 | " 45 | `; 46 | -------------------------------------------------------------------------------- /src/tslint-misc-rules/jsx-expression-spacing/test.tsx: -------------------------------------------------------------------------------- 1 | const fails = ( 2 |
3 | {missingOpeningAndClosingSpace} 4 | { extraLeadingSpace } 5 | { extraTrailingSpace } 6 |
7 | ); 8 | -------------------------------------------------------------------------------- /src/tslint-misc-rules/jsx-expression-spacing/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tslint.json", 3 | "rules": { 4 | "jsx-expression-spacing": true 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/tslint-misc-rules/jsx-no-closing-bracket-newline/__snapshots__/test.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | ERROR: (jsx-no-closing-bracket-newline) /src/tslint-misc-rules/jsx-no-closing-bracket-newline/test.tsx[4, 7]: closing brackets for jsx elements should not be on newlines 7 | ERROR: (jsx-no-closing-bracket-newline) /src/tslint-misc-rules/jsx-no-closing-bracket-newline/test.tsx[8, 7]: closing brackets for jsx elements should not be on newlines 8 | ERROR: (jsx-no-closing-bracket-newline) /src/tslint-misc-rules/jsx-no-closing-bracket-newline/test.tsx[12, 7]: closing brackets for jsx elements should not be on newlines 9 | 10 | ====== 11 | no error 12 | 13 | >>>>>> after 14 | " 15 | `; 16 | 17 | exports[`should be pretty after formatting 1`] = ` 18 | " 19 | <<<<<< before 20 | const fails = ( 21 | 35 | ); 36 | 37 | ====== 38 | const fails = ( 39 | 46 | ); 47 | 48 | >>>>>> after 49 | " 50 | `; 51 | -------------------------------------------------------------------------------- /src/tslint-misc-rules/jsx-no-closing-bracket-newline/test.tsx: -------------------------------------------------------------------------------- 1 | const fails = ( 2 | 16 | ); 17 | -------------------------------------------------------------------------------- /src/tslint-misc-rules/jsx-no-closing-bracket-newline/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tslint.json", 3 | "rules": { 4 | "jsx-no-closing-bracket-newline": true 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/tslint-misc-rules/no-unnecessary-parens-for-arrow-function-arguments/__snapshots__/test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | no error 7 | 8 | ====== 9 | ERROR: (no-unnecessary-parens-for-arrow-function-arguments) /src/tslint-misc-rules/no-unnecessary-parens-for-arrow-function-arguments/test.ts[1, 14]: arrow functions with one argument should not have parentheses around the argument 10 | 11 | >>>>>> after 12 | " 13 | `; 14 | 15 | exports[`should be pretty after formatting 1`] = ` 16 | " 17 | <<<<<< before 18 | const log = x => console.log(x); 19 | 20 | ====== 21 | const log = (x) => console.log(x); 22 | 23 | >>>>>> after 24 | " 25 | `; 26 | -------------------------------------------------------------------------------- /src/tslint-misc-rules/no-unnecessary-parens-for-arrow-function-arguments/test.ts: -------------------------------------------------------------------------------- 1 | const log = x => console.log(x); 2 | -------------------------------------------------------------------------------- /src/tslint-misc-rules/no-unnecessary-parens-for-arrow-function-arguments/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tslint.json", 3 | "rules": { 4 | "no-unnecessary-parens-for-arrow-function-arguments": true 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/tslint-misc-rules/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rulesDirectory": ["../../node_modules/tslint-misc-rules/rules"] 3 | } 4 | -------------------------------------------------------------------------------- /src/tslint-react/jsx-alignment/__snapshots__/test.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | ERROR: (jsx-alignment) /src/tslint-react/jsx-alignment/test.tsx[1, 18]: JSX attributes must be on a line below the opening tag 7 | ERROR: (jsx-alignment) /src/tslint-react/jsx-alignment/test.tsx[2, 5]: JSX attributes must be on their own line and vertically aligned 8 | 9 | ====== 10 | no error 11 | 12 | >>>>>> after 13 | " 14 | `; 15 | 16 | exports[`should be pretty after formatting 1`] = ` 17 | " 18 | <<<<<< before 19 | const bad = ; 22 | 23 | ====== 24 | const bad = ; 25 | 26 | >>>>>> after 27 | " 28 | `; 29 | -------------------------------------------------------------------------------- /src/tslint-react/jsx-alignment/test.tsx: -------------------------------------------------------------------------------- 1 | const bad = ; 4 | -------------------------------------------------------------------------------- /src/tslint-react/jsx-alignment/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tslint.json", 3 | "rules": { 4 | "jsx-alignment": true 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/tslint-react/jsx-curly-spacing/__snapshots__/test.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | ERROR: (jsx-curly-spacing) /src/tslint-react/jsx-curly-spacing/test.tsx[1, 28]: There should be no space before } 7 | 8 | ====== 9 | no error 10 | 11 | >>>>>> after 12 | " 13 | `; 14 | 15 | exports[`should be pretty after formatting 1`] = ` 16 | " 17 | <<<<<< before 18 | const fail = ; 19 | 20 | ====== 21 | const fail = ; 22 | 23 | >>>>>> after 24 | " 25 | `; 26 | -------------------------------------------------------------------------------- /src/tslint-react/jsx-curly-spacing/test.tsx: -------------------------------------------------------------------------------- 1 | const fail = ; 2 | -------------------------------------------------------------------------------- /src/tslint-react/jsx-curly-spacing/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tslint.json", 3 | "rules": { 4 | "jsx-curly-spacing": [true, "never"] 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/tslint-react/jsx-equals-spacing/__snapshots__/test.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | ERROR: (jsx-equals-spacing) /src/tslint-react/jsx-equals-spacing/test.tsx[1, 9]: There should be no space before '=' 7 | ERROR: (jsx-equals-spacing) /src/tslint-react/jsx-equals-spacing/test.tsx[1, 11]: There should be no space after '=' 8 | 9 | ====== 10 | no error 11 | 12 | >>>>>> after 13 | " 14 | `; 15 | 16 | exports[`should be pretty after formatting 1`] = ` 17 | " 18 | <<<<<< before 19 | 20 | 21 | ====== 22 | ; 23 | 24 | >>>>>> after 25 | " 26 | `; 27 | -------------------------------------------------------------------------------- /src/tslint-react/jsx-equals-spacing/test.tsx: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/tslint-react/jsx-equals-spacing/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tslint.json", 3 | "rules": { 4 | "jsx-equals-spacing": [true, "never"] 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/tslint-react/jsx-no-multiline-js/__snapshots__/test.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | ERROR: (jsx-no-multiline-js) /src/tslint-react/jsx-no-multiline-js/test.tsx[2, 1]: Multiline JS expressions inside JSX are forbidden 7 | 8 | ====== 9 | no error 10 | 11 | >>>>>> after 12 | " 13 | `; 14 | 15 | exports[`should be pretty after formatting 1`] = ` 16 | " 17 | <<<<<< before 18 | const printBadStr =
19 | {test ? 20 | \\"a!=b\\" 21 | : 22 | \\"b!=a\\" 23 | } 24 |
; 25 | 26 | ====== 27 | const printBadStr =
{test ? \\"a!=b\\" : \\"b!=a\\"}
; 28 | 29 | >>>>>> after 30 | " 31 | `; 32 | -------------------------------------------------------------------------------- /src/tslint-react/jsx-no-multiline-js/test.tsx: -------------------------------------------------------------------------------- 1 | const printBadStr =
2 | {test ? 3 | "a!=b" 4 | : 5 | "b!=a" 6 | } 7 |
; 8 | -------------------------------------------------------------------------------- /src/tslint-react/jsx-no-multiline-js/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tslint.json", 3 | "rules": { 4 | "jsx-no-multiline-js": true 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/tslint-react/jsx-space-before-trailing-slash/__snapshots__/test.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | ERROR: (jsx-space-before-trailing-slash) /src/tslint-react/jsx-space-before-trailing-slash/test.tsx[1, 1]: Self-closing JSX elements must have a space before the '/>' part 7 | 8 | ====== 9 | no error 10 | 11 | >>>>>> after 12 | " 13 | `; 14 | 15 | exports[`should be pretty after formatting 1`] = ` 16 | " 17 | <<<<<< before 18 | 19 | 20 | ====== 21 | ; 22 | 23 | >>>>>> after 24 | " 25 | `; 26 | -------------------------------------------------------------------------------- /src/tslint-react/jsx-space-before-trailing-slash/test.tsx: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/tslint-react/jsx-space-before-trailing-slash/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tslint.json", 3 | "rules": { 4 | "jsx-space-before-trailing-slash": true 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/tslint-react/jsx-wrap-multiline/__snapshots__/test.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | ERROR: (jsx-wrap-multiline) /src/tslint-react/jsx-wrap-multiline/test.tsx[1, 22]: Multiline JSX elements must be wrapped in parentheses 7 | 8 | ====== 9 | no error 10 | 11 | >>>>>> after 12 | " 13 | `; 14 | 15 | exports[`should be pretty after formatting 1`] = ` 16 | " 17 | <<<<<< before 18 | const badMultiline =
22 | {children} 23 |
; 24 | 25 | ====== 26 | const badMultiline = ( 27 |
28 | {children} 29 |
30 | ); 31 | 32 | >>>>>> after 33 | " 34 | `; 35 | -------------------------------------------------------------------------------- /src/tslint-react/jsx-wrap-multiline/test.tsx: -------------------------------------------------------------------------------- 1 | const badMultiline =
5 | {children} 6 |
; 7 | -------------------------------------------------------------------------------- /src/tslint-react/jsx-wrap-multiline/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tslint.json", 3 | "rules": { 4 | "jsx-wrap-multiline": true 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/tslint-react/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rulesDirectory": ["../../node_modules/tslint-react/rules"] 3 | } 4 | -------------------------------------------------------------------------------- /src/tslint/align/__snapshots__/test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | ERROR: (align) /src/tslint/align/test.ts[2, 3]: parameters are not aligned 7 | 8 | ====== 9 | no error 10 | 11 | >>>>>> after 12 | " 13 | `; 14 | 15 | exports[`should be pretty after formatting 1`] = ` 16 | " 17 | <<<<<< before 18 | export function test(a: number, 19 | b: number) {} 20 | 21 | ====== 22 | export function test(a: number, b: number) {} 23 | 24 | >>>>>> after 25 | " 26 | `; 27 | -------------------------------------------------------------------------------- /src/tslint/align/test.ts: -------------------------------------------------------------------------------- 1 | export function test(a: number, 2 | b: number) {} 3 | -------------------------------------------------------------------------------- /src/tslint/align/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "align": [ 4 | true, 5 | "arguments", 6 | "parameters", 7 | "statements" 8 | ] 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/tslint/arrow-parens/__snapshots__/test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | no error 7 | 8 | ====== 9 | ERROR: (arrow-parens) /src/tslint/arrow-parens/test.ts[1, 9]: Parentheses are prohibited around the parameter in this single parameter arrow function 10 | 11 | >>>>>> after 12 | " 13 | `; 14 | 15 | exports[`should be pretty after formatting 1`] = ` 16 | " 17 | <<<<<< before 18 | [].map(x => 1); 19 | 20 | ====== 21 | [].map((x) => 1); 22 | 23 | >>>>>> after 24 | " 25 | `; 26 | -------------------------------------------------------------------------------- /src/tslint/arrow-parens/test.ts: -------------------------------------------------------------------------------- 1 | [].map(x => 1); 2 | -------------------------------------------------------------------------------- /src/tslint/arrow-parens/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "arrow-parens": [true, "ban-single-arg-parens"] 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /src/tslint/eofline/__snapshots__/test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | ERROR: (eofline) /src/tslint/eofline/test.ts[1, 23]: file should end with a newline 7 | 8 | ====== 9 | no error 10 | 11 | >>>>>> after 12 | " 13 | `; 14 | 15 | exports[`should be pretty after formatting 1`] = ` 16 | " 17 | <<<<<< before 18 | console.log(\\"no-eof\\"); 19 | ====== 20 | console.log(\\"no-eof\\"); 21 | 22 | >>>>>> after 23 | " 24 | `; 25 | -------------------------------------------------------------------------------- /src/tslint/eofline/test.ts: -------------------------------------------------------------------------------- 1 | console.log("no-eof"); -------------------------------------------------------------------------------- /src/tslint/eofline/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "eofline": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /src/tslint/import-spacing/__snapshots__/test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | ERROR: (import-spacing) /src/tslint/import-spacing/test.ts[1, 1]: Add space after 'import' 7 | ERROR: (import-spacing) /src/tslint/import-spacing/test.ts[1, 7]: Add space after '*' 8 | 9 | ====== 10 | no error 11 | 12 | >>>>>> after 13 | " 14 | `; 15 | 16 | exports[`should be pretty after formatting 1`] = ` 17 | " 18 | <<<<<< before 19 | import*as ts from \\"typescript\\"; 20 | 21 | ====== 22 | import * as ts from \\"typescript\\"; 23 | 24 | >>>>>> after 25 | " 26 | `; 27 | -------------------------------------------------------------------------------- /src/tslint/import-spacing/test.ts: -------------------------------------------------------------------------------- 1 | import*as ts from "typescript"; 2 | -------------------------------------------------------------------------------- /src/tslint/import-spacing/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "import-spacing": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /src/tslint/indent/__snapshots__/test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | ERROR: (indent) /src/tslint/indent/test.ts[2, 1]: 2 space indentation expected 7 | 8 | ====== 9 | no error 10 | 11 | >>>>>> after 12 | " 13 | `; 14 | 15 | exports[`should be pretty after formatting 1`] = ` 16 | " 17 | <<<<<< before 18 | if (true) { 19 | console.log(\\"1-tab\\"); 20 | } 21 | 22 | ====== 23 | if (true) { 24 | console.log(\\"1-tab\\"); 25 | } 26 | 27 | >>>>>> after 28 | " 29 | `; 30 | -------------------------------------------------------------------------------- /src/tslint/indent/test.ts: -------------------------------------------------------------------------------- 1 | if (true) { 2 | console.log("1-tab"); 3 | } 4 | -------------------------------------------------------------------------------- /src/tslint/indent/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "indent": [true, "spaces", 2] 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /src/tslint/linebreak-style/__snapshots__/test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | ERROR: (linebreak-style) /src/tslint/linebreak-style/test.ts[1, 1]: Expected linebreak to be 'LF' 7 | 8 | ====== 9 | no error 10 | 11 | >>>>>> after 12 | " 13 | `; 14 | 15 | exports[`should be pretty after formatting 1`] = ` 16 | " 17 | <<<<<< before 18 | 19 | 20 | ====== 21 | 22 | >>>>>> after 23 | " 24 | `; 25 | -------------------------------------------------------------------------------- /src/tslint/linebreak-style/test.ts: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/tslint/linebreak-style/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "linebreak-style": [true] 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /src/tslint/max-line-length/__snapshots__/test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | ERROR: (max-line-length) /src/tslint/max-line-length/test.ts[1, 1]: Exceeds maximum line length of 80 7 | 8 | ====== 9 | no error 10 | 11 | >>>>>> after 12 | " 13 | `; 14 | 15 | exports[`should be pretty after formatting 1`] = ` 16 | " 17 | <<<<<< before 18 | this.is.a.long().long().long().long().long().long().long().long().long().long().method(); 19 | 20 | ====== 21 | this.is.a 22 | .long() 23 | .long() 24 | .long() 25 | .long() 26 | .long() 27 | .long() 28 | .long() 29 | .long() 30 | .long() 31 | .long() 32 | .method(); 33 | 34 | >>>>>> after 35 | " 36 | `; 37 | -------------------------------------------------------------------------------- /src/tslint/max-line-length/test.ts: -------------------------------------------------------------------------------- 1 | this.is.a.long().long().long().long().long().long().long().long().long().long().method(); 2 | -------------------------------------------------------------------------------- /src/tslint/max-line-length/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "max-line-length": [true, 80] 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /src/tslint/new-parens/__snapshots__/test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | ERROR: (new-parens) /src/tslint/new-parens/test.ts[2, 11]: Parentheses are required when invoking a constructor 7 | 8 | ====== 9 | no error 10 | 11 | >>>>>> after 12 | " 13 | `; 14 | 15 | exports[`should be pretty after formatting 1`] = ` 16 | " 17 | <<<<<< before 18 | class X {} 19 | const x = new X; 20 | 21 | ====== 22 | class X {} 23 | const x = new X(); 24 | 25 | >>>>>> after 26 | " 27 | `; 28 | -------------------------------------------------------------------------------- /src/tslint/new-parens/test.ts: -------------------------------------------------------------------------------- 1 | class X {} 2 | const x = new X; 3 | -------------------------------------------------------------------------------- /src/tslint/new-parens/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "new-parens": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /src/tslint/newline-per-chained-call/__snapshots__/test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | ERROR: (newline-per-chained-call) /src/tslint/newline-per-chained-call/test.ts[4, 6]: When chaining calls, put method calls on new lines. 7 | ERROR: (newline-per-chained-call) /src/tslint/newline-per-chained-call/test.ts[4, 12]: When chaining calls, put method calls on new lines. 8 | 9 | ====== 10 | ERROR: (newline-per-chained-call) /src/tslint/newline-per-chained-call/test.ts[1, 6]: When chaining calls, put method calls on new lines. 11 | ERROR: (newline-per-chained-call) /src/tslint/newline-per-chained-call/test.ts[3, 6]: When chaining calls, put method calls on new lines. 12 | ERROR: (newline-per-chained-call) /src/tslint/newline-per-chained-call/test.ts[3, 12]: When chaining calls, put method calls on new lines. 13 | 14 | >>>>>> after 15 | " 16 | `; 17 | 18 | exports[`should be pretty after formatting 1`] = ` 19 | " 20 | <<<<<< before 21 | foo() 22 | .bar() 23 | 24 | foo().bar().baz() 25 | 26 | ====== 27 | foo().bar(); 28 | 29 | foo().bar().baz(); 30 | 31 | >>>>>> after 32 | " 33 | `; 34 | -------------------------------------------------------------------------------- /src/tslint/newline-per-chained-call/test.ts: -------------------------------------------------------------------------------- 1 | foo() 2 | .bar() 3 | 4 | foo().bar().baz() 5 | -------------------------------------------------------------------------------- /src/tslint/newline-per-chained-call/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "newline-per-chained-call": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /src/tslint/no-consecutive-blank-lines/__snapshots__/test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | ERROR: (no-consecutive-blank-lines) /src/tslint/no-consecutive-blank-lines/test.ts[3, 1]: Consecutive blank lines are forbidden 7 | 8 | ====== 9 | no error 10 | 11 | >>>>>> after 12 | " 13 | `; 14 | 15 | exports[`should be pretty after formatting 1`] = ` 16 | " 17 | <<<<<< before 18 | console.log(1); 19 | 20 | 21 | console.log(2); 22 | 23 | ====== 24 | console.log(1); 25 | 26 | console.log(2); 27 | 28 | >>>>>> after 29 | " 30 | `; 31 | -------------------------------------------------------------------------------- /src/tslint/no-consecutive-blank-lines/test.ts: -------------------------------------------------------------------------------- 1 | console.log(1); 2 | 3 | 4 | console.log(2); 5 | -------------------------------------------------------------------------------- /src/tslint/no-consecutive-blank-lines/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "no-consecutive-blank-lines": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /src/tslint/no-irregular-whitespace/__snapshots__/test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | ERROR: (no-irregular-whitespace) /src/tslint/no-irregular-whitespace/test.ts[1, 5]: Irregular whitespace not allowed 7 | 8 | ====== 9 | no error 10 | 11 | >>>>>> after 12 | " 13 | `; 14 | 15 | exports[`should be pretty after formatting 1`] = ` 16 | " 17 | <<<<<< before 18 | let   abc; 19 | 20 | ====== 21 | let abc; 22 | 23 | >>>>>> after 24 | " 25 | `; 26 | -------------------------------------------------------------------------------- /src/tslint/no-irregular-whitespace/test.ts: -------------------------------------------------------------------------------- 1 | let   abc; 2 | -------------------------------------------------------------------------------- /src/tslint/no-irregular-whitespace/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "no-irregular-whitespace": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /src/tslint/no-trailing-whitespace/__snapshots__/test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | ERROR: (no-trailing-whitespace) /src/tslint/no-trailing-whitespace/test.ts[1, 19]: trailing whitespace 7 | 8 | ====== 9 | no error 10 | 11 | >>>>>> after 12 | " 13 | `; 14 | 15 | exports[`should be pretty after formatting 1`] = ` 16 | " 17 | <<<<<< before 18 | console.log('->'); 19 | 20 | ====== 21 | console.log(\\"->\\"); 22 | 23 | >>>>>> after 24 | " 25 | `; 26 | -------------------------------------------------------------------------------- /src/tslint/no-trailing-whitespace/test.ts: -------------------------------------------------------------------------------- 1 | console.log('->'); 2 | -------------------------------------------------------------------------------- /src/tslint/no-trailing-whitespace/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "no-trailing-whitespace": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /src/tslint/number-literal-format/__snapshots__/test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | ERROR: (number-literal-format) /src/tslint/number-literal-format/test.ts[1, 13]: Number literal should begin with '0.' and not just '.'. 7 | ERROR: (number-literal-format) /src/tslint/number-literal-format/test.ts[1, 26]: Number literal should not have a trailing '0'. 8 | 9 | ====== 10 | ERROR: (number-literal-format) /src/tslint/number-literal-format/test.ts[1, 20]: Hexadecimal number literal should be uppercase. 11 | 12 | >>>>>> after 13 | " 14 | `; 15 | 16 | exports[`should be pretty after formatting 1`] = ` 17 | " 18 | <<<<<< before 19 | const ns = [.123, 0xABC, 1.20]; 20 | 21 | ====== 22 | const ns = [0.123, 0xabc, 1.2]; 23 | 24 | >>>>>> after 25 | " 26 | `; 27 | -------------------------------------------------------------------------------- /src/tslint/number-literal-format/test.ts: -------------------------------------------------------------------------------- 1 | const ns = [.123, 0xABC, 1.20]; 2 | -------------------------------------------------------------------------------- /src/tslint/number-literal-format/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "number-literal-format": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /src/tslint/object-literal-key-quotes/__snapshots__/test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | ERROR: (object-literal-key-quotes) /src/tslint/object-literal-key-quotes/test.ts[2, 3]: Unnecessarily quoted property 'quoted' found. 7 | 8 | ====== 9 | no error 10 | 11 | >>>>>> after 12 | " 13 | `; 14 | 15 | exports[`should be pretty after formatting 1`] = ` 16 | " 17 | <<<<<< before 18 | const x = { 19 | 'quoted': true, 20 | }; 21 | 22 | ====== 23 | const x = { 24 | quoted: true, 25 | }; 26 | 27 | >>>>>> after 28 | " 29 | `; 30 | -------------------------------------------------------------------------------- /src/tslint/object-literal-key-quotes/test.ts: -------------------------------------------------------------------------------- 1 | const x = { 2 | 'quoted': true, 3 | }; 4 | -------------------------------------------------------------------------------- /src/tslint/object-literal-key-quotes/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "object-literal-key-quotes": [true, "as-needed"] 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /src/tslint/one-line/__snapshots__/test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | ERROR: (one-line) /src/tslint/one-line/test.ts[2, 1]: misplaced opening brace 7 | 8 | ====== 9 | no error 10 | 11 | >>>>>> after 12 | " 13 | `; 14 | 15 | exports[`should be pretty after formatting 1`] = ` 16 | " 17 | <<<<<< before 18 | function fn() 19 | { 20 | 21 | } 22 | 23 | ====== 24 | function fn() {} 25 | 26 | >>>>>> after 27 | " 28 | `; 29 | -------------------------------------------------------------------------------- /src/tslint/one-line/test.ts: -------------------------------------------------------------------------------- 1 | function fn() 2 | { 3 | 4 | } 5 | -------------------------------------------------------------------------------- /src/tslint/one-line/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "one-line": [ 4 | true, 5 | "check-open-brace", 6 | "check-catch", 7 | "check-else", 8 | "check-finally", 9 | "check-whitespace" 10 | ] 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/tslint/quotemark/__snapshots__/test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | ERROR: (quotemark) /src/tslint/quotemark/test.ts[1, 13]: ' should be \\" 7 | 8 | ====== 9 | no error 10 | 11 | >>>>>> after 12 | " 13 | `; 14 | 15 | exports[`should be pretty after formatting 1`] = ` 16 | " 17 | <<<<<< before 18 | console.log('quotes'); 19 | 20 | ====== 21 | console.log(\\"quotes\\"); 22 | 23 | >>>>>> after 24 | " 25 | `; 26 | -------------------------------------------------------------------------------- /src/tslint/quotemark/test.ts: -------------------------------------------------------------------------------- 1 | console.log('quotes'); 2 | -------------------------------------------------------------------------------- /src/tslint/quotemark/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "quotemark": [true, "double"] 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /src/tslint/semicolon/__snapshots__/test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | ERROR: (semicolon) /src/tslint/semicolon/test.ts[1, 20]: Missing semicolon 7 | 8 | ====== 9 | no error 10 | 11 | >>>>>> after 12 | " 13 | `; 14 | 15 | exports[`should be pretty after formatting 1`] = ` 16 | " 17 | <<<<<< before 18 | console.log('semi') 19 | 20 | ====== 21 | console.log(\\"semi\\"); 22 | 23 | >>>>>> after 24 | " 25 | `; 26 | -------------------------------------------------------------------------------- /src/tslint/semicolon/test.ts: -------------------------------------------------------------------------------- 1 | console.log('semi') 2 | -------------------------------------------------------------------------------- /src/tslint/semicolon/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "semicolon":[true, "always"] 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /src/tslint/space-before-function-paren/__snapshots__/test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | no error 7 | 8 | ====== 9 | ERROR: (space-before-function-paren) /src/tslint/space-before-function-paren/test.ts[1, 24]: Spaces before function parens are disallowed 10 | 11 | >>>>>> after 12 | " 13 | `; 14 | 15 | exports[`should be pretty after formatting 1`] = ` 16 | " 17 | <<<<<< before 18 | export default function() {} 19 | 20 | ====== 21 | export default function () {} 22 | 23 | >>>>>> after 24 | " 25 | `; 26 | -------------------------------------------------------------------------------- /src/tslint/space-before-function-paren/test.ts: -------------------------------------------------------------------------------- 1 | export default function() {} 2 | -------------------------------------------------------------------------------- /src/tslint/space-before-function-paren/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "space-before-function-paren": [true, "never"] 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /src/tslint/space-within-parens/__snapshots__/test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | no error 7 | 8 | ====== 9 | ERROR: (space-within-parens) /src/tslint/space-within-parens/test.ts[1, 12]: Needs 1 whitespace within parentheses 10 | ERROR: (space-within-parens) /src/tslint/space-within-parens/test.ts[1, 21]: Needs 1 whitespace within parentheses 11 | 12 | >>>>>> after 13 | " 14 | `; 15 | 16 | exports[`should be pretty after formatting 1`] = ` 17 | " 18 | <<<<<< before 19 | function x( a: string ) {} 20 | 21 | ====== 22 | function x(a: string) {} 23 | 24 | >>>>>> after 25 | " 26 | `; 27 | -------------------------------------------------------------------------------- /src/tslint/space-within-parens/test.ts: -------------------------------------------------------------------------------- 1 | function x( a: string ) {} 2 | -------------------------------------------------------------------------------- /src/tslint/space-within-parens/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "space-within-parens": [true, 1] 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /src/tslint/trailing-comma/__snapshots__/test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | ERROR: (trailing-comma) /src/tslint/trailing-comma/test.ts[1, 17]: Unnecessary trailing comma 7 | ERROR: (trailing-comma) /src/tslint/trailing-comma/test.ts[2, 13]: Unnecessary trailing comma 8 | 9 | ====== 10 | no error 11 | 12 | >>>>>> after 13 | " 14 | `; 15 | 16 | exports[`should be pretty after formatting 1`] = ` 17 | " 18 | <<<<<< before 19 | const x = { a: 1, }; 20 | const y = [1,]; 21 | 22 | ====== 23 | const x = { a: 1 }; 24 | const y = [1]; 25 | 26 | >>>>>> after 27 | " 28 | `; 29 | -------------------------------------------------------------------------------- /src/tslint/trailing-comma/test.ts: -------------------------------------------------------------------------------- 1 | const x = { a: 1, }; 2 | const y = [1,]; 3 | -------------------------------------------------------------------------------- /src/tslint/trailing-comma/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "trailing-comma": [ 4 | true, 5 | { "singleline": "never" }, 6 | { "multiline": "never" } 7 | ] 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/tslint/type-literal-delimiter/__snapshots__/test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | ERROR: (type-literal-delimiter) /src/tslint/type-literal-delimiter/test.ts[2, 12]: Expected type literal to use ';' instead of ','. 7 | ERROR: (type-literal-delimiter) /src/tslint/type-literal-delimiter/test.ts[3, 11]: Expected type literal to use ';' to separate members. 8 | 9 | ====== 10 | no error 11 | 12 | >>>>>> after 13 | " 14 | `; 15 | 16 | exports[`should be pretty after formatting 1`] = ` 17 | " 18 | <<<<<< before 19 | type T = { 20 | x: number, 21 | y: string 22 | }; 23 | 24 | ====== 25 | type T = { 26 | x: number; 27 | y: string; 28 | }; 29 | 30 | >>>>>> after 31 | " 32 | `; 33 | -------------------------------------------------------------------------------- /src/tslint/type-literal-delimiter/test.ts: -------------------------------------------------------------------------------- 1 | type T = { 2 | x: number, 3 | y: string 4 | }; 5 | -------------------------------------------------------------------------------- /src/tslint/type-literal-delimiter/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "type-literal-delimiter": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /src/tslint/typedef-whitespace/__snapshots__/test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | ERROR: (typedef-whitespace) /src/tslint/typedef-whitespace/test.ts[1, 6]: expected nospace before colon in variable-declaration 7 | 8 | ====== 9 | no error 10 | 11 | >>>>>> after 12 | " 13 | `; 14 | 15 | exports[`should be pretty after formatting 1`] = ` 16 | " 17 | <<<<<< before 18 | let x : string; 19 | 20 | ====== 21 | let x: string; 22 | 23 | >>>>>> after 24 | " 25 | `; 26 | -------------------------------------------------------------------------------- /src/tslint/typedef-whitespace/test.ts: -------------------------------------------------------------------------------- 1 | let x : string; 2 | -------------------------------------------------------------------------------- /src/tslint/typedef-whitespace/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "typedef-whitespace": [ 4 | true, 5 | { 6 | "call-signature": "nospace", 7 | "index-signature": "nospace", 8 | "parameter": "nospace", 9 | "property-declaration": "nospace", 10 | "variable-declaration": "nospace" 11 | }, 12 | { 13 | "call-signature": "onespace", 14 | "index-signature": "onespace", 15 | "parameter": "onespace", 16 | "property-declaration": "onespace", 17 | "variable-declaration": "onespace" 18 | } 19 | ] 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/tslint/whitespace/__snapshots__/test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | ERROR: (whitespace) /src/tslint/whitespace/test.ts[1, 3]: missing whitespace 7 | ERROR: (whitespace) /src/tslint/whitespace/test.ts[1, 9]: missing whitespace 8 | 9 | ====== 10 | no error 11 | 12 | >>>>>> after 13 | " 14 | `; 15 | 16 | exports[`should be pretty after formatting 1`] = ` 17 | " 18 | <<<<<< before 19 | if(true){ 20 | 21 | } 22 | 23 | ====== 24 | if (true) { 25 | } 26 | 27 | >>>>>> after 28 | " 29 | `; 30 | -------------------------------------------------------------------------------- /src/tslint/whitespace/test.ts: -------------------------------------------------------------------------------- 1 | if(true){ 2 | 3 | } 4 | -------------------------------------------------------------------------------- /src/tslint/whitespace/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "whitespace": [true, 4 | "check-branch", 5 | "check-decl", 6 | "check-operator", 7 | "check-module", 8 | "check-preblock", 9 | "check-separator", 10 | "check-type", 11 | "check-typecast" 12 | ] 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/vrsource-tslint-rules/conditional-expression-parens/__snapshots__/test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | no error 7 | 8 | ====== 9 | ERROR: (conditional-expression-parens) /src/vrsource-tslint-rules/conditional-expression-parens/test.ts[1, 9]: Expression clause must be parenthesized 10 | 11 | >>>>>> after 12 | " 13 | `; 14 | 15 | exports[`should be pretty after formatting 1`] = ` 16 | " 17 | <<<<<< before 18 | let x = (y > 30) ? \\"left\\" : \\"right\\"; 19 | 20 | ====== 21 | let x = y > 30 ? \\"left\\" : \\"right\\"; 22 | 23 | >>>>>> after 24 | " 25 | `; 26 | -------------------------------------------------------------------------------- /src/vrsource-tslint-rules/conditional-expression-parens/test.ts: -------------------------------------------------------------------------------- 1 | let x = (y > 30) ? "left" : "right"; 2 | -------------------------------------------------------------------------------- /src/vrsource-tslint-rules/conditional-expression-parens/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tslint.json", 3 | "rules": { 4 | "conditional-expression-parens": true 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/vrsource-tslint-rules/literal-spacing/__snapshots__/test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | ERROR: (literal-spacing) /src/vrsource-tslint-rules/literal-spacing/test.ts[1, 9]: Missing whitespace 7 | ERROR: (literal-spacing) /src/vrsource-tslint-rules/literal-spacing/test.ts[1, 10]: Missing whitespace 8 | ERROR: (literal-spacing) /src/vrsource-tslint-rules/literal-spacing/test.ts[3, 12]: Missing whitespace 9 | ERROR: (literal-spacing) /src/vrsource-tslint-rules/literal-spacing/test.ts[3, 15]: Missing whitespace 10 | ERROR: (literal-spacing) /src/vrsource-tslint-rules/literal-spacing/test.ts[5, 12]: Found extra space 11 | ERROR: (literal-spacing) /src/vrsource-tslint-rules/literal-spacing/test.ts[5, 14]: Found extra space 12 | 13 | ====== 14 | no error 15 | 16 | >>>>>> after 17 | " 18 | `; 19 | 20 | exports[`should be pretty after formatting 1`] = ` 21 | " 22 | <<<<<< before 23 | import {x} from 'x'; 24 | 25 | const y = {a:1}; 26 | 27 | const z = [ 0 ]; 28 | 29 | ====== 30 | import { x } from \\"x\\"; 31 | 32 | const y = { a: 1 }; 33 | 34 | const z = [0]; 35 | 36 | >>>>>> after 37 | " 38 | `; 39 | -------------------------------------------------------------------------------- /src/vrsource-tslint-rules/literal-spacing/test.ts: -------------------------------------------------------------------------------- 1 | import {x} from 'x'; 2 | 3 | const y = {a:1}; 4 | 5 | const z = [ 0 ]; 6 | -------------------------------------------------------------------------------- /src/vrsource-tslint-rules/literal-spacing/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tslint.json", 3 | "rules": { 4 | "literal-spacing": [ 5 | true, 6 | { 7 | "array": ["never"], 8 | "object": ["always"], 9 | "import": ["always"] 10 | } 11 | ] 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/vrsource-tslint-rules/multiline-arrow/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "arrowParens": "avoid" 3 | } 4 | -------------------------------------------------------------------------------- /src/vrsource-tslint-rules/multiline-arrow/__snapshots__/test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should affect error message after formatting 1`] = ` 4 | " 5 | <<<<<< before 6 | no error 7 | 8 | ====== 9 | ERROR: (multiline-arrow) /src/vrsource-tslint-rules/multiline-arrow/test.ts[1, 11]: Multi-line arrow function must have parentheses around parameters. 10 | 11 | >>>>>> after 12 | " 13 | `; 14 | 15 | exports[`should be pretty after formatting 1`] = ` 16 | " 17 | <<<<<< before 18 | const x = a => longlonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglong; 19 | 20 | ====== 21 | const x = a => 22 | longlonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglong; 23 | 24 | >>>>>> after 25 | " 26 | `; 27 | -------------------------------------------------------------------------------- /src/vrsource-tslint-rules/multiline-arrow/test.ts: -------------------------------------------------------------------------------- 1 | const x = a => longlonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglong; 2 | -------------------------------------------------------------------------------- /src/vrsource-tslint-rules/multiline-arrow/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tslint.json", 3 | "rules": { 4 | "multiline-arrow": [true, "require-parens"] 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/vrsource-tslint-rules/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rulesDirectory": ["../../node_modules/vrsource-tslint-rules/rules"] 3 | } 4 | -------------------------------------------------------------------------------- /tools/__snapshots__/checker.test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`should be able to check multiple config files 1`] = ` 4 | "[error] Conflict rule(s) detected in /fixtures/tslint.all.json: 5 | [error] align 6 | [error] arrow-parens 7 | [error] eofline 8 | [error] import-spacing 9 | [error] indent 10 | [error] linebreak-style 11 | [error] max-line-length 12 | [error] new-parens 13 | [error] newline-per-chained-call 14 | [error] no-consecutive-blank-lines 15 | [error] no-irregular-whitespace 16 | [error] no-trailing-whitespace 17 | [error] number-literal-format 18 | [error] object-literal-key-quotes 19 | [error] one-line 20 | [error] quotemark 21 | [error] semicolon 22 | [error] space-before-function-paren 23 | [error] space-within-parens 24 | [error] trailing-comma 25 | [error] type-literal-delimiter 26 | [error] typedef-whitespace 27 | [error] whitespace 28 | [error] Unexpected number in JSON at position 1 in /fixtures/tslint.error.json" 29 | `; 30 | 31 | exports[`should show nothing for conflict rules that is disabled 1`] = `""`; 32 | 33 | exports[`should show nothing for non-conflict rules 1`] = `""`; 34 | 35 | exports[`should show usage if there is no filePath 1`] = `"[log] Usage: tslint-config-prettier-check ..."`; 36 | 37 | exports[`should throw conflict rules 1`] = ` 38 | "[error] Conflict rule(s) detected in /fixtures/tslint.all.json: 39 | [error] align 40 | [error] arrow-parens 41 | [error] eofline 42 | [error] import-spacing 43 | [error] indent 44 | [error] linebreak-style 45 | [error] max-line-length 46 | [error] new-parens 47 | [error] newline-per-chained-call 48 | [error] no-consecutive-blank-lines 49 | [error] no-irregular-whitespace 50 | [error] no-trailing-whitespace 51 | [error] number-literal-format 52 | [error] object-literal-key-quotes 53 | [error] one-line 54 | [error] quotemark 55 | [error] semicolon 56 | [error] space-before-function-paren 57 | [error] space-within-parens 58 | [error] trailing-comma 59 | [error] type-literal-delimiter 60 | [error] typedef-whitespace 61 | [error] whitespace" 62 | `; 63 | 64 | exports[`should throw parsing error for invalid config 1`] = `"[error] Unexpected number in JSON at position 1 in /fixtures/tslint.error.json"`; 65 | -------------------------------------------------------------------------------- /tools/checker.test.ts: -------------------------------------------------------------------------------- 1 | import * as path from "path"; 2 | import { check } from "./checker"; 3 | 4 | expect.addSnapshotSerializer({ 5 | print: (value: string, serializer) => 6 | serializer(value.replace(process.cwd(), "")), 7 | test: (value) => 8 | typeof value === "string" && value.indexOf(process.cwd()) !== -1, 9 | }); 10 | 11 | const messages: string[] = []; 12 | 13 | mockConsole("log"); 14 | mockConsole("error"); 15 | 16 | beforeEach(() => { 17 | messages.splice(0, messages.length); 18 | process.exitCode = 0; 19 | }); 20 | 21 | afterAll(() => { 22 | process.exitCode = 0; 23 | }); 24 | 25 | it("should throw conflict rules", () => { 26 | checkFixture("all"); 27 | expect(getMessage()).toMatchSnapshot(); 28 | expect(process.exitCode).toBe(1); 29 | }); 30 | 31 | it("should throw parsing error for invalid config", () => { 32 | checkFixture("error"); 33 | expect(getMessage()).toMatchSnapshot(); 34 | expect(process.exitCode).toBe(1); 35 | }); 36 | 37 | it("should show nothing for non-conflict rules", () => { 38 | checkFixture("empty"); 39 | expect(getMessage()).toMatchSnapshot(); 40 | expect(process.exitCode).toBe(0); 41 | }); 42 | 43 | it("should show nothing for conflict rules that is disabled", () => { 44 | checkFixture("false"); 45 | expect(getMessage()).toMatchSnapshot(); 46 | expect(process.exitCode).toBe(0); 47 | }); 48 | 49 | it("should show usage if there is no filePath", () => { 50 | checkFixture(); 51 | expect(getMessage()).toMatchSnapshot(); 52 | expect(process.exitCode).toBe(0); 53 | }); 54 | 55 | it("should be able to check multiple config files", () => { 56 | checkFixture("all", "empty", "error"); 57 | expect(getMessage()).toMatchSnapshot(); 58 | expect(process.exitCode).toBe(1); 59 | }); 60 | 61 | function mockConsole(id: keyof typeof console) { 62 | const mockedConsoleLog = jest 63 | .spyOn(console, id) 64 | .mockImplementation((message: string) => 65 | messages.push( 66 | message 67 | .split("\n") 68 | .map((x) => `[${id}] ${x}`) 69 | .join("\n"), 70 | ), 71 | ); 72 | } 73 | 74 | function getMessage() { 75 | return messages.join("\n"); 76 | } 77 | 78 | function checkFixture(...ids: string[]) { 79 | const filePaths = ids.map((id) => 80 | path.resolve(__dirname, `../fixtures/tslint.${id}.json`), 81 | ); 82 | return check(filePaths); 83 | } 84 | -------------------------------------------------------------------------------- /tools/checker.ts: -------------------------------------------------------------------------------- 1 | import * as path from "path"; 2 | import { Configuration, Linter } from "tslint"; 3 | 4 | // tslint:disable-next-line:no-var-requires 5 | const tslintConfigPrettier = require("..") as Configuration.RawConfigFile; 6 | 7 | export const check = (configFilePaths: string[]) => { 8 | if (configFilePaths.length === 0) { 9 | // tslint:disable-next-line:no-console 10 | console.log("Usage: tslint-config-prettier-check ..."); 11 | return; 12 | } 13 | 14 | configFilePaths.forEach((configFilePath) => { 15 | try { 16 | const conflictRules = getConflictRules(configFilePath); 17 | if (conflictRules.length) { 18 | // tslint:disable-next-line:no-console 19 | console.error( 20 | `Conflict rule(s) detected in ${configFilePath}:\n${conflictRules 21 | .map((conflictRule) => ` ${conflictRule}`) 22 | .join("\n")}`, 23 | ); 24 | process.exitCode = 1; 25 | } 26 | } catch (error) { 27 | // tslint:disable-next-line:no-console 28 | console.error(error.message); 29 | process.exitCode = 1; 30 | } 31 | }); 32 | }; 33 | 34 | function getConflictRules(configFilePath: string) { 35 | const { rules, jsRules } = Linter.loadConfigurationFromPath(configFilePath); 36 | return Object.keys(tslintConfigPrettier.rules!).filter( 37 | (conflictRuleName) => 38 | isConflict(conflictRuleName, rules) || 39 | isConflict(conflictRuleName, jsRules), 40 | ); 41 | } 42 | 43 | function isConflict( 44 | conflictRuleName: string, 45 | rules: Configuration.IConfigurationFile["rules"], 46 | ) { 47 | return ( 48 | rules.has(conflictRuleName) && 49 | rules.get(conflictRuleName)!.ruleSeverity !== "off" 50 | ); 51 | } 52 | -------------------------------------------------------------------------------- /tools/generate.ts: -------------------------------------------------------------------------------- 1 | import * as fs from "fs"; 2 | import * as mkdir from "make-dir"; 3 | import * as path from "path"; 4 | 5 | const outputDirname = path.resolve(__dirname, "../lib"); 6 | const outputFilename = path.join(outputDirname, "index.json"); 7 | 8 | const ruleProvidersDirname = path.resolve(__dirname, "../src"); 9 | const ruleNames: string[] = []; 10 | 11 | fs.readdirSync(ruleProvidersDirname).forEach((ruleProviderName) => { 12 | const ruleProviderDirname = path.join( 13 | ruleProvidersDirname, 14 | ruleProviderName, 15 | ); 16 | 17 | if (!fs.statSync(ruleProviderDirname).isDirectory()) { 18 | return; 19 | } 20 | 21 | fs.readdirSync(ruleProviderDirname).forEach((ruleName) => { 22 | const ruleDirname = path.join(ruleProviderDirname, ruleName); 23 | 24 | if (!fs.statSync(ruleDirname).isDirectory()) { 25 | return; 26 | } 27 | 28 | if (ruleNames.indexOf(ruleName) !== -1) { 29 | throw new Error( 30 | `Duplicate rule '${ruleName}' in '${ruleProviderName}'`, 31 | ); 32 | } 33 | ruleNames.push(ruleName); 34 | }); 35 | }); 36 | 37 | const rules = ruleNames 38 | .slice() 39 | .sort() 40 | .reduce>( 41 | (current, ruleName) => ({ ...current, [ruleName]: false }), 42 | {}, 43 | ); 44 | 45 | mkdir.sync(outputDirname); 46 | fs.writeFileSync( 47 | outputFilename, 48 | JSON.stringify({ rules, jsRules: rules }, null, 2), 49 | ); 50 | -------------------------------------------------------------------------------- /tools/runtime.ts: -------------------------------------------------------------------------------- 1 | import * as path from "path"; 2 | import * as prettier from "prettier"; 3 | import * as tslint from "tslint"; 4 | 5 | export function format(filename: string, source: string) { 6 | const options = prettier.resolveConfig.sync(filename, { editorconfig: false }); 7 | return prettier.format(source, { filepath: filename, ...options }); 8 | } 9 | 10 | export function lint(filename: string, source: string) { 11 | const dirname = path.dirname(filename); 12 | 13 | const tslintPath = path.join(dirname, "tslint.json"); 14 | const tslintConfig = tslint.Linter.findConfiguration(tslintPath, "").results; 15 | const linter = new tslint.Linter({ fix: false, formatter: "verbose" }); 16 | 17 | linter.lint(filename, source, tslintConfig); 18 | const results = linter.getResult(); 19 | 20 | if (results.failures.length > 0) { 21 | const output = results.output.replace(new RegExp(process.cwd(), "g"), ""); 22 | throw new Error(output); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /tools/transform.ts: -------------------------------------------------------------------------------- 1 | 2 | const transformer: jest.Transformer = { process }; 3 | 4 | export = transformer; 5 | 6 | function process(sourceText: string, sourcePath: string) { 7 | return ` 8 | const path = require('path'); 9 | const runtime = require('../../../build/runtime'); 10 | 11 | const filename = ${JSON.stringify(sourcePath)}; 12 | const source = ${JSON.stringify(sourceText)}; 13 | const formatted = runtime.format(filename, source); 14 | 15 | const messageNoError = 'no error\\n'; 16 | const ruleName = path.basename(__dirname); 17 | const errorRegex = new RegExp('^ERROR: \\\\(' + ruleName + '\\\\)', 'gm'); 18 | 19 | const getMatchCount = (str, regex) => { 20 | const result = str.match(regex); 21 | return result === null 22 | ? 0 23 | : result.length; 24 | }; 25 | const printBeforeDfter = (before, after) => ( 26 | '\\n<<<<<< before\\n' + 27 | before + 28 | '\\n======\\n' + 29 | after + 30 | '\\n>>>>>> after\\n' 31 | ); 32 | 33 | let messageBefore = messageNoError; 34 | let messageAfter = messageNoError; 35 | 36 | try { 37 | runtime.lint(filename, source); 38 | } catch (error) { 39 | messageBefore = error.message; 40 | } 41 | 42 | try { 43 | runtime.lint(filename, formatted); 44 | } catch (error) { 45 | messageAfter = error.message; 46 | } 47 | 48 | it('should affect error message after formatting', () => { 49 | const errorCountBefore = getMatchCount(messageBefore, errorRegex); 50 | const errorCountAfter = getMatchCount(messageAfter, errorRegex); 51 | expect(errorCountAfter).not.toBe(errorCountBefore); 52 | expect(printBeforeDfter(messageBefore, messageAfter)).toMatchSnapshot(); 53 | }); 54 | 55 | it('should be pretty after formatting', () => { 56 | expect(printBeforeDfter(source, formatted)).toMatchSnapshot(); 57 | }); 58 | `; 59 | } 60 | -------------------------------------------------------------------------------- /tsconfig.checker.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "include": ["tools/checker.ts"], 4 | "compilerOptions": { 5 | "outDir": "lib", 6 | "inlineSourceMap": false 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "strict": true, 4 | "lib": ["es6"], 5 | "module": "commonjs", 6 | "rootDir": "tools", 7 | "outDir": "build", 8 | "inlineSourceMap": true 9 | }, 10 | "include": ["tools/**/*.ts"] 11 | } 12 | -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["tslint:latest"], 3 | "rules": { 4 | "no-implicit-dependencies": [true, "dev"] 5 | } 6 | } 7 | --------------------------------------------------------------------------------