azz / prettier-tslint Goto Github PK
View Code? Open in Web Editor NEWCode ➡️ prettier ➡️ tslint --fix ➡️ Formatted Code ✨
Home Page: https://npm.im/prettier-tslint
License: MIT License
Code ➡️ prettier ➡️ tslint --fix ➡️ Formatted Code ✨
Home Page: https://npm.im/prettier-tslint
License: MIT License
$ npm audit
# npm audit report
ansi-regex >2.1.1 <5.0.1
Severity: moderate
Inefficient Regular Expression Complexity in chalk/ansi-regex - https://github.com/advisories/GHSA-93q8-gq69-wqmw
fix available via `npm audit fix --force`
Will install [email protected], which is a breaking change
node_modules/ansi-regex
strip-ansi 4.0.0 - 5.2.0
Depends on vulnerable versions of ansi-regex
node_modules/strip-ansi
cliui 4.0.0 - 5.0.0
Depends on vulnerable versions of strip-ansi
node_modules/cliui
yargs 8.0.0-candidate.0 - 15.0.0
Depends on vulnerable versions of cliui
Depends on vulnerable versions of yargs-parser
node_modules/yargs
prettier-tslint >=0.3.0
Depends on vulnerable versions of globby
Depends on vulnerable versions of yargs
node_modules/prettier-tslint
string-width 2.1.0 - 4.1.0
Depends on vulnerable versions of strip-ansi
node_modules/string-width
glob-parent <5.1.2
Severity: high
Regular expression denial of service - https://github.com/advisories/GHSA-ww39-953v-wcq6
fix available via `npm audit fix --force`
Will install [email protected], which is a breaking change
node_modules/glob-parent
fast-glob <=2.2.7
Depends on vulnerable versions of glob-parent
node_modules/fast-glob
globby 8.0.0 - 9.2.0
Depends on vulnerable versions of fast-glob
node_modules/globby
prettier-tslint >=0.3.0
Depends on vulnerable versions of globby
Depends on vulnerable versions of yargs
node_modules/prettier-tslint
yargs-parser 6.0.0 - 13.1.1
Severity: moderate
Prototype Pollution in yargs-parser - https://github.com/advisories/GHSA-p9pc-299p-vxgp
fix available via `npm audit fix --force`
Will install [email protected], which is a breaking change
node_modules/yargs-parser
yargs 8.0.0-candidate.0 - 15.0.0
Depends on vulnerable versions of cliui
Depends on vulnerable versions of yargs-parser
node_modules/yargs
prettier-tslint >=0.3.0
Depends on vulnerable versions of globby
Depends on vulnerable versions of yargs
node_modules/prettier-tslint
10 vulnerabilities (6 moderate, 4 high)
Requires palantir/tslint#1760
Versions:
prettier-tslint
version: 0.4.2
Problem description:
TypeScript has recently released a new update which bumped the major. Unfortunately, TypeScript doesn't adhere to semver (see microsoft/TypeScript#14116). This means that this package needs to update the typescript
peerDependency
to allow using TypeScript 4.0+ with it.
Suggested solution:
Using 2.5.3 || >=3.0.0
(or simply >=2.5.3
if all versions past v2.5.3 are supported) as the peer dependency version for the typescript
package should fix this issue. See https://docs.npmjs.com/files/package.json#dependencies
I am quite confused by all the different npm packages and the various approaches to set up a project properly.
I wonder what benefits using prettier+prettier-tslint bring and how does it compare to tslint-config-prettier ?
Environment:
"module": "commonjs"
in tsconfig.json"ordered-imports": true
in tslint.jsonSteps taken:
Created testing.ts
with the following in it:
import crypto from 'crypto'
import path from 'path'
import fs from 'fs'
Upon calling "Format Document" in VS Code, it gets mangled to:
import crypto from 'crypto'
import fs from "f'path'ort path from "p'fs'
Correct is:
import crypto from 'crypto'
import fs from 'fs'
import path from 'path'
The vscode-tslint extension with tslint.autoFixOnSave
set to true
doesn't have this bug and correctly reorders imports on save.
The following does not work:
prettier-tslint check ./packages/node_modules/@scope/packageName/src/path/to/file.ts
Prettier addresses this by having a --with-node-modules
option, which changes the default filter.
This is fixed by #20
Hey!
In angular project there are three tslint.json files for the project (shared), the code (in src) and e2e (in e2e).
Would be nice to have a possibility to specify the tslint.json file.
Regards,
TheAifam5
Typescript is at 3.0 now, and prettier-tslint is not happy about it.
[email protected]" has incorrect peer dependency "typescript@^2.5.3".
Not sure how possible this is. You need to use this plugin to apply auto-fixes for rules with requiresTypeInfo
enabled. It would be great if prettier-tslint
could trigger those auto-fixes somehow.
Side note: It might be easier to run Prettier as a TSLint rule instead. See here
Currently, if you want to lint / prettify files, you need to do them one at a time. When processing multiple files, I suspect it would probably execute much quicker if the fix
and check
methods accepted an array of files, so prettier and tslint could process them in bulk.
Prettier's printWidth
defaults to 80, which (if left unchanged) makes TSLint's max-line-length
look broken. The reality is that users should be using Prettier options to control the maximum line length.
To ease the pain, this package could probably translate TSLint's max-line-length
into Prettier's printWidth
automatically when printWidth
is not explicitly defined.
We could also warn when both are defined, but have different values.
Related: #15
import {NgModule} from '@angular/core'
import {AppComponent} from './app.component'
import {CommonModuleCustom} from './modules/common.module'
import {ElectronService} from './providers/electron.service'
import {LayoutComponent} from './components/layout/layout.component'
with tslint.json
configuration:
ordered-imports:
- true
- grouped-imports: false
import-sources-order: case-insensitive
named-imports-order: case-insensitive
module-source-path: full
# From tslint-eslint-rules
object-curly-spacing:
- true
- always
You can reproduce from this repository: https://github.com/liuweiGL/prettier-tslint-bug-reproduce
I think the apply-fixes.js
has some problems,the tslint‘s applyTSLintAllFixes
function will update Program
, but you don't.
Refrence from palantir/tslint#2864
PROBLEM
Some of the rules configured by tslint.json
are not working. One such example is below
/* tslint.json */
"rules": {
"quotemark": [true, "single", "jsx-double"]
},
PARTIAL WORKAROUND
As a workaround, we are using the below in .prettierrc
and hence we cannot utilize 😭 more option like "jsx-double" which is best suited for react configured in tslint
/* .prettierrc */
{
"printWidth": 120, // workaround as 'printWidth' in settings.json / 'max-line-length' in tslint.json not working
"singleQuote": true // partial workaround as usage of '.prettierrc' breaks tslint.json
}
Since I use prettier, tslint as vscode plugins, I prefer maintaining configuration in .vscode/settings.json
/* .vscode/settings.json */
{
"editor.formatOnSave": true,
"eslint.autoFixOnSave": true,
"prettier.eslintIntegration": true,
"prettier.printWidth": 120, // not working
"prettier.tslintIntegration": true, // enabled
"tslint.autoFixOnSave": true
}
All the rules working as per the configuration in tslint.json
and .vscode/settings.json
except
printWidth
which is configured in .vscode/settings.json
."max-line-length": [true, 120]
which is configured in tslint.json
Hence as a workaround, we are using .prettierrc
file as suggested in #15 (comment) but this breaks some of the tslint.json
rules as explained
When tslint fixing , don't you need to read the tslint.json configuration in your project?
Hello.
I wanted to used a simple thing to get prettier and tslint working together (this project so :D) with VsCode, on save.
Is there any steps I'm missing ?
Prettier itself supports .editorconfig
as second in priority to the .prettierrc
file, this repo doesn't.
Shouldn't tslint be a peer dependency as well?
I'm using a 0.4.2 version of the prettier-tslint library and have a warning about one of your dependencies. Here is a report from yarn audit
command:
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ low │ Prototype Pollution │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package │ yargs-parser │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in │ >=13.1.2 <14.0.0 || >=15.0.1 <16.0.0 || >=18.1.2 │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ prettier-tslint │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path │ prettier-tslint > yargs > yargs-parser │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info │ https://www.npmjs.com/advisories/1500 │
└───────────────┴──────────────────────────────────────────────────────────────┘
When setting tslintIntegration to true, prettier does not take into account its print-width rule anymore, neither it takes the max-line-length rule from tslint for formatting line length. When formatting files, it acts as if the print-width would be 80.
Here is my configuration:
VS config (extract):
"prettier.tslintIntegration": true,
tslint.yaml (extract):
extends:
- >-
common/tslint
common/tslint.yaml (extract):
max-line-length:
options:
limit: 120
Prettier in VSCode settings is set to 80. Tslint Integration has been set. tslint.json has "max-line-length": [true, 80]
I tried creating a .prettierrc.json
file with "printWidth": 80
but it also doesn't work.
Is this a bug or am I missing something?
When setting tslintIntegration to true, prettier does not take into account its semi rule anymore, neither it takes the semicolon rule from tslint, at least in interface definition.
For example, in my interface definition:
export interface ApiDefinition extends RoutesType {
lang: {
url: { langCode: string }
data: undefined
header: undefined
return: void
}
securityToken: {
url: undefined
data: undefined
header: undefined
return: string
}
}
code formatting adds semicolons at almost each line:
export interface ApiDefinition extends RoutesType {
lang: {
url: { langCode: string };
data: undefined;
header: undefined;
return: void;
}
securityToken: {
url: undefined;
data: undefined;
header: undefined;
return: string;
}
}
Here is my configuration:
VS config (extract):
"prettier.tslintIntegration": true,
tslint.yaml (extract):
extends:
- >-
common/tslint
common/tslint.yaml (extract):
semicolon:
options:
- never
The linterOptions
of tslint.json
is only supported by the CLI, not the programmatic API of tslint
.
This library needs to support linterOptions
on its own, unfortunately.
See here: palantir/tslint#3722
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.