Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update configuration for ESM #133

Merged
merged 1 commit into from Sep 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions .eslintrc.js
@@ -1,18 +1,19 @@
"use strict";

// eslint-disable-next-line no-undef -- Keep backward compatibility with CommonJS.
module.exports = {
parserOptions: {
ecmaVersion: 2019,
sourceType: "module",
},
env: {
es6: true,
node: true,
},
plugins: ["eslint-comments", "jest", "node", "sort-requires"],
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[note] This config is needless because they are automatically set via extends:

  • plugin:eslint-comments/recommended
  • plugin:jest/recommended
  • plugin:node/recommended-module

extends: [
"eslint:recommended",
"plugin:eslint-comments/recommended",
"plugin:node/recommended",
"plugin:node/recommended-module",
"plugin:jest/recommended",
"plugin:jest/style",
"prettier",
Expand Down Expand Up @@ -111,7 +112,6 @@ module.exports = {
"prefer-rest-params": "error",
"prefer-spread": "error",
"prefer-template": "error",
"sort-requires/sort-requires": "error",
strict: ["error", "global"],
"sort-imports": ["error", { allowSeparatedGroups: true }],
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[note] I've enabled allowSeparatedGroups because the pattern grouping imports by an empty line are common in our code base.

https://eslint.org/docs/rules/sort-imports#allowseparatedgroups

},
};
4 changes: 3 additions & 1 deletion __tests__/index.test.js
@@ -1,6 +1,7 @@
"use strict";

const config = require("../");
// eslint-disable-next-line no-undef -- Keep backward compatibility with CommonJS.
const config = require("../index");

it("test basic properties of config", () => {
expect(isObject(config.parserOptions)).toBeTruthy();
Expand All @@ -9,6 +10,7 @@ it("test basic properties of config", () => {
});

it("load config in ESLint to validate all rule syntax is correct", () => {
// eslint-disable-next-line no-undef -- Keep backward compatibility with CommonJS.
const CLIEngine = require("eslint").CLIEngine;

const cli = new CLIEngine({
Expand Down
1 change: 1 addition & 0 deletions index.js
@@ -1,3 +1,4 @@
"use strict";

// eslint-disable-next-line no-undef -- Keep backward compatibility with CommonJS.
module.exports = require("./.eslintrc.js");
13 changes: 1 addition & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Expand Up @@ -28,8 +28,7 @@
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-jest": "^24.3.6",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-sort-requires": "^2.1.0"
"eslint-plugin-node": "^11.1.0"
},
"publishConfig": {
"access": "public"
Expand Down