Skip to content

Code formatting in ESLint

Course: ESLint, Prettier and Pre-commit hooks - chapter 3

  • Update eslint.config.mjs
import globals from "globals";
import pluginJs from "@eslint/js";
import tseslint from "typescript-eslint";
export default [
{
languageOptions: { globals: globals.node },
rules: {
// Indentation rule: 2 spaces
"indent": ["error", 2],
// Space before function parenthesis
"space-before-function-paren": ["error", "always"],
// No space inside parentheses
"space-in-parens": ["error", "never"]
}
},
pluginJs.configs.recommended,
...tseslint.configs.recommended,
];

If you press tab while coding, it adds a tab. You need 2 spaces to be added now that our eslint config says that