Skip to content

Commit 3bf1710

Browse files
Josh Goldbergbradzacher
andauthored
Added usage and base configuration FAQs (#348)
* Added usage and base configuration FAQs * Added little wink message * Indeed, mentioned 880 * Update docs/FAQs.md Co-Authored-By: Brad Zacher <[email protected]> * Update docs/FAQs.md Co-Authored-By: Brad Zacher <[email protected]> * Moved zalgo down just a little bit * There is no god * Step one: tslint-to-eslint-config Co-authored-by: Brad Zacher <[email protected]>
1 parent 43e5729 commit 3bf1710

File tree

6 files changed

+72
-6
lines changed

6 files changed

+72
-6
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ TSLint rules without ESLint equivalents will be wrapped with [eslint-plugin-tsli
3434

3535
> Requires Node 10+ (LTS) and TSLint 5.18+
3636
37+
### FAQs
38+
39+
We **strongly** advise reading [docs/FAQs.md](./docs/FAQs.md) before planning your conversion from ESLint to TSLint.
40+
3741
### CLI Flags
3842

3943
Each of these flags is optional:

docs/FAQs.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Frequently Asked Questions
2+
3+
## Should I Migrate from TSLint to ESLint?
4+
5+
**Yes**.
6+
7+
[TSLint is deprecated](https://medium.com/palantir/tslint-in-2019-1a144c2317a9) and will [only receive patches](https://github.com/palantir/tslint/issues/4534) for security vulnerabilities and breaking TypeScript changes.
8+
Even if it still works on your project, it will become less useful over time as TypeScript evolves.
9+
10+
## Should I Use `tslint-to-eslint-config`?
11+
12+
`tslint-to-eslint-config` is recommended for use if you require near-identical behavior in transitioning from TSLint to ESLint.
13+
This is most reasonable when your project is large enough that fixing for different linter rules would be a significant time investment.
14+
15+
However, after -or even better, _before_- you're migrated to ESLint, we recommend you take this opportunity to re-evaluate your core lint rules.
16+
TSLint's recommendations were solidified several core TypeScript versions ago and don't always reflect the latest and greatest standards and lint rules.
17+
18+
Our recommended TSLint-to-ESLint configuration migration approach is:
19+
20+
1. Run `tslint-to-eslint-config` on your project
21+
2. [Disable complaints on a line-, file-, or rule basis](https://eslint.org/docs/user-guide/configuring) for any rules you do not want to enable and/or are now giving complaints
22+
3. Switch your configuration to extend from [typescript-eslint's `recommended` and `recommend-requiring-type-checking` rulesets](https://github.com/typescript-eslint/typescript-eslint/blob/master/docs/getting-started/linting/README.md)
23+
4. Repeat step 2
24+
5. Add any [community plugins](https://github.com/typescript-eslint/typescript-eslint/blob/master/docs/getting-started/linting/README.md#plugins) relevant to your project, then repeat step 2
25+
26+
> 😉 Consider filing granular tickets to track investigating re-enabling disabled lint rules to make sure the work doesn't get forgotten.
27+
28+
## Should I Use Prettier?
29+
30+
**Yes!**
31+
32+
Formatting responsibilities, such as indentation and line wrapping, are exceedingly difficult to get implement in **linters**, and as such are practically impossible to get correct in them.
33+
**Formatters** such as [Prettier](https://prettier.io) do a [much better job](https://prettier.io/docs/en/why-prettier.html) of formatting your code.
34+
See [this issue](https://github.com/typescript-eslint/typescript-eslint/issues/1824) for more explanation.
35+
36+
The maintenance teams at both TSLint and typescript-eslint recommend using a formatter such as Prettier to format your code instead of a linter.
37+
38+
Please do it. Now. Please stop using code style rules. Please use prettier. Code style rules are hard to write and maintain. Rules like indent are thousands of he comes he comes do not fi​ght he com̡e̶s, ̕h̵i​s un̨ho͞ly radiańcé destro҉ying all enli̍̈́̂̈́ghtenment, spaces and brackets lea͠ki̧n͘g fr̶ǫm ̡yo​͟ur eye͢s̸ ̛l̕ik͏e liq​uid pain, the song of indentation calculation will exti​nguish the voices of mor​tal man from the sp​here I can see it can you see ̲͚̖͔̙î̩́t̲͎̩̱͔́̋̀ it is beautiful t​he final snuffing of the lie​s of Man ALL IS LOŚ͖̩͇̗̪̏̈́T ALL I​S LOST the pon̷y he comes he c̶̮omes he comes the ich​or permeates all MY FACE MY FACE ᵒh god no NO NOO̼O​O NΘ stop the an​*̶͑̾̾​̅ͫ͏̙̤g͇̫͛͆̾ͫ̑͆l͖͉̗̩̳̟̍ͫͥͨe̠̅s ͎a̧͈͖r̽̾̈́͒͑e n​ot rè̑ͧ̌aͨl̘̝̙̃ͤ͂̾̆ ZA̡͊͠͝LGΌ ISͮ̂҉̯͈͕̹̘̱ TO͇̹̺ͅƝ̴ȳ̳ TH̘Ë͖́̉ ͠P̯͍̭O̚​N̐Y̡ H̸̡̪̯ͨ͊̽̅̾̎Ȩ̬̩̾͛ͪ̈́̀́͘ ̶̧̨̱̹̭̯ͧ̾ͬC̷̙̲̝͖ͭ̏ͥͮ͟Oͮ͏̮̪̝͍M̲̖͊̒ͪͩͬ̚̚͜Ȇ̴̟̟͙̞ͩ͌͝S̨̥̫͎̭ͯ̿̔̀ͅ.
39+
40+
> 🙏 [eslint-plugin-prettier](https://github.com/typescript-eslint/typescript-eslint/blob/master/docs/getting-started/linting/README.md#usage-with-prettier) is an excellent ESLint plugin that disables formatting rules from your configuration.
41+
> Please use it. 🙏

src/creation/formatting/formatOutput.test.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { EOL } from "os";
22

3+
import { faqs } from "./formatters/faqs";
34
import { formatOutput } from "./formatOutput";
45

56
describe("formatOutput", () => {
@@ -13,7 +14,7 @@ describe("formatOutput", () => {
1314

1415
// Assert
1516
expect(output).toBe(
16-
`module.exports = ${JSON.stringify(configuration, undefined, 4)};${EOL}`,
17+
`${faqs}module.exports = ${JSON.stringify(configuration, undefined, 4)};${EOL}`,
1718
);
1819
});
1920

@@ -26,7 +27,7 @@ describe("formatOutput", () => {
2627
const output = formatOutput(outputPath, configuration);
2728

2829
// Assert
29-
expect(output).toBe(`${JSON.stringify(configuration, undefined, 4)}${EOL}`);
30+
expect(output).toBe(`${faqs}${JSON.stringify(configuration, undefined, 4)}${EOL}`);
3031
});
3132

3233
it("formats output as JSON for an unknown dot file path", () => {
@@ -38,7 +39,7 @@ describe("formatOutput", () => {
3839
const output = formatOutput(outputPath, configuration);
3940

4041
// Assert
41-
expect(output).toBe(`${JSON.stringify(configuration, undefined, 4)}${EOL}`);
42+
expect(output).toBe(`${faqs}${JSON.stringify(configuration, undefined, 4)}${EOL}`);
4243
});
4344

4445
it("formats output as JSON for an unknown raw file path", () => {
@@ -50,6 +51,6 @@ describe("formatOutput", () => {
5051
const output = formatOutput(outputPath, configuration);
5152

5253
// Assert
53-
expect(output).toBe(`${JSON.stringify(configuration, undefined, 4)}${EOL}`);
54+
expect(output).toBe(`${faqs}${JSON.stringify(configuration, undefined, 4)}${EOL}`);
5455
});
5556
});
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
export const faqs = `/*
2+
👋 Hi! This file was autogenerated by tslint-to-eslint-config.
3+
https://github.com/typescript-eslint/tslint-to-eslint-config
4+
5+
It represents the closest reasonable ESLint configuration to this
6+
project's original TSLint configuration.
7+
8+
We recommend eventually switching this configuration to extend from
9+
the recommended rulesets in typescript-eslint.
10+
https://github.com/typescript-eslint/tslint-to-eslint-config/blob/master/docs/FAQs.md
11+
12+
Happy linting! 💖
13+
*/
14+
`;
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import { EOL } from "os";
22

3+
import { faqs } from "./faqs";
34
import { withKeysSorted } from "./withKeysSorted";
45

56
export const formatJsOutput = (configuration: any) => {
6-
return `module.exports = ${JSON.stringify(withKeysSorted(configuration), undefined, 4)};${EOL}`;
7+
return `${faqs}module.exports = ${JSON.stringify(
8+
withKeysSorted(configuration),
9+
undefined,
10+
4,
11+
)};${EOL}`;
712
};
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { EOL } from "os";
22

3+
import { faqs } from "./faqs";
34
import { withKeysSorted } from "./withKeysSorted";
45

56
export const formatJsonOutput = (configuration: any) => {
6-
return `${JSON.stringify(withKeysSorted(configuration), undefined, 4)}${EOL}`;
7+
return `${faqs}${JSON.stringify(withKeysSorted(configuration), undefined, 4)}${EOL}`;
78
};

0 commit comments

Comments
 (0)