Skip to content

Commit

Permalink
Merge pull request #18 from hildjj/flat-modules
Browse files Browse the repository at this point in the history
Flat modules
  • Loading branch information
hildjj authored Feb 7, 2024
2 parents bbb814a + 453b8a3 commit 0800c7d
Show file tree
Hide file tree
Showing 16 changed files with 1,892 additions and 12 deletions.
5 changes: 0 additions & 5 deletions .eslintrc.js

This file was deleted.

6 changes: 5 additions & 1 deletion .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ jobs:
node-version: ${{ matrix.node-version }}
cache: npm
- name: Install dependencies
run: npm install && cd test/old && npm install && cd ../flat && npm install
run: |
npm install
(cd test/old && npm install)
(cd test/flat && npm install)
(cd test/flat-module && npm install)
- name: Check coding standards
run: npm run lint
- name: Test
Expand Down
12 changes: 12 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"use strict";

module.exports = [
{
ignores: [
"node_modules/**",
"test/**",
],
},
require("./flat/js"),
require("./flat/cjs"),
];
10 changes: 10 additions & 0 deletions flat/cjs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"use strict";

// Use module.js before this, which has most of the config. This just
// overrides sourceType for .cjs files.
module.exports = {
files: ["**/*.cjs"],
languageOptions: {
sourceType: "commonjs",
},
};
3 changes: 3 additions & 0 deletions flat/globals.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"use strict";

module.exports = require("globals");
1 change: 0 additions & 1 deletion flat/mjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

// Use js.js before this, which has most of the config. This just
// overrides sourceType for .mjs files.
// Future: Figure out what to do for module-type projects.
module.exports = {
files: ["**/*.mjs"],
languageOptions: {
Expand Down
17 changes: 17 additions & 0 deletions flat/module.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"use strict";

const globals = require("globals");
const { rules } = require("../rules/js.js");

module.exports = {
files: ["**/*.js", "**/*.cjs", "**/*.mjs", "**/*.ts"],
plugins: {
"@stylistic": require("@stylistic/eslint-plugin"),
},
languageOptions: {
globals: globals["shared-node-browser"],
ecmaVersion: 2020,
sourceType: "module",
},
rules,
};
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
"eslint"
],
"scripts": {
"lint": "eslint . --ext js",
"lint": "eslint .",
"missing": "npm run missing:js && npm run missing:ts",
"missing:js": "eslint-find-rules --verbose -u index.js",
"missing:ts": "eslint-find-rules --verbose --no-core -u ts.js",
"test": "cd test/old && npm test && cd ../flat && npm test"
"test": "cd test/old && npm test && cd ../flat && npm test && cd ../flat-module && npm test"
},
"author": "Joe Hildebrand <joe-github@cursive.net>",
"license": "MIT",
Expand Down Expand Up @@ -44,5 +44,8 @@
"dependencies": {
"@stylistic/eslint-plugin": "1.6.0",
"globals": "13.24.0"
},
"engines": {
"node": ">=18"
}
}
9 changes: 9 additions & 0 deletions test/flat-module/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import cjs from "@peggyjs/eslint-config/flat/cjs.js";
import module from "@peggyjs/eslint-config/flat/module.js";
import ts from "@peggyjs/eslint-config/flat/ts.js";

export default [
module,
cjs,
ts,
];
Loading

0 comments on commit 0800c7d

Please sign in to comment.