| import globals from 'globals' |
| import { globalIgnores } from 'eslint/config' |
| import eslint from '@eslint/js' |
| import pluginPlaywright from 'eslint-plugin-playwright' |
| import prettierEslintInteroperabilityConfig from 'eslint-config-prettier/flat' |
| import tseslint from 'typescript-eslint' |
| import { DEFAULT_GLOBALS } from './compiler/index.js' |
|
|
| const DEFAULT_BOOLEAN_SETTINGS = Object.fromEntries( |
| Object.entries(DEFAULT_GLOBALS).map(([global]) => [global, 'readonly']) |
| ) |
|
|
| export default tseslint.config([ |
| globalIgnores(['./npm_package/plausible.js']), |
| |
| eslint.configs.recommended, |
| tseslint.configs.recommended, |
| { |
| rules: { |
| '@typescript-eslint/no-unused-vars': [ |
| 'error', |
| { |
| argsIgnorePattern: '^_', |
| varsIgnorePattern: '^_', |
| caughtErrorsIgnorePattern: '^_' |
| } |
| ], |
| '@typescript-eslint/no-unused-expressions': [ |
| 'error', |
| { |
| allowShortCircuit: true |
| } |
| ] |
| } |
| }, |
| |
| { |
| files: [ |
| 'compile.js', |
| 'compiler/**/*.js', |
| 'playwright.config.js', |
| 'eslint.config.mjs', |
| 'playwright.config.ts', |
| 'test/support/server.js' |
| ], |
| languageOptions: { ecmaVersion: 'latest', globals: globals.node } |
| }, |
| |
| { |
| files: ['src/**/*.js'], |
| languageOptions: { |
| ecmaVersion: 5, |
| globals: { |
| ...globals.browser, |
| ...DEFAULT_BOOLEAN_SETTINGS, |
| plausible: 'writeable' |
| }, |
| sourceType: 'commonjs' |
| } |
| }, |
| |
| { |
| files: ['installation_support/**/*.js'], |
| languageOptions: { |
| ecmaVersion: 'latest', |
| globals: { |
| ...globals.browser, |
| plausible: 'readable' |
| } |
| } |
| }, |
| |
| { |
| files: ['test/**/*.js', 'test/**/*.ts'], |
| ...pluginPlaywright.configs['flat/recommended'], |
| languageOptions: { |
| ecmaVersion: 'latest', |
| globals: { |
| |
| ...globals.node, |
| |
| ...globals.browser, |
| plausible: 'readable' |
| } |
| }, |
| rules: { |
| ...pluginPlaywright.configs['flat/recommended'].rules, |
| 'playwright/expect-expect': [ |
| 'error', |
| { |
| assertFunctionNames: ['expectPlausibleInAction'] |
| } |
| ], |
| 'playwright/no-wait-for-timeout': 'off', |
| 'playwright/no-conditional-in-test': 'off', |
| 'playwright/no-skipped-test': 'off' |
| } |
| }, |
| prettierEslintInteroperabilityConfig |
| ]) |
|
|