1- 'use strict'
1+ import { createRequire } from 'node:module'
2+ import path from 'node:path'
3+ import { fileURLToPath } from 'node:url'
24
3- const path = require ( 'node:path' )
4-
5- const {
5+ import {
66 convertIgnorePatternToMinimatch ,
77 includeIgnoreFile ,
8- } = require ( '@eslint/compat' )
9- const js = require ( '@eslint/js' )
10- const importXPlugin = require ( 'eslint-plugin-import-x' )
11- const nodePlugin = require ( 'eslint-plugin-n' )
12- const sortDestructureKeysPlugin = require ( 'eslint-plugin-sort-destructure-keys' )
13- const unicornPlugin = require ( 'eslint-plugin-unicorn' )
14- const globals = require ( 'globals' )
8+ } from '@eslint/compat'
9+ import js from '@eslint/js'
10+ import importXPlugin from 'eslint-plugin-import-x'
11+ import nodePlugin from 'eslint-plugin-n'
12+ import sortDestructureKeysPlugin from 'eslint-plugin-sort-destructure-keys'
13+ import unicornPlugin from 'eslint-plugin-unicorn'
14+ import globals from 'globals'
1515
16- const constants = require ( '@socketsecurity/registry/lib/constants' )
17- const { BIOME_JSON , GITIGNORE , LATEST } = constants
16+ import constants from '@socketsecurity/registry/lib/constants'
1817
19- const rootPath = __dirname
18+ const __filename = fileURLToPath ( import . meta. url )
19+ const __dirname = path . dirname ( __filename )
20+ const require = createRequire ( import . meta. url )
2021
21- const biomeConfigPath = path . join ( rootPath , BIOME_JSON )
22- const gitignorePath = path . join ( rootPath , GITIGNORE )
22+ const rootPath = __dirname
2323
24- const biomeConfig = require ( biomeConfigPath )
2524const nodeGlobalsConfig = Object . fromEntries (
2625 Object . entries ( globals . node ) . map ( ( [ k ] ) => [ k , 'readonly' ] ) ,
2726)
2827
29- module . exports = [
28+ const biomeConfigPath = path . join ( rootPath , 'biome.json' )
29+ const biomeConfig = require ( biomeConfigPath )
30+ const biomeIgnores = {
31+ name : `Imported biome.json ignore patterns` ,
32+ ignores : biomeConfig . files . includes
33+ . filter ( p => p . startsWith ( '!' ) )
34+ . map ( p => convertIgnorePatternToMinimatch ( p . slice ( 1 ) ) ) ,
35+ }
36+
37+ const gitignorePath = path . join ( rootPath , '.gitignore' )
38+ const gitIgnores = {
39+ ...includeIgnoreFile ( gitignorePath ) ,
40+ name : `Imported .gitignore ignore patterns` ,
41+ }
42+
43+ export default [
3044 includeIgnoreFile ( gitignorePath ) ,
31- {
32- name : 'Imported biome.json ignore patterns' ,
33- ignores : biomeConfig . files . includes
34- . filter ( p => p . startsWith ( '!' ) )
35- . map ( p => convertIgnorePatternToMinimatch ( p . slice ( 1 ) ) ) ,
36- } ,
37- {
38- ignores : [ 'coverage/**' ] ,
39- } ,
45+ biomeIgnores ,
46+ gitIgnores ,
4047 {
4148 ...js . configs . recommended ,
4249 ...importXPlugin . flatConfigs . recommended ,
@@ -45,7 +52,7 @@ module.exports = [
4552 ...js . configs . recommended . languageOptions ,
4653 ...importXPlugin . flatConfigs . recommended . languageOptions ,
4754 ...nodePlugin . configs [ 'flat/recommended-script' ] . languageOptions ,
48- ecmaVersion : LATEST ,
55+ ecmaVersion : 'latest' ,
4956 globals : {
5057 ...js . configs . recommended . languageOptions ?. globals ,
5158 ...importXPlugin . flatConfigs . recommended . languageOptions ?. globals ,
@@ -152,4 +159,4 @@ module.exports = [
152159 sourceType : 'module' ,
153160 } ,
154161 } ,
155- ]
162+ ]
0 commit comments