Skip to content

Commit

Permalink
Use @eslint/eslintrc package to convert Standard's config (#15)
Browse files Browse the repository at this point in the history
* Remove nearly everything, bump ESLint minimum version

* Re-add standard, add eslintrc package

* Use FlatCompat to import eslint-config-standard

* Use shorthand for importing from ./lib
  • Loading branch information
jgarber623 authored Oct 2, 2023
1 parent 90b6821 commit 114ab70
Show file tree
Hide file tree
Showing 5 changed files with 479 additions and 614 deletions.
2 changes: 1 addition & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('./lib/index');
module.exports = require('./lib');
38 changes: 5 additions & 33 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,13 @@
/*
* Import global identifiers from different JavaScript environments.
*
* @see {@link https://www.npmjs.com/package/globals}
* @see {@link https://github.com/sindresorhus/globals/blob/HEAD/globals.json}
*/
const globals = require('globals');
const { FlatCompat } = require('@eslint/eslintrc');

/*
* Import Standard's ESLint configurtation for use with ESLint's new "flat"
* configuration file format.
*
* @see {@link https://github.com/standard/eslint-config-standard/blob/master/.eslintrc.json}
* @see {@link https://eslint.org/docs/latest/use/configure/configuration-files-new}
*/
const standard = require('eslint-config-standard');
const compat = new FlatCompat({
baseDirectory: __dirname
});

module.exports = [
...compat.extends('standard'),
{
plugins: Object.fromEntries(standard.plugins.map(plugin => [plugin, require(`eslint-plugin-${plugin}`)])),
rules: {
...standard.rules,

/*
* Enforces consistent use of semicolons.
*
Expand All @@ -40,20 +27,5 @@ module.exports = [
named: 'never'
}]
}
},
{
/*
* By default, ESLint's "flat" config considers `*.js` files as ECMAScript
* modules (ESM). Instead, consider `*.js` files to be CommonJS modules.
*
* @see {@link https://eslint.org/docs/latest/use/configure/configuration-files-new#configuration-objects}
*/
files: ['**/*.js'],
languageOptions: {
globals: {
...globals.commonjs
},
sourceType: 'commonjs'
}
}
];
Loading

0 comments on commit 114ab70

Please sign in to comment.