Skip to content

Add eslint rules#1564

Closed
jochenklar wants to merge 3 commits into2.5.0/releasefrom
2.5.0/eslint-rules
Closed

Add eslint rules#1564
jochenklar wants to merge 3 commits into2.5.0/releasefrom
2.5.0/eslint-rules

Conversation

@jochenklar
Copy link
Copy Markdown
Member

This PR adds rules to .eslintrc.js to ensure a consistent JS style. The rules cause a lot of issues which need to be resolved after we agreed on the rules and probably after other branches have been merged.

@CalamityC
Copy link
Copy Markdown
Collaborator

These three ESLint rules can clash in certain cases:

'multiline-ternary': ['error', 'never'],
'max-len': ['error', { code: 120 }],
'react/jsx-curly-newline': ['error', { multiline: 'require' }]
  • multiline-ternary: never → ternaries must stay on one line
  • max-len: 120 → line length is limited
  • react/jsx-curly-newline → multiline JSX expressions should be split across lines

For longer ternaries (especially in JSX), this can lead to situations where:

  • breaking the ternary is not allowed
  • keeping it on one line exceeds max length

Just something to be aware of when formatting conditional expressions.

@CalamityC
Copy link
Copy Markdown
Collaborator

These rules can interact in a slightly confusing way:

'multiline-ternary': ['error', 'never'],
'indent': ['error', 2, { offsetTernaryExpressions: true }]

multiline-ternary: never → ternaries must stay on one line
offsetTernaryExpressions: true → controls indentation for multiline ternaries

Since multiline ternaries are not allowed, the offsetTernaryExpressions option never really comes into effect.

Just something to keep in mind when looking at the config.

@CalamityC
Copy link
Copy Markdown
Collaborator

After reading through PR#1565, especially this part of STYLE.md,
I'm pretty convinced that we don't want the rule
'multiline-ternary': ['error', 'never'],

@jochenklar
Copy link
Copy Markdown
Member Author

@CalamityC https://eslint.org/docs/latest/rules/multiline-ternary

We will remove { offsetTernaryExpressions: true }.

@jochenklar
Copy link
Copy Markdown
Member Author

@CalamityC I added some rules for the imports. It is now:

import React from 'react'
import PropTypes from 'prop-types'
// all other external imports

// imports from rdmo

// components from rdmo

// imports from ..

// components from ..

// imports from .

// components from .

The trick is that components have upper case filenames. I know this is not the case for index.js, but I can live with that.

@jochenklar
Copy link
Copy Markdown
Member Author

Closed in favor of #1572.

@jochenklar jochenklar closed this Mar 28, 2026
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