|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +const js = require('@eslint/js'); |
| 4 | +const { FlatCompat } = require('@eslint/eslintrc'); |
| 5 | +const globals = require('globals'); |
| 6 | +const markdown = require('eslint-plugin-markdown'); |
| 7 | +const eslintPluginConfig = require('eslint-plugin-eslint-plugin/configs/all'); |
| 8 | + |
| 9 | +const compat = new FlatCompat({ |
| 10 | + baseDirectory: __dirname, |
| 11 | + recommendedConfig: js.configs.recommended, |
| 12 | +}); |
| 13 | + |
| 14 | +module.exports = [ |
| 15 | + ...compat.extends( |
| 16 | + 'not-an-aardvark/node', |
| 17 | + 'plugin:eslint-comments/recommended', |
| 18 | + 'plugin:node/recommended', |
| 19 | + 'plugin:prettier/recommended', |
| 20 | + 'plugin:unicorn/recommended' |
| 21 | + ), |
| 22 | + { |
| 23 | + languageOptions: { sourceType: 'commonjs' }, |
| 24 | + rules: { |
| 25 | + 'comma-dangle': [ |
| 26 | + 'error', |
| 27 | + { |
| 28 | + arrays: 'always-multiline', |
| 29 | + objects: 'always-multiline', |
| 30 | + functions: 'never', // disallow trailing commas in function(es2017) |
| 31 | + }, |
| 32 | + ], |
| 33 | + 'require-jsdoc': 'error', |
| 34 | + |
| 35 | + 'eslint-comments/no-unused-disable': 'error', |
| 36 | + 'eslint-comments/require-description': 'error', |
| 37 | + |
| 38 | + 'unicorn/consistent-function-scoping': 'off', |
| 39 | + 'unicorn/no-array-callback-reference': 'off', |
| 40 | + 'unicorn/no-array-for-each': 'off', |
| 41 | + 'unicorn/no-array-reduce': 'off', |
| 42 | + 'unicorn/no-null': 'off', |
| 43 | + 'unicorn/prefer-module': 'off', |
| 44 | + 'unicorn/prefer-node-protocol': 'off', // TODO: enable once we drop support for Node 14.17. |
| 45 | + 'unicorn/prevent-abbreviations': 'off', |
| 46 | + }, |
| 47 | + }, |
| 48 | + { |
| 49 | + // Apply eslint-plugin rules to our own rules/tests (but not docs). |
| 50 | + files: ['lib/**/*.js', 'tests/**/*.js'], |
| 51 | + plugins: eslintPluginConfig.plugins, |
| 52 | + rules: { |
| 53 | + ...eslintPluginConfig.rules, |
| 54 | + 'eslint-plugin/report-message-format': ['error', '^[^a-z].*.$'], |
| 55 | + 'eslint-plugin/require-meta-docs-url': [ |
| 56 | + 'error', |
| 57 | + { |
| 58 | + pattern: |
| 59 | + 'https://github.com/eslint-community/eslint-plugin-eslint-plugin/tree/HEAD/docs/rules/{{name}}.md', |
| 60 | + }, |
| 61 | + ], |
| 62 | + }, |
| 63 | + }, |
| 64 | + { |
| 65 | + files: ['tests/**/*.js'], |
| 66 | + languageOptions: { globals: globals.mocha }, |
| 67 | + }, |
| 68 | + { |
| 69 | + files: ['**/*.md'], |
| 70 | + plugins: { markdown }, |
| 71 | + processor: 'markdown/markdown', |
| 72 | + }, |
| 73 | + { |
| 74 | + // Markdown JS code samples in documentation: |
| 75 | + files: ['**/*.md/*.js'], |
| 76 | + plugins: { markdown }, |
| 77 | + linterOptions: { noInlineConfig: true }, |
| 78 | + rules: { |
| 79 | + 'no-undef': 'off', |
| 80 | + 'no-unused-vars': 'off', |
| 81 | + strict: 'off', |
| 82 | + |
| 83 | + 'eslint-comments/require-description': 'off', |
| 84 | + |
| 85 | + 'unicorn/filename-case': 'off', |
| 86 | + }, |
| 87 | + }, |
| 88 | +]; |
0 commit comments