-
Notifications
You must be signed in to change notification settings - Fork 49
Missing ESLint + Prettier Integration in Frontend #56 #77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
chaitanyak175
wants to merge
1
commit into
Community-Programmer:main
Choose a base branch
from
chaitanyak175:eslint-prettier-fix
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| # EditorConfig helps maintain consistent coding styles | ||
| # for multiple developers working on the same project | ||
| # across various editors and IDEs. | ||
| # https://editorconfig.org | ||
|
|
||
| root = true | ||
|
|
||
| [*] | ||
| charset = utf-8 | ||
| end_of_line = lf | ||
| indent_style = space | ||
| indent_size = 2 | ||
| insert_final_newline = true | ||
| trim_trailing_whitespace = true | ||
| max_line_length = 100 | ||
|
|
||
| [*.md] | ||
| trim_trailing_whitespace = false | ||
|
|
||
| [*.{json,yml,yaml}] | ||
| indent_size = 2 | ||
|
|
||
| [*.{ts,tsx,js,jsx}] | ||
| indent_size = 2 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| name: Lint and Format Check | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main, develop] | ||
| pull_request: | ||
| branches: [main, develop] | ||
|
|
||
| jobs: | ||
| lint-and-format: | ||
| name: ESLint & Prettier Check | ||
| runs-on: ubuntu-latest | ||
|
|
||
| strategy: | ||
| matrix: | ||
| node-version: [18.x, 20.x] | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Node.js ${{ matrix.node-version }} | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: ${{ matrix.node-version }} | ||
| cache: "npm" | ||
| cache-dependency-path: frontend-react/package-lock.json | ||
|
|
||
| - name: Install dependencies | ||
| working-directory: ./frontend-react | ||
| run: npm ci | ||
|
|
||
| - name: Run ESLint | ||
| working-directory: ./frontend-react | ||
| run: npm run lint | ||
|
|
||
| - name: Check formatting with Prettier | ||
| working-directory: ./frontend-react | ||
| run: npm run format:check | ||
|
|
||
| - name: Type check | ||
| working-directory: ./frontend-react | ||
| run: npm run type-check | ||
|
|
||
| - name: Build project | ||
| working-directory: ./frontend-react | ||
| run: npm run build |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| npx lint-staged |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| # Dependencies | ||
| node_modules | ||
| package-lock.json | ||
| yarn.lock | ||
| pnpm-lock.yaml | ||
|
|
||
| # Build outputs | ||
| dist | ||
| build | ||
| .next | ||
| out | ||
| coverage | ||
|
|
||
| # Cache | ||
| .cache | ||
| .turbo | ||
| .vite | ||
| .eslintcache | ||
|
|
||
| # Environment files | ||
| .env | ||
| .env.local | ||
| .env.production | ||
|
|
||
| # Logs | ||
| *.log | ||
|
|
||
| # OS files | ||
| .DS_Store | ||
| Thumbs.db | ||
|
|
||
| # IDE | ||
| .vscode/* | ||
| !.vscode/settings.json | ||
| !.vscode/extensions.json | ||
| .idea | ||
|
|
||
| # Generated files | ||
| *.min.js | ||
| *.min.css | ||
| public/build |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| { | ||
| "semi": true, | ||
| "trailingComma": "es5", | ||
| "singleQuote": false, | ||
| "printWidth": 80, | ||
| "tabWidth": 2, | ||
| "useTabs": false, | ||
| "arrowParens": "always", | ||
| "endOfLine": "lf", | ||
| "bracketSpacing": true, | ||
| "jsxSingleQuote": false, | ||
| "bracketSameLine": false, | ||
| "proseWrap": "preserve", | ||
| "htmlWhitespaceSensitivity": "css", | ||
| "embeddedLanguageFormatting": "auto" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "recommendations": [ | ||
| "dbaeumer.vscode-eslint", | ||
| "esbenp.prettier-vscode", | ||
| "editorconfig.editorconfig", | ||
| "bradlc.vscode-tailwindcss" | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,28 +1,102 @@ | ||
| import js from '@eslint/js' | ||
| import globals from 'globals' | ||
| import reactHooks from 'eslint-plugin-react-hooks' | ||
| import reactRefresh from 'eslint-plugin-react-refresh' | ||
| import tseslint from 'typescript-eslint' | ||
| import js from '@eslint/js'; | ||
| import prettierConfig from 'eslint-config-prettier'; | ||
| import jsxA11y from 'eslint-plugin-jsx-a11y'; | ||
| import prettier from 'eslint-plugin-prettier'; | ||
| import react from 'eslint-plugin-react'; | ||
| import reactHooks from 'eslint-plugin-react-hooks'; | ||
| import reactRefresh from 'eslint-plugin-react-refresh'; | ||
| import globals from 'globals'; | ||
| import tseslint from 'typescript-eslint'; | ||
|
|
||
| export default tseslint.config( | ||
| { ignores: ['dist'] }, | ||
| { ignores: ['dist', 'node_modules', 'build', 'coverage', '.vite'] }, | ||
| { | ||
| extends: [js.configs.recommended, ...tseslint.configs.recommended], | ||
| files: ['**/*.{ts,tsx}'], | ||
| extends: [js.configs.recommended, ...tseslint.configs.recommended, prettierConfig], | ||
| files: ['**/*.{ts,tsx,js,jsx}'], | ||
| languageOptions: { | ||
| ecmaVersion: 2020, | ||
| globals: globals.browser, | ||
| parserOptions: { | ||
| ecmaFeatures: { | ||
| jsx: true, | ||
| }, | ||
| }, | ||
| }, | ||
| plugins: { | ||
| react, | ||
| 'react-hooks': reactHooks, | ||
| 'react-refresh': reactRefresh, | ||
| 'jsx-a11y': jsxA11y, | ||
| prettier, | ||
| }, | ||
| settings: { | ||
| react: { | ||
| version: 'detect', | ||
| }, | ||
| }, | ||
| rules: { | ||
| // Prettier integration | ||
| 'prettier/prettier': 'error', | ||
|
|
||
| // React Hooks | ||
| ...reactHooks.configs.recommended.rules, | ||
| 'react-refresh/only-export-components': [ | ||
| 'warn', | ||
| { allowConstantExport: true }, | ||
|
|
||
| // React Refresh | ||
| 'react-refresh/only-export-components': ['warn', { allowConstantExport: true }], | ||
|
|
||
| // React best practices | ||
| 'react/react-in-jsx-scope': 'off', // Not needed in React 17+ | ||
| 'react/prop-types': 'off', // Using TypeScript | ||
| 'react/jsx-uses-react': 'off', // Not needed in React 17+ | ||
| 'react/jsx-uses-vars': 'error', | ||
| 'react/jsx-key': ['error', { checkFragmentShorthand: true }], | ||
| 'react/jsx-no-duplicate-props': 'error', | ||
| 'react/jsx-no-undef': 'error', | ||
| 'react/jsx-pascal-case': 'error', | ||
| 'react/no-children-prop': 'error', | ||
| 'react/no-danger-with-children': 'error', | ||
| 'react/no-deprecated': 'warn', | ||
| 'react/no-direct-mutation-state': 'error', | ||
| 'react/no-unescaped-entities': 'warn', | ||
| 'react/self-closing-comp': 'error', | ||
| 'react/jsx-curly-brace-presence': ['error', { props: 'never', children: 'never' }], | ||
|
|
||
| // TypeScript specific | ||
| '@typescript-eslint/no-unused-vars': [ | ||
| 'error', | ||
| { | ||
| argsIgnorePattern: '^_', | ||
| varsIgnorePattern: '^_', | ||
| caughtErrorsIgnorePattern: '^_', | ||
| }, | ||
| ], | ||
| '@typescript-eslint/no-explicit-any': 'warn', | ||
| '@typescript-eslint/explicit-module-boundary-types': 'off', | ||
| '@typescript-eslint/no-non-null-assertion': 'warn', | ||
| '@typescript-eslint/consistent-type-imports': ['warn', { prefer: 'type-imports' }], | ||
|
|
||
| // Accessibility | ||
| 'jsx-a11y/alt-text': 'warn', | ||
| 'jsx-a11y/anchor-is-valid': 'warn', | ||
| 'jsx-a11y/click-events-have-key-events': 'warn', | ||
| 'jsx-a11y/no-static-element-interactions': 'warn', | ||
| 'jsx-a11y/aria-props': 'error', | ||
| 'jsx-a11y/aria-proptypes': 'error', | ||
| 'jsx-a11y/aria-unsupported-elements': 'error', | ||
| 'jsx-a11y/role-has-required-aria-props': 'error', | ||
| 'jsx-a11y/role-supports-aria-props': 'error', | ||
|
|
||
| // General best practices | ||
| 'no-console': ['warn', { allow: ['warn', 'error'] }], | ||
| 'no-debugger': 'warn', | ||
| 'prefer-const': 'error', | ||
| 'no-var': 'error', | ||
| 'object-shorthand': 'error', | ||
| 'prefer-template': 'error', | ||
| 'prefer-arrow-callback': 'error', | ||
| 'no-duplicate-imports': 'error', | ||
| eqeqeq: ['error', 'always', { null: 'ignore' }], | ||
| 'no-unused-expressions': ['error', { allowShortCircuit: true, allowTernary: true }], | ||
| }, | ||
| }, | ||
| ) | ||
| } | ||
| ); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent line length limits: Prettier is configured with printWidth: 80 in .prettierrc, while EditorConfig specifies max_line_length = 100. These should be aligned to the same value to avoid confusion.