|
| 1 | +// eslint.config.js |
| 2 | + |
| 3 | +import { FlatCompat } from '@eslint/eslintrc'; |
| 4 | +import js from '@eslint/js'; |
| 5 | +import path from 'path'; |
| 6 | +import { fileURLToPath } from 'url'; |
| 7 | + |
| 8 | +// mimic CommonJS variables -- not needed if using CommonJS |
| 9 | +const __filename = fileURLToPath(import.meta.url); |
| 10 | +const __dirname = path.dirname(__filename); |
| 11 | + |
| 12 | +const compat = new FlatCompat({ |
| 13 | + baseDirectory: __dirname, // optional; default: process.cwd() |
| 14 | + resolvePluginsRelativeTo: __dirname, // optional |
| 15 | + recommendedConfig: js.configs.recommended, // optional unless you're using "eslint:recommended" |
| 16 | + allConfig: js.configs.all // optional unless you're using "eslint:all" |
| 17 | +}); |
| 18 | + |
| 19 | +export default [ |
| 20 | + // translate an entire config |
| 21 | + ...compat.config({ |
| 22 | + // ╔═╗╔═╗╦ ╦╔╗╔╔╦╗┬─┐┌─┐ |
| 23 | + // ║╣ ╚═╗║ ║║║║ ║ ├┬┘│ |
| 24 | + // o╚═╝╚═╝╩═╝╩╝╚╝ ╩ ┴└─└─┘ |
| 25 | + // A set of basic code conventions (similar to a .jshintrc file) designed to |
| 26 | + // and encourage quality and consistency across your Sails app's code base. |
| 27 | + // These rules are checked against automatically any time you run `npm test`. |
| 28 | + // |
| 29 | + // > Note: If you're using mocha, you'll want to add an extra override file to your |
| 30 | + // > `test/` folder so that eslint will tolerate mocha-specific globals like `before` |
| 31 | + // > and `describe`. |
| 32 | + // |
| 33 | + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 34 | + // For more information about any of the rules below, check out the relevant |
| 35 | + // reference page on eslint.org. For example, to get details on "no-sequences", |
| 36 | + // you would visit `http://eslint.org/docs/rules/no-sequences`. |
| 37 | + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 38 | + |
| 39 | + 'env': { |
| 40 | + 'node': true, |
| 41 | + 'es6': true, |
| 42 | + 'es2020': true |
| 43 | + // "jest/globals": true |
| 44 | + }, |
| 45 | + |
| 46 | + 'parser': '@babel/eslint-parser', |
| 47 | + |
| 48 | + 'parserOptions': { |
| 49 | + 'requireConfigFile': false, |
| 50 | + 'ecmaVersion': 2022, |
| 51 | + 'sourceType': 'module' |
| 52 | + // "babelOptions": { |
| 53 | + // "parserOpts": { |
| 54 | + // "plugins": ["importAssertions"] |
| 55 | + // } |
| 56 | + // } |
| 57 | + }, |
| 58 | + |
| 59 | + 'globals': { |
| 60 | + // If "no-undef" is enabled below and your app uses globals, be sure to list all |
| 61 | + // relevant globals below (including the globalIds of models, if appropriate): |
| 62 | + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 63 | + // ...and any other backend globals (e.g. `"Organization": true`) |
| 64 | + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 65 | + }, |
| 66 | + |
| 67 | + 'plugins': [ |
| 68 | + // "import", |
| 69 | + 'jest', |
| 70 | + 'prettier' |
| 71 | + ], |
| 72 | + |
| 73 | + 'extends': [ |
| 74 | + 'eslint:recommended', |
| 75 | + // "airbnb-base", |
| 76 | + 'prettier', |
| 77 | + // "plugin:import/errors", |
| 78 | + // "plugin:import/warnings", |
| 79 | + 'plugin:jest/all' |
| 80 | + ], |
| 81 | + |
| 82 | + 'rules': { |
| 83 | + 'prettier/prettier': ['warn'] |
| 84 | + |
| 85 | + // // CUSTOM OVERRIDES |
| 86 | + // // TODO: remove no-restricted-syntax override and replace for...Of due |
| 87 | + // /// "iterators/generators require regenerator-runtime, which is too heavyweight for this guide to allow them. Separately, loops should be avoided in favor of array iterations." |
| 88 | + // "no-restricted-syntax": 0, |
| 89 | + // "no-console": "off", |
| 90 | + // "no-underscore-dangle": 0, |
| 91 | + // "no-plusplus": ["error", { "allowForLoopAfterthoughts": true }], |
| 92 | + // "import/no-unresolved": [2, {"commonjs": true, "amd": true}], |
| 93 | + // "import/extensions": ["error", { "js": "always", "json": "always"}], |
| 94 | + // "import/no-extraneous-dependencies": ["error", {"devDependencies": ["**/*.test.js", "**/*.bruteforce-test.js", "**/*.spec.js"]}] |
| 95 | + } |
| 96 | + }) |
| 97 | +]; |
0 commit comments