Skip to content

Commit

Permalink
Fix flat config
Browse files Browse the repository at this point in the history
Closes #358
  • Loading branch information
sindresorhus committed May 11, 2024
1 parent 73dc210 commit eb6088b
Showing 1 changed file with 34 additions and 25 deletions.
59 changes: 34 additions & 25 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

const path = require('node:path');
const importModules = require('import-modules');
const {name, version} = require('./package.json');

const rules = {
const recommendedRules = {
'ava/assertion-arguments': 'error',
'ava/hooks-order': 'error',
'ava/max-asserts': [
Expand Down Expand Up @@ -36,31 +37,39 @@ const rules = {
'ava/use-true-false': 'error',
};

module.exports = {
const plugin = {
meta: {
name,
version,
},
rules: importModules(path.resolve(__dirname, 'rules'), {camelize: false}),
configs: {
recommended: {
env: {
es6: true,
},
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
},
plugins: [
'ava',
],
rules: {
...rules,
},
configs: {},
};

Object.assign(plugin.configs, {
recommended: {
env: {
es6: true,
},
'flat/recommended': {
plugins: {
ava: 'ava',
},
rules: {
...rules,
},
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
},
plugins: [
'ava',
],
rules: {
...recommendedRules,
},
},
};
'flat/recommended': {
plugins: {
ava: plugin,
},
rules: {
...recommendedRules,
},
},
});

module.exports = plugin;

0 comments on commit eb6088b

Please sign in to comment.