Skip to content

Commit

Permalink
Update ESLint Config to Support ESLint 9+
Browse files Browse the repository at this point in the history
  • Loading branch information
Braden-077 authored Dec 5, 2024
2 parents 5451f2a + 48f2194 commit f5df40b
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 131 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def install_eslint
end

def add_config
template '.eslintrc.cjs', '.eslintrc.cjs'
template 'eslint.config.js', 'eslint.config.js'
end

def add_eslint_command_to_package_json
Expand Down
130 changes: 0 additions & 130 deletions lib/generators/rolemodel/linters/eslint/templates/.eslintrc.cjs

This file was deleted.

92 changes: 92 additions & 0 deletions lib/generators/rolemodel/linters/eslint/templates/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import globals from 'globals'

export default [
{
ignores: ['app/assets/builds/**/*']
},
{ name: 'airbnb' },
{
languageOptions: {
parserOptions: {
ecmaFeatures: {
jsx: true
},
ecmaVersion: 'latest',
globals: {
...globals.browser,
...globals.es6
}
}
},
rules: {
'no-unused-vars': [
'error',
{
argsIgnorePattern: '^_', // Allow unused arguments starting with an underscore
varsIgnorePattern: '^_' // Allow unused variables starting with an underscore
}
],

// No semicolons
semi: ['error', 'never'],
'no-unexpected-multiline': 'error',

// 1. We follow the convention of naming "private" properties with a leading underscore
// 2. This conflicts with the no-unused-vars config
'no-underscore-dangle': 'off',

// Multiple variable declarations (without assignment) on the same line
// without multiple let/const
'one-var': ['error', { initialized: 'never', uninitialized: 'always' }],
'one-var-declaration-per-line': ['error', 'initializations'],

// Don't require naming all non-arrow functions. Modern browsers can usually
// detect the correct name if it's assigned to a variable or property.
'func-names': 'off',

// Don't require instance methods to use `this` (the rule name is confusing)
'class-methods-use-this': 'off',

// Turning this on addresses some quirks with using `var`. It's unnecessary
// for `let` and `const`.
'no-loop-func': 'off',

// Turning this on requires destructuring in too many cases
'prefer-destructuring': 'off',

// Turning this on prevents directly importing sub-dependencies
'import/no-extraneous-dependencies': 'off',

// One-liner methods can be readable without the extra spacing
'lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: true }],

// Allow assigning to properties of arguments (might consider completely disabling this rule)
'no-param-reassign': ['error', { props: false }],

// Sufficiently high that it won't be too annoying
'max-len': ['warn', 130],

// Disabled because it complains if you mix `return` with `return <value>` in a function
'consistent-return': 'off',

// Allow patterns like `while ((a = getNextValue()))`
'no-cond-assign': ['error', 'except-parens'],

// 'import/extensions': ['warn', 'ignorePackages'],

// Default disallows mixing exponentiation with other arithmetic operators
'no-mixed-operators': [
'error',
{
allowSamePrecedence: false, // Could also make this true
groups: [
['&', '|', '^', '~', '<<', '>>', '>>>'],
['==', '!=', '===', '!==', '>', '>=', '<', '<='],
['&&', '||'],
['in', 'instanceof']
]
}
]
}
}
]

0 comments on commit f5df40b

Please sign in to comment.