ESLint v9 (2025-04) 사용법
ESLint 9 사용법
- VS code 에서 ESLint 적용
https://eslint.org/
https://github.com/eslint/eslint
* eslint 최신 버전 설치와 설정
npm init @eslint/config@latest
- 글로벌 설치는 권장되지 않음
* VScode extension 설치
https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint
https://github.com/Microsoft/vscode-eslint
eslint 로 검색 -> 제작자가 Microsoft인것 선택
* ESLint 9 에서 달라진 것
https://eslint.org/docs/latest/use/migrate-to-9.0.0
설정파일 변경 : .eslintignore , .eslintrc.js 파일 사용안함( 삭제 필요)
설정파일은 eslint.config.js 로 설정
-------------------------------------------------------------------------------
* eslint.config.js 파일 설정 예제
import js from "@eslint/js";
import globals from "globals";
import tseslint from "typescript-eslint";
import { defineConfig } from "eslint/config";
export default defineConfig([
js.configs.recommended,
...tseslint.configs.recommended,
{
files: ["**/*.{js,ts,mjs,cjs}"],
ignores: ["/node_modules/**"],
languageOptions: {
globals: {
...globals.browser,
$: "readonly",
},
},
rules: {
"no-undef": "off",
'@typescript-eslint/no-unused-vars': 'off',
'no-unused-vars': 'off',
"no-debugger": "off",
"no-unreachable": "off",
"no-useless-escape": "off",
"no-extra-semi": "off",
"no-empty": "off",
"no-extra-boolean-cast": 0,
"plugin:you-dont-need-lodash-underscore/compatible": "off",
"no-irregular-whitespace": "off",
"no-prototype-builtins": "off",
"@typescript-eslint/no-unused-expressions": "off",
"no-control-regex": "off",
},
},
]);
-------------------------------------------------------------------------------
* 틀린 문법 테스트
// eslint 에러 테스트
let foo = 10
if (foo = 5) {
console.log("Oops!")
}