|
| 1 | +const prettier = require('eslint-plugin-prettier'); |
| 2 | +const globals = require('globals'); |
| 3 | +const babelParser = require('@babel/eslint-parser'); |
| 4 | +const path = require('path'); |
| 5 | +const {fileURLToPath} = require('url'); |
| 6 | +const js = require('@eslint/js'); |
| 7 | +const {FlatCompat} = require('@eslint/eslintrc'); |
| 8 | + |
| 9 | +//const __filename = fileURLToPath(import.meta.url); |
| 10 | +//const __dirname = path.dirname(__filename); |
| 11 | +const compat = new FlatCompat({ |
| 12 | + baseDirectory: __dirname, |
| 13 | + recommendedConfig: js.configs.recommended, |
| 14 | + allConfig: js.configs.all, |
| 15 | +}); |
| 16 | +// Fix TypeError Key "languageOptions": Key "globals": Global "AudioWorkletGlobalScope " has leading or trailing whitespace. |
| 17 | +const GLOBALS_BROWSER_FIX = Object.assign({}, globals.browser, { |
| 18 | + AudioWorkletGlobalScope: globals.browser['AudioWorkletGlobalScope '], |
| 19 | +}); |
| 20 | +delete GLOBALS_BROWSER_FIX['AudioWorkletGlobalScope ']; |
| 21 | + |
| 22 | +module.exports = [ |
| 23 | + ...compat.extends('eslint:recommended', 'plugin:prettier/recommended'), |
| 24 | + { |
| 25 | + plugins: { |
| 26 | + prettier, |
| 27 | + }, |
| 28 | + |
| 29 | + languageOptions: { |
| 30 | + globals: { |
| 31 | + ...GLOBALS_BROWSER_FIX, |
| 32 | + ...globals.node, |
| 33 | + ...globals.jest, |
| 34 | + }, |
| 35 | + |
| 36 | + parser: babelParser, |
| 37 | + ecmaVersion: 12, |
| 38 | + sourceType: 'commonjs', |
| 39 | + |
| 40 | + parserOptions: { |
| 41 | + ecmaFeatures: { |
| 42 | + //jsx: true, |
| 43 | + }, |
| 44 | + |
| 45 | + allowImportExportEverywhere: false, |
| 46 | + }, |
| 47 | + }, |
| 48 | + |
| 49 | + rules: { |
| 50 | + 'prettier/prettier': [ |
| 51 | + 'error', |
| 52 | + { |
| 53 | + endOfLine: 'auto', |
| 54 | + }, |
| 55 | + ], |
| 56 | + }, |
| 57 | + }, |
| 58 | +]; |
0 commit comments