|
| 1 | +'use strict' |
| 2 | + |
| 3 | +const eslintPluginImportX = require('eslint-plugin-import-x') |
| 4 | +const eslintPluginJs = require('@eslint/js') |
| 5 | +const eslintPluginN = require('eslint-plugin-n') |
| 6 | +const eslintPluginStylistic = require('@stylistic/eslint-plugin') |
| 7 | +const eslintPluginUnicorn = require('eslint-plugin-unicorn').default |
| 8 | +const globals = require('globals') |
| 9 | + |
| 10 | +module.exports = [ |
| 11 | + eslintPluginJs.configs.recommended, |
| 12 | + eslintPluginImportX.flatConfigs.recommended, |
| 13 | + eslintPluginN.configs['flat/recommended-script'], |
| 14 | + eslintPluginStylistic.configs.recommended, |
| 15 | + eslintPluginUnicorn.configs.recommended, |
| 16 | + { |
| 17 | + languageOptions: { |
| 18 | + ecmaVersion: 2022, |
| 19 | + sourceType: 'commonjs', |
| 20 | + globals: { |
| 21 | + ...globals.es2022, |
| 22 | + ...globals.node, |
| 23 | + }, |
| 24 | + }, |
| 25 | + settings: { |
| 26 | + // Used by `eslint-plugin-n` to determine the minimum version of Node.js to support. |
| 27 | + // Normally setting this in the `package.json` engines field is enough, but we can't use that as it will fail |
| 28 | + // when running `yarn copy-artifacts` inside the prebuildify Docker container which uses Node.js 12. |
| 29 | + node: { version: '>=18.0.0' }, |
| 30 | + }, |
| 31 | + rules: { |
| 32 | + '@stylistic/brace-style': ['error', '1tbs'], |
| 33 | + '@stylistic/space-before-function-paren': ['error', 'always'], |
| 34 | + 'import-x/extensions': ['error', 'never', { json: 'always' }], |
| 35 | + 'import-x/no-absolute-path': 'error', |
| 36 | + 'import-x/no-webpack-loader-syntax': 'error', |
| 37 | + 'import-x/order': ['error', { |
| 38 | + 'newlines-between': 'always', |
| 39 | + }], |
| 40 | + 'n/no-process-exit': 'off', // Duplicate of unicorn/no-process-exit |
| 41 | + 'prefer-const': 'error', |
| 42 | + 'unicorn/prefer-module': 'off', // We use CJS |
| 43 | + 'unicorn/prevent-abbreviations': 'off', |
| 44 | + }, |
| 45 | + }, |
| 46 | + { |
| 47 | + files: ['load.js'], |
| 48 | + languageOptions: { |
| 49 | + globals: { |
| 50 | + __webpack_require__: 'readonly', |
| 51 | + __non_webpack_require__: 'readonly', |
| 52 | + }, |
| 53 | + }, |
| 54 | + }, |
| 55 | + { |
| 56 | + // This script runs inside the prebuildify Docker container which uses Node.js 12 |
| 57 | + files: ['scripts/copy-artifacts.js'], |
| 58 | + languageOptions: { |
| 59 | + ecmaVersion: 2019, |
| 60 | + }, |
| 61 | + settings: { |
| 62 | + // Used by `eslint-plugin-n` to determine the minimum version of Node.js to support. |
| 63 | + node: { version: '>=12.0.0' }, |
| 64 | + }, |
| 65 | + rules: { |
| 66 | + 'unicorn/prefer-node-protocol': 'off', |
| 67 | + }, |
| 68 | + }, |
| 69 | + { |
| 70 | + ignores: ['build/', 'target/', 'prebuilds/'], |
| 71 | + }, |
| 72 | +] |
0 commit comments