diff --git a/README.md b/README.md index 7fa1028..47fe28c 100644 --- a/README.md +++ b/README.md @@ -47,25 +47,6 @@ export default [ ] ``` -For TypeScript: -```js -import eslintConfigCodely from "eslint-config-codely"; - -export default [ - ...eslintConfigCodely.ts, - { - // You should add the path to your tsconfig - files: ["**/*.ts", "**/*.tsx"], - languageOptions: { - parserOptions: { - project: ["./tsconfig.json"], - }, - } - // Your config here - } -] -``` - ℹ️ Please note that some of the rules enabled by default require that you have `strict: true` in your `tsconfig.json`. ## 🤔 What it does diff --git a/configs/codely-full.js b/configs/codely-full.js new file mode 100644 index 0000000..ef024b6 --- /dev/null +++ b/configs/codely-full.js @@ -0,0 +1,62 @@ +import eslintPluginCheckFile from "eslint-plugin-check-file"; + +import eslintPluginCodely from "./codely-ts.js"; + +export default [ + ...eslintPluginCodely, + { + ignores: [ + "**/.idea/", + "**/.next/", + "**/.storybook/", + "**/.turbo/", + "**/.yarn/", + "**/node_modules/", + "**/storybook-static/", + "**/test-results/", + ], + }, + { + plugins: { + "check-file": eslintPluginCheckFile, + }, + rules: { + "prettier/prettier": ["error", { printWidth: 120, useTabs: true, tabWidth: 4 }], + "check-file/folder-naming-convention": [ + "error", + { + // kebab-case and folders with square brackets are allowed + "**/*": "+([a-z-\\[\\]])", + }, + ], + "simple-import-sort/imports": [ + "error", + { + groups: [ + // Side effect imports: `import "./setup";` + ["^\\u0000"], + // Packages: `import fs from "fs";` + ["^@?\\w"], + // Internal packages. + ["^(@|@codely)(/.*|$)"], + // Parent imports. Put `..` last. + ["^\\.\\.(?!/?$)", "^\\.\\./?$"], + // Other relative imports. Put same-folder imports and `.` last. + ["^\\./(?=.*/)(?!/?$)", "^\\.(?!/?$)", "^\\./?$"], + // Style imports. + ["^.+\\.s?css$"], + ], + }, + ], + "no-use-before-define": [ + "error", + { + functions: false, + classes: true, + variables: true, + allowNamedExports: false, + }, + ], + }, + }, +]; diff --git a/configs/codely-js.js b/configs/codely-js.js index bb38dd1..a163a95 100644 --- a/configs/codely-js.js +++ b/configs/codely-js.js @@ -74,10 +74,7 @@ export default [ // style curly: "error", "lines-between-class-members": ["error", "always", { exceptAfterSingleLine: true }], - "padding-line-between-statements": [ - "error", - { blankLine: "always", prev: "*", next: "return" }, - ], + "padding-line-between-statements": ["error", { blankLine: "always", prev: "*", next: "return" }], // plugins "import/first": "error", diff --git a/configs/codely-ts.js b/configs/codely-ts.js index 51e4e33..525ea49 100644 --- a/configs/codely-ts.js +++ b/configs/codely-ts.js @@ -96,4 +96,10 @@ export default [ "@typescript-eslint/explicit-module-boundary-types": ["error"], }, }, + { + files: ["**/*.js"], + rules: { + "@typescript-eslint/no-unused-vars": ["off"], + }, + }, ]; diff --git a/eslint.config.js b/eslint.config.js index b605310..f317e70 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,3 +1,3 @@ import eslintConfigCodely from "./index.js"; -export default [...eslintConfigCodely.js]; +export default [...eslintConfigCodely.full]; diff --git a/index.js b/index.js index b30e62e..5d2e32d 100644 --- a/index.js +++ b/index.js @@ -1,9 +1,11 @@ -import jsConfigs from "./configs/codely-js.js"; -import tsConfigs from "./configs/codely-ts.js"; +import fullConfig from "./configs/codely-full.js"; +import jsConfig from "./configs/codely-js.js"; +import tsConfig from "./configs/codely-ts.js"; const eslintConfigCodely = { - js: jsConfigs, - ts: tsConfigs, + js: jsConfig, + ts: tsConfig, + full: fullConfig, }; export default eslintConfigCodely; diff --git a/package-lock.json b/package-lock.json index dabe482..d866710 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,21 +1,22 @@ { "name": "eslint-config-codely", - "version": "4.0.0-beta.2", + "version": "4.1.0-beta.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "eslint-config-codely", - "version": "4.0.0-beta.2", + "version": "4.1.0-beta.0", "license": "SEE LICENSE IN LICENSE", "dependencies": { - "@babel/core": "^7.25.1", + "@babel/core": "^7.25.2", "@babel/eslint-parser": "^7.25.1", "@eslint/js": "^9.9.1", "@types/eslint__js": "^8.42.3", "@types/node": "^20.10.1", "eslint": "^9.9.1", "eslint-config-prettier": "^9.1.0", + "eslint-plugin-check-file": "^2.8.0", "eslint-plugin-import-x": "^4.1.1", "eslint-plugin-prettier": "^5.2.1", "eslint-plugin-simple-import-sort": "^12.1.1", @@ -1189,6 +1190,26 @@ "ms": "^2.1.1" } }, + "node_modules/eslint-plugin-check-file": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-check-file/-/eslint-plugin-check-file-2.8.0.tgz", + "integrity": "sha512-FvvafMTam2WJYH9uj+FuMxQ1y+7jY3Z6P9T4j2214cH0FBxNzTcmeCiGTj1Lxp3mI6kbbgsXvmgewvf+llKYyw==", + "license": "Apache-2.0", + "dependencies": { + "is-glob": "^4.0.3", + "micromatch": "^4.0.5" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "type": "ko_fi", + "url": "https://ko-fi.com/huanluo" + }, + "peerDependencies": { + "eslint": ">=7.28.0" + } + }, "node_modules/eslint-plugin-import-x": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/eslint-plugin-import-x/-/eslint-plugin-import-x-4.1.1.tgz", diff --git a/package.json b/package.json index 1f60d8d..17b1769 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-codely", - "version": "4.0.1", + "version": "4.1.0", "description": "Codely's ESLint and Prettier Config", "main": "index.js", "scripts": { @@ -16,6 +16,7 @@ "@types/node": "^20.10.1", "eslint": "^9.9.1", "eslint-config-prettier": "^9.1.0", + "eslint-plugin-check-file": "^2.8.0", "eslint-plugin-import-x": "^4.1.1", "eslint-plugin-prettier": "^5.2.1", "eslint-plugin-simple-import-sort": "^12.1.1",