Skip to content

Commit

Permalink
Add additional ESM rules
Browse files Browse the repository at this point in the history
  • Loading branch information
niksy committed Apr 14, 2024
1 parent b54999c commit 32df539
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"root": true,
"extends": ["./index.js", "eslint-config-prettier"],
"parserOptions": {
"sourceType": "commonjs"
},
"plugins": [
"eslint-plugin-prettier",
"eslint-plugin-unicorn",
Expand Down
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ module.exports = {
es2022: true
},
parserOptions: {
ecmaVersion: 2022
ecmaVersion: 2022,
sourceType: 'module'
},
plugins: [
'eslint-plugin-promise',
Expand All @@ -15,7 +16,6 @@ module.exports = {
'eslint-plugin-jsdoc',
'eslint-plugin-import'
],

rules: {
'n/no-sync': 1,
'n/no-restricted-require': 0,
Expand Down
3 changes: 1 addition & 2 deletions test/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{
"extends": ["../tests.js"],
"plugins": ["eslint-plugin-unicorn", "eslint-plugin-import"],
"parserOptions": {
"ecmaVersion": 2022,
"sourceType": "module"
},
"plugins": ["eslint-plugin-unicorn", "eslint-plugin-import"],
"rules": {
"unicorn/prefer-module": 2,
"import/no-commonjs": 2
Expand Down
6 changes: 3 additions & 3 deletions test/fixtures/default.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ let a = 1;
const b = 2;
b = 3;

function foo () {
function foo1 () {
var bar = {
bad: () => {
var a = `a b c ${d} e`;
Expand All @@ -15,7 +15,7 @@ function foo () {
bar.catch = function () {};
}

var foo = {};
var foo2 = {};
var bar = {};

fn(_.extend(foo, bar));
Expand All @@ -27,4 +27,4 @@ var p = new Promise(function ( r1, r2 ) {})

throw Error();

var [foo, ... bar] = [1, 2];
var [foo3, ... bar] = [1, 2];
2 changes: 1 addition & 1 deletion test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ async function runEslint(file, config) {

return results.messages.map((error) => {
if (error.ruleId === null && error.fatal === true) {
return 'parsing error';
return error.message ?? 'Parsing error';
}
return error.ruleId;
});
Expand Down

0 comments on commit 32df539

Please sign in to comment.