Skip to content

Commit

Permalink
Merge pull request #35 from hildjj/modernize
Browse files Browse the repository at this point in the history
Modernize
  • Loading branch information
hildjj authored Oct 10, 2024
2 parents cfad897 + 4aeecd0 commit cdc1e9d
Show file tree
Hide file tree
Showing 42 changed files with 2,668 additions and 2,187 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# EditorConfig is awesome: http://EditorConfig.org

# top-most EditorConfig file
root = true

[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
charset = utf-8
indent_style = space
indent_size = 2
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
eslint.config.mjs
node_modules/
test/
.editorconfig
32 changes: 19 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,30 @@

For js-only projects:

File: `.eslintrc.js` (or `.eslintrc.cjs` if you're type `"module"`):
File: `eslint.config.js` (or `eslint.config.mjs` if you're in a project with
type `"commonjs"`):

```js
"use strict";
import mocha from "@peggyjs/eslint-config/flat/mocha.js";
// Use commonjs if you're in an older project
import module from "@peggyjs/eslint-config/flat/module.js";
import ts from "@peggyjs/eslint-config/flat/ts.js";

module.exports = {
root: true,
extends: ["@peggyjs"],
};
export default [
...module,
...ts,
...mocha,
];
```

For projects that include typescript:
If you include the ts config, you'll need to add dependencies:

```js
"use strict";
```sh
npm install -D typescript typescript-eslint
```

If you include the mocha config, you'll need to add dependencies:

module.exports = {
root: true,
extends: ["@peggyjs", "@peggyjs/eslint-config/typescript"],
};
```sh
npm install -D eslint-plugin-mocha
```
26 changes: 26 additions & 0 deletions commonjs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import globals from "globals";
import ignores from "./ignores.js";
import json from "./json.js";
import markdown from "@eslint/markdown";
import override from "./override.js";
import { rules } from "./rules/js.js";
import stylistic from "@stylistic/eslint-plugin";

export default [
...ignores,
{
files: ["**/*.js", "**/*.cjs", "**/*.mjs", "**/*.ts"],
plugins: {
"@stylistic": stylistic,
},
languageOptions: {
globals: globals["shared-node-browser"],
ecmaVersion: 2018,
sourceType: "commonjs",
},
rules,
},
...override,
...json,
...markdown.configs.recommended,
];
19 changes: 7 additions & 12 deletions eslint.config.mjs → eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
import cjs from "./flat/cjs.js";
import js from "./flat/js.js";
import json from "@eslint/json";
import meta from "@cto.af/eslint-plugin-meta";
import mjs from "./flat/mjs.js";
import { plugin } from "typescript-eslint";
import module from "./module.js";
import stylistic from "@stylistic/eslint-plugin";
import { plugin as ts } from "typescript-eslint";

export default [
{
ignores: [
"node_modules/**",
"test/**",
],
ignores: ["test/**"],
},
js,
cjs,
mjs,
...module,
{
files: [
"rules/*.js",
Expand All @@ -23,7 +17,8 @@ export default [
meta: {
libs: {
"@stylistic": stylistic,
"@typescript-eslint": plugin,
"@typescript-eslint": ts,
json,
},
},
},
Expand Down
10 changes: 0 additions & 10 deletions flat/cjs.js

This file was deleted.

3 changes: 0 additions & 3 deletions flat/globals.js

This file was deleted.

17 changes: 0 additions & 17 deletions flat/js.js

This file was deleted.

10 changes: 0 additions & 10 deletions flat/mjs.js

This file was deleted.

23 changes: 0 additions & 23 deletions flat/mocha.js

This file was deleted.

17 changes: 0 additions & 17 deletions flat/module.js

This file was deleted.

21 changes: 0 additions & 21 deletions flat/ts.js

This file was deleted.

1 change: 1 addition & 0 deletions globals.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from "globals";
8 changes: 8 additions & 0 deletions ignores.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default [{
ignores: [
"node_modules/**",
"coverage/**",
"docs/**",
"**/*.min.js",
],
}];
14 changes: 0 additions & 14 deletions index.js

This file was deleted.

26 changes: 26 additions & 0 deletions json.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import json from "@eslint/json";
import { rules } from "./rules/json.js";

export default [{
files: ["**/*.json"],
plugins: { json },
language: "json/json",
rules,
},
{
files: [
"**/*.jsonc",
".vscode/*.json",
"**/tsconfig.json",
"**/tsconfig-base.json",
],
plugins: { json },
language: "json/jsonc",
rules,
},
{
files: ["**/*.json5"],
plugins: { json },
language: "json/json5",
rules,
}];
18 changes: 18 additions & 0 deletions mocha.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import globals from "globals";
import mocha from "eslint-plugin-mocha";

export default [{
files: [
"test/**/*.{spec,test}.{js,ts,cjs,mjs}",
],
languageOptions: {
globals: globals.mocha,
},
plugins: {
mocha,
},
rules: {
...mocha.configs.recommended.rules,
"mocha/no-mocha-arrows": "off",
},
}];
8 changes: 4 additions & 4 deletions flat/modern.js → modern.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"use strict";
import globals from "globals";

const globals = require("globals");

module.exports = {
export const modern = {
languageOptions: {
globals: globals.node,
ecmaVersion: 2022,
},
};

export default [modern];
26 changes: 26 additions & 0 deletions module.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import globals from "globals";
import ignores from "./ignores.js";
import json from "./json.js";
import markdown from "@eslint/markdown";
import override from "./override.js";
import { rules } from "./rules/js.js";
import stylistic from "@stylistic/eslint-plugin";

export default [
...ignores,
{
files: ["**/*.js", "**/*.cjs", "**/*.mjs", "**/*.ts"],
plugins: {
"@stylistic": stylistic,
},
languageOptions: {
globals: globals["shared-node-browser"],
ecmaVersion: 2020,
sourceType: "module",
},
rules,
},
...override,
...json,
...markdown.configs.recommended,
];
12 changes: 12 additions & 0 deletions override.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export default [{
files: ["**/*.mjs"],
languageOptions: {
sourceType: "module", // Force
},
},
{
files: ["**/*.cjs"],
languageOptions: {
sourceType: "commonjs", // Force
},
}];
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
"name": "@peggyjs/eslint-config",
"version": "4.0.4",
"description": "Lint rules for peggyjs projects",
"main": "index.js",
"main": "./module.js",
"type": "module",
"keywords": [
"peggy",
"eslint"
],
"scripts": {
"lint": "eslint .",
"test": "cd test/old && npm test && cd ../flat && npm test && cd ../flat-module && npm test",
"test": "(cd test/flat && npm test); (cd test/flat-module && npm test)",
"ci": "npm run lint && npm run test"
},
"author": "Joe Hildebrand <[email protected]>",
Expand All @@ -20,15 +21,16 @@
},
"devDependencies": {
"@cto.af/eslint-plugin-meta": "1.1.1",
"@peggyjs/sort-rules": "link:sort-rules",
"eslint": "^9.12.0",
"eslint-plugin-mocha": "10.5.0",
"typescript": "^5.6.2",
"typescript": "^5.6.3",
"typescript-eslint": "8.8.1"
},
"dependencies": {
"@eslint/json": "0.5.0",
"@eslint/markdown": "6.2.0",
"@stylistic/eslint-plugin": "2.9.0",
"globals": "15.10.0"
"globals": "15.11.0"
},
"packageManager": "[email protected]",
"engines": {
Expand Down
Loading

0 comments on commit cdc1e9d

Please sign in to comment.