Turns off all rules that are unnecessary or might conflict with [Prettier].
This lets you use your favorite shareable config without letting its stylistic choices get in the way when using Prettier.
Note that this config _only_ turns rules _off,_ so it only makes sense using it together with some other config.
[prettier]: https://github.com/prettier/prettier
1. Install eslint-config-prettier:
1npm install --save-dev eslint-config-prettier
2. Add eslint-config-prettier to your ESLint configuration – either to [eslintrc] or to [eslint.config.js (flat config)].
- eslintrc: Add `"prettier"` to the "extends" array in your `.eslintrc.*` file. Make sure to put it **last,** so it gets the chance to override other configs.
1{
2 "extends": [
3 "some-other-config-you-use",
4 "prettier"
5 ]
6}
- eslint.config.js (flat config): Import eslint-config-prettier, and put it in the configuration array – **after** other configs that you want to override.
1import someConfig from "some-other-config-you-use";
2import eslintConfigPrettier from "eslint-config-prettier";
3
4export default [
5 someConfig,
6 eslintConfigPrettier,
7];
3. Finally, run the [CLI helper tool](#cli-helper-tool) to find problems in the `"rules"` sections of your config.
> 👉 Using [eslint-plugin-prettier]? Check out [eslint-plugin-prettier’s recommended config][eslint-plugin-prettier-recommended].
eslint-config-prettier not only turns off _core_ rules, but also some from these plugins automatically:
- [@typescript-eslint/eslint-plugin]
- [@babel/eslint-plugin]
- [eslint-plugin-babel]
- [eslint-plugin-flowtype]
- [eslint-plugin-react]
- [eslint-plugin-standard]
- [eslint-plugin-unicorn]
- [eslint-plugin-vue]
ℹ️ Note: You might find guides on the Internet saying you should also extend stuff like `"prettier/react"`. Since version 8.0.0 of eslint-config-prettier, all you need to extend is `"prettier"`! That includes all plugins.
With flat config, _you_ get to decide the plugin name! For example:
1public class Main {
2
3 public static void main(String[] args) {
4 char last = 'E', alphabet = 'A';
5
6 for (int i = 1; i <= (last - 'A' + 1); ++i) {
7 for (int j = 1; j <= i; ++j) {
8 System.out.print(alphabet + " ");
9 }
10 ++alphabet;
11
12 System.out.println();
13 }
14 }
15}
1interface User {
2 name: string;
3 id: number;
4}
5
6class UserAccount {
7 name: string;
8 id: number;
9
10 constructor(name: string, id: number) {
11 this.name = name;
12 this.id = id;
13 }
14}
15
16const user: User = new UserAccount("Murphy", 1);
1function MyButton() {
2 return (
3 <button>
4 I'm a button
5 </button>
6 );
7}
8
9export default function MyApp() {
10 return (
11 <div>
12 <h1>Welcome to my app</h1>
13 <MyButton />
14 </div>
15 );
16}
1import {useReducer} from 'react';
2
3interface State {
4 count: number
5};
6
7type CounterAction =
8 | { type: "reset" }
9 | { type: "setCount"; value: State["count"] }
10
11const initialState: State = { count: 0 };
12
13function stateReducer(state: State, action: CounterAction): State {
14 switch (action.type) {
15 case "reset":
16 return initialState;
17 case "setCount":
18 return { ...state, count: action.value };
19 default:
20 throw new Error("Unknown action");
21 }
22}
23
24export default function App() {
25 const [state, dispatch] = useReducer(stateReducer, initialState);
26
27 const addFive = () => dispatch({ type: "setCount", value: state.count + 5 });
28 const reset = () => dispatch({ type: "reset" });
29
30 return (
31 <div>
32 <h1>Welcome to my counter</h1>
33
34 <p>Count: {state.count}</p>
35 <button onClick={addFive}>Add 5</button>
36 <button onClick={reset}>Reset</button>
37 </div>
38 );
39}
1#include <iostream>
2using namespace std;
3
4int main() {
5
6 int rows;
7
8 cout << "Enter number of rows: ";
9 cin >> rows;
10
11 for(int i = 1; i <= rows; ++i) {
12 for(int j = 1; j <= i; ++j) {
13 cout << "* ";
14 }
15 cout << "\n";
16 }
17 return 0;
18}
19
1package main
2
3import (
4 "cmp"
5 "fmt"
6 "slices"
7)
8
9func main() {
10 fruits := []string{"peach", "banana", "kiwi"}
11
12 lenCmp := func(a, b string) int {
13 return cmp.Compare(len(a), len(b))
14 }
15
16 slices.SortFunc(fruits, lenCmp)
17 fmt.Println(fruits)
18
19 type Person struct {
20 name string
21 age int
22 }
23
24 people := []Person{
25 Person{name: "Jax", age: 37},
26 Person{name: "TJ", age: 25},
27 Person{name: "Alex", age: 72},
28 }
29
30 slices.SortFunc(people,
31 func(a, b Person) int {
32 return cmp.Compare(a.age, b.age)
33 })
34 fmt.Println(people)
35}
1use std::fmt::{Debug, Display};
2
3fn compare_prints<T: Debug + Display>(t: &T) {
4 println!("Debug: `{:?}`", t);
5 println!("Display: `{}`", t);
6}
7
8fn compare_types<T: Debug, U: Debug>(t: &T, u: &U) {
9 println!("t: `{:?}`", t);
10 println!("u: `{:?}`", u);
11}
12
13fn main() {
14 let string = "words";
15 let array = [1, 2, 3];
16 let vec = vec![1, 2, 3];
17
18 compare_prints(&string);
19 //compare_prints(&array);
20 // TODO ^ Try uncommenting this.
21
22 compare_types(&array, &vec);
23}
1// Normal, basic styles
2// that look great on small screens
3// but not on bigger screens
4body {
5 font-size: 16px;
6}
7
8// Define a new breakpoint, with a media query.
9// In this case, for when the viewport's width
10// is at least 512px wide.
11@media (min-width: 512px) {
12 body {
13 font-size: 20px;
14 }
15}
1# This function adds two numbers
2def add(x, y):
3 return x + y
4
5# This function subtracts two numbers
6def subtract(x, y):
7 return x - y
8
9# This function multiplies two numbers
10def multiply(x, y):
11 return x * y
12
13# This function divides two numbers
14def divide(x, y):
15 return x / y
16
17
18print("Select operation.")
19print("1.Add")
20print("2.Subtract")
21print("3.Multiply")
22print("4.Divide")
23
24while True:
25 # take input from the user
26 choice = input("Enter choice(1/2/3/4): ")
27
28 # check if choice is one of the four options
29 if choice in ('1', '2', '3', '4'):
30 try:
31 num1 = float(input("Enter first number: "))
32 num2 = float(input("Enter second number: "))
33 except ValueError:
34 print("Invalid input. Please enter a number.")
35 continue
36
37 if choice == '1':
38 print(num1, "+", num2, "=", add(num1, num2))
39
40 elif choice == '2':
41 print(num1, "-", num2, "=", subtract(num1, num2))
42
43 elif choice == '3':
44 print(num1, "*", num2, "=", multiply(num1, num2))
45
46 elif choice == '4':
47 print(num1, "/", num2, "=", divide(num1, num2))
48
49 # check if user wants another calculation
50 # break the while loop if answer is no
51 next_calculation = input("Let's do next calculation? (yes/no): ")
52 if next_calculation == "no":
53 break
54 else:
55 print("Invalid Input")
1<header>
2 <h1>Company A</h1>
3 <ul>
4 <li><a href="/home">Home</a></li>
5 <li><a href="/about">About</a></li>
6 <li><a href="/contact">Contact us</a></li>
7 </ul>
8 <form target="/search">
9 <input name="q" type="search" />
10 <input type="submit" />
11 </form>
12</header>
1function mandelbrot(a)
2 z = 0
3 for i=1:50
4 z = z^2 + a
5 end
6 return z
7end
8
9for y=1.0:-0.05:-1.0
10 for x=-2.0:0.0315:0.5
11 abs(mandelbrot(complex(x, y))) < 2 ? print("*") : print(" ")
12 end
13 println()
14end
15
<hr/>
blockqoute
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.