| 1 |
import { defineConfig, globalIgnores } from "eslint/config"; |
| 2 |
|
| 3 |
// Custom preprocessor to strip Handlebars templates. |
| 4 |
const handlebarsPreprocessor = { |
| 5 |
processors: { |
| 6 |
"handlebars-js": { |
| 7 |
preprocess(text, filename) { |
| 8 |
if (filename.endsWith('.hbs')) { |
| 9 |
// This is a really dumb strip, which will likely not work |
| 10 |
// for more complex expressions, but for our use is good |
| 11 |
// enough for now. |
| 12 |
return [text.replace(/\{\{.*?\}\}/g, '')]; |
| 13 |
} |
| 14 |
return [text]; |
| 15 |
}, |
| 16 |
postprocess(messages, filename) { |
| 17 |
// Ideally this would update the locations so that they would |
| 18 |
// compensate for the removed ranges. |
| 19 |
return [].concat(...messages); |
| 20 |
}, |
| 21 |
}, |
| 22 |
}, |
| 23 |
}; |
| 24 |
|
| 25 |
export default defineConfig([ |
| 26 |
globalIgnores(["**/**min.js", "**/highlight.js", "**/playground_editor/*"]), |
| 27 |
{ |
| 28 |
rules: { |
| 29 |
indent: ["error", 4], |
| 30 |
"linebreak-style": ["error", "unix"], |
| 31 |
quotes: ["error", "single"], |
| 32 |
semi: ["error", "always"], |
| 33 |
|
| 34 |
"brace-style": ["error", "1tbs", { |
| 35 |
allowSingleLine: false, |
| 36 |
}], |
| 37 |
|
| 38 |
curly: "error", |
| 39 |
"no-trailing-spaces": "error", |
| 40 |
"no-multi-spaces": "error", |
| 41 |
|
| 42 |
"keyword-spacing": ["error", { |
| 43 |
before: true, |
| 44 |
after: true, |
| 45 |
}], |
| 46 |
|
| 47 |
"comma-spacing": ["error", { |
| 48 |
before: false, |
| 49 |
after: true, |
| 50 |
}], |
| 51 |
|
| 52 |
"arrow-spacing": ["error", { |
| 53 |
before: true, |
| 54 |
after: true, |
| 55 |
}], |
| 56 |
|
| 57 |
"key-spacing": ["error", { |
| 58 |
beforeColon: false, |
| 59 |
afterColon: true, |
| 60 |
mode: "strict", |
| 61 |
}], |
| 62 |
|
| 63 |
"func-call-spacing": ["error", "never"], |
| 64 |
"space-infix-ops": "error", |
| 65 |
"space-before-function-paren": ["error", "never"], |
| 66 |
"space-before-blocks": "error", |
| 67 |
|
| 68 |
"no-console": ["error", { |
| 69 |
allow: ["warn", "error"], |
| 70 |
}], |
| 71 |
|
| 72 |
"comma-dangle": ["error", "always-multiline"], |
| 73 |
"comma-style": ["error", "last"], |
| 74 |
|
| 75 |
"max-len": ["error", { |
| 76 |
code: 100, |
| 77 |
tabWidth: 2, |
| 78 |
}], |
| 79 |
|
| 80 |
"eol-last": ["error", "always"], |
| 81 |
"no-extra-parens": "error", |
| 82 |
"arrow-parens": ["error", "as-needed"], |
| 83 |
|
| 84 |
"no-unused-vars": ["error", { |
| 85 |
argsIgnorePattern: "^_", |
| 86 |
varsIgnorePattern: "^_", |
| 87 |
}], |
| 88 |
|
| 89 |
"prefer-const": ["error"], |
| 90 |
"no-var": "error", |
| 91 |
eqeqeq: "error", |
| 92 |
}, |
| 93 |
}, |
| 94 |
{ |
| 95 |
files: ["**/*.js.hbs"], |
| 96 |
processor: handlebarsPreprocessor.processors["handlebars-js"], |
| 97 |
}, |
| 98 |
]); |