|
| 1 | +import js from '@eslint/js' |
| 2 | +import globals from 'globals' |
| 3 | + |
| 4 | +export default [ |
| 5 | + js.configs.recommended, |
| 6 | + { |
| 7 | + languageOptions: { |
| 8 | + ecmaVersion: 2022, |
| 9 | + sourceType: 'module', |
| 10 | + globals: { |
| 11 | + ...globals.node, |
| 12 | + ...globals.mocha, |
| 13 | + fetch: 'readonly', |
| 14 | + AbortController: 'readonly', |
| 15 | + Headers: 'readonly', |
| 16 | + Request: 'readonly', |
| 17 | + Response: 'readonly', |
| 18 | + URL: 'readonly', |
| 19 | + URLSearchParams: 'readonly' |
| 20 | + } |
| 21 | + }, |
| 22 | + rules: { |
| 23 | + // StandardJS-like rules |
| 24 | + 'no-unused-vars': ['error', { |
| 25 | + args: 'none', |
| 26 | + caughtErrors: 'none', |
| 27 | + ignoreRestSiblings: true, |
| 28 | + vars: 'all' |
| 29 | + }], |
| 30 | + 'no-empty': ['error', { allowEmptyCatch: true }], |
| 31 | + 'no-var': 'error', |
| 32 | + 'prefer-const': ['error', { destructuring: 'all' }], |
| 33 | + 'quote-props': ['error', 'as-needed'], |
| 34 | + semi: ['error', 'never'], |
| 35 | + quotes: ['error', 'single', { avoidEscape: true, allowTemplateLiterals: true }], |
| 36 | + 'comma-dangle': ['error', 'never'], |
| 37 | + 'space-before-function-paren': ['error', 'always'], |
| 38 | + indent: ['error', 2, { |
| 39 | + SwitchCase: 1, |
| 40 | + VariableDeclarator: 1, |
| 41 | + outerIIFEBody: 1, |
| 42 | + MemberExpression: 1, |
| 43 | + FunctionDeclaration: { parameters: 1, body: 1 }, |
| 44 | + FunctionExpression: { parameters: 1, body: 1 }, |
| 45 | + CallExpression: { arguments: 1 }, |
| 46 | + ArrayExpression: 1, |
| 47 | + ObjectExpression: 1, |
| 48 | + ImportDeclaration: 1, |
| 49 | + flatTernaryExpressions: false, |
| 50 | + ignoreComments: false, |
| 51 | + ignoredNodes: ['TemplateLiteral *', 'JSXElement', 'JSXElement > *', 'JSXAttribute', 'JSXIdentifier', 'JSXNamespacedName', 'JSXMemberExpression', 'JSXSpreadAttribute', 'JSXExpressionContainer', 'JSXOpeningElement', 'JSXClosingElement', 'JSXFragment', 'JSXOpeningFragment', 'JSXClosingFragment', 'JSXText', 'JSXEmptyExpression', 'JSXSpreadChild'], |
| 52 | + offsetTernaryExpressions: true |
| 53 | + }], |
| 54 | + 'key-spacing': ['error', { beforeColon: false, afterColon: true }], |
| 55 | + 'keyword-spacing': ['error', { before: true, after: true }], |
| 56 | + 'object-curly-spacing': ['error', 'always'], |
| 57 | + 'array-bracket-spacing': ['error', 'never'], |
| 58 | + 'space-in-parens': ['error', 'never'], |
| 59 | + 'space-before-blocks': ['error', 'always'], |
| 60 | + 'space-infix-ops': 'error', |
| 61 | + 'eol-last': 'error', |
| 62 | + 'no-multiple-empty-lines': ['error', { max: 1, maxBOF: 0, maxEOF: 0 }], |
| 63 | + 'no-trailing-spaces': 'error', |
| 64 | + 'comma-spacing': ['error', { before: false, after: true }], |
| 65 | + 'no-multi-spaces': 'error', |
| 66 | + 'no-mixed-operators': ['error', { |
| 67 | + groups: [ |
| 68 | + ['==', '!=', '===', '!==', '>', '>=', '<', '<='], |
| 69 | + ['&&', '||'], |
| 70 | + ['in', 'instanceof'] |
| 71 | + ], |
| 72 | + allowSamePrecedence: true |
| 73 | + }], |
| 74 | + 'operator-linebreak': ['error', 'after', { overrides: { '?': 'before', ':': 'before', '|>': 'before' } }], |
| 75 | + 'brace-style': ['error', '1tbs', { allowSingleLine: true }], |
| 76 | + 'arrow-spacing': ['error', { before: true, after: true }], |
| 77 | + 'padded-blocks': ['error', { blocks: 'never', switches: 'never', classes: 'never' }], |
| 78 | + 'no-use-before-define': ['error', { functions: false, classes: false, variables: false }] |
| 79 | + } |
| 80 | + }, |
| 81 | + { |
| 82 | + // Browser files (client-side code) |
| 83 | + files: ['common/**/*.mjs'], |
| 84 | + languageOptions: { |
| 85 | + globals: { |
| 86 | + ...globals.browser, |
| 87 | + solid: 'readonly', |
| 88 | + UI: 'readonly', |
| 89 | + owaspPasswordStrengthTest: 'readonly' |
| 90 | + } |
| 91 | + } |
| 92 | + }, |
| 93 | + { |
| 94 | + ignores: [ |
| 95 | + 'node_modules/**', |
| 96 | + 'coverage/**', |
| 97 | + '.db/**', |
| 98 | + 'data/**', |
| 99 | + 'resources/**' |
| 100 | + ] |
| 101 | + } |
| 102 | +] |
0 commit comments