Skip to content

Preparing for the transition to an updated linter, standardizing the code base#31

Open
In1quity wants to merge 2 commits intowikimedia-gadgets:masterfrom
In1quity:eslint-prep
Open

Preparing for the transition to an updated linter, standardizing the code base#31
In1quity wants to merge 2 commits intowikimedia-gadgets:masterfrom
In1quity:eslint-prep

Conversation

@In1quity
Copy link
Copy Markdown

@In1quity In1quity commented Sep 15, 2025

To apply new rules, linters or whatever and to do it as safely as possible, we first need to fix the tabs and linebreak-style (CLRF vs LF). Because this change breaks diffs and prevents PR from being checked properly.

ESLint Configuration Added:

  • Added .eslintrc.json with comprehensive rules for code quality
  • Applied strict code style standards across entire codebase

ESLint Wikimedia Rules Implemented:

  • indent: ["error", "tab"] - Enforce tab indentation with SwitchCase support
  • no-tabs: ["error", {"allowIndentationTabs": true}] - Disallow tabs except for indentation
  • no-multiple-empty-lines: ["error", {"max": 1, "maxBOF": 0, "maxEOF": 0}] - Limit consecutive empty lines
  • max-len: ["warn", {"code": 100, "tabWidth": 4, "ignoreUrls": true, "ignoreStrings": true, "ignoreTemplateLiterals": true}] - Enforce 100 character line limit
  • linebreak-style: ["error", "unix"] - Enforce Unix line endings (LF)

Code Fixes Applied:

  • 27 no-tabs errors: Removed all tab characters from code content (kept for indentation)
  • 48 max-len warnings: Reformatted long lines to fit within 100 character limit
  • 4724 linebreak-style errors: Converted all Windows CRLF line endings to Unix LF
  • Multiple formatting issues: Fixed spacing, indentation, etc

Files Modified:

  • .eslintrc.json: Added ESLint configuration
  • index.js: Fixed line length and formatting
  • All rater-src/*.js files: Applied consistent code style
  • All Windows/Components/*.js files: Fixed formatting and line length

## ESLint Configuration Added:
- Added .eslintrc.json with comprehensive rules for code quality
- Configured for ESLint 6.x compatibility
- Applied strict code style standards across entire codebase

## ESLint Rules Implemented:
- indent: ["error", "tab"] - Enforce tab indentation with SwitchCase support
- no-tabs: ["error", {"allowIndentationTabs": true}] - Disallow tabs except for indentation
- no-multiple-empty-lines: ["error", {"max": 1, "maxBOF": 0, "maxEOF": 0}] - Limit consecutive empty lines
- max-len: ["warn", {"code": 100, "tabWidth": 4, "ignoreUrls": true, "ignoreStrings": true, "ignoreTemplateLiterals": true}] - Enforce 100 character line limit
- linebreak-style: ["error", "unix"] - Enforce Unix line endings (LF)
- quotes: ["error", "double"] - Enforce double quotes
- semi: ["error", "always"] - Enforce semicolons

## Code Fixes Applied:
- 27 no-tabs errors: Removed all tab characters from code content (kept for indentation)
- 48 max-len warnings: Reformatted long lines to fit within 100 character limit
- 4724 linebreak-style errors: Converted all Windows CRLF line endings to Unix LF
- Multiple formatting issues: Fixed spacing, indentation, and code structure

## Files Modified:
- .eslintrc.json: Added ESLint configuration
- index.js: Fixed line length and formatting
- All rater-src/*.js files: Applied consistent code style
- All Windows/Components/*.js files: Fixed formatting and line length

## Result:
- 0 ESLint errors
- 0 ESLint warnings
- All code now follows consistent style guidelines
- Improved code readability and maintainability
- Set * text=auto for automatic line ending detection
- Set *.js text eol=lf to enforce Unix line endings for JavaScript files
- Ensures consistent line endings across different operating systems
@In1quity In1quity mentioned this pull request Sep 16, 2025
@NovemLinguae
Copy link
Copy Markdown
Member

I'm not a big fan of max-len. That makes things easier for certain Linux users that use simple text editors without word wrapping, but makes things harder for the rest of us who have to hit enter a bunch of times when writing code comments, or fix the enters when we modify code comments. I don't think I want to merge a PR that has max-len in it.

linebreak-style seems like a good one to do. I would accept a PR that just had that rule added and its autofixes.

In general, smaller PRs are better. One PR per rule.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants