From f5d740e78321c8c652226b5338552a9991e2589a Mon Sep 17 00:00:00 2001 From: Joe Hildebrand Date: Fri, 1 Mar 2024 10:53:55 -0700 Subject: [PATCH 1/4] Un-break configs. Fixes #35 --- src/utils.ts | 4 ++-- test/index.test.js | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index 535e319..c89b876 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -25,8 +25,8 @@ export function dirMap(...dirs: string[]): { [id: string]: object } { .map(fileName => fileName.replace(/\.js$/, "")) .map(entryName => [ entryName, - // eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires - require(path.join(dirName, entryName)).default, + // eslint-disable-next-line @typescript-eslint/no-require-imports + require(path.join(dirName, entryName)), ]) ); } diff --git a/test/index.test.js b/test/index.test.js index 82451f4..7883005 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -7,5 +7,10 @@ describe("plugin", () => { it("loads", () => { assert(index); assert.equal(typeof index, "object"); + assert(index.configs); + assert(index.configs.all); + assert(index.configs.recommended); + assert(index.rules); + assert(index.processors); }); }); From ea2b7d3558bb21f4d542d995eee49d9138aa37d4 Mon Sep 17 00:00:00 2001 From: Joe Hildebrand Date: Fri, 1 Mar 2024 10:56:43 -0700 Subject: [PATCH 2/4] Make README read a little better --- README.md | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 9a5e247..9cefa83 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,6 @@ Install with: npm install --save-dev @peggyjs/eslint-plugin @peggyjs/eslint-parser eslint ``` -(update this when we publish!) - Add to your `.eslintrc.js` file: ```js @@ -21,26 +19,6 @@ module.exports = { }; ``` -Or, if you are using ESLint Flat configs, add this to your `eslint.config.js` -file: - -```js -// ESM -import peggylint from "@peggyjs/eslint-plugin/lib/flat/recommended.js" -export default [ - peggyLint, -]; -``` - -Or: - -```js -// CommonJS -module.exports = [ - ...require("@peggyjs/eslint-plugin/lib/flat/recommended.js"), -]; -``` - You can also use "plugin:@peggyjs/all" or to get ALL of the rules. If you'd like more control: @@ -72,6 +50,26 @@ module.exports = { }; ``` +Or, if you are using ESLint Flat configs, add this to your `eslint.config.js` +file: + +```js +// ESM +import peggylint from "@peggyjs/eslint-plugin/lib/flat/recommended.js" +export default [ + peggyLint, +]; +``` + +Or: + +```js +// CommonJS +module.exports = [ + ...require("@peggyjs/eslint-plugin/lib/flat/recommended.js"), +]; +``` + ## VSCode If you are using VSCode, you might be interested in these for your `.vscode/settings.json` file: From 8fc2cf52935dd63192f1298c3eb330ea9231509d Mon Sep 17 00:00:00 2001 From: Joe Hildebrand Date: Fri, 1 Mar 2024 11:05:05 -0700 Subject: [PATCH 3/4] fix exports on all rules --- src/rules/camelCase.ts | 2 +- src/rules/equal-next-line.ts | 2 +- src/rules/no-empty-code-blocks.ts | 2 +- src/rules/no-empty-initializers.ts | 2 +- src/rules/no-unused-labels.ts | 2 +- src/rules/no-unused-rules.ts | 2 +- src/rules/quotes.ts | 2 +- src/rules/rule-order.ts | 2 +- src/rules/semantic-predicate-must-return.ts | 2 +- src/rules/semi.ts | 2 +- src/rules/separate-choices.ts | 2 +- src/rules/space-ops.ts | 2 +- src/rules/valid-imports.ts | 2 +- test/rules/camelCase.test.js | 2 +- test/rules/equal-next-line.test.js | 2 +- test/rules/no-empty-code-blocks.test.js | 2 +- test/rules/no-empty-initializers.test.js | 2 +- test/rules/no-unused-labels.test.js | 2 +- test/rules/no-unused-rules.test.js | 2 +- test/rules/quotes.test.js | 2 +- test/rules/rule-order.test.js | 2 +- test/rules/semantic-predicate-must-return.test.js | 2 +- test/rules/semi.test.js | 2 +- test/rules/separate-choices.test.js | 2 +- test/rules/space-ops.test.js | 2 +- test/rules/valid-imports.test.js | 2 +- 26 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/rules/camelCase.ts b/src/rules/camelCase.ts index 6997d5f..e7ade7d 100644 --- a/src/rules/camelCase.ts +++ b/src/rules/camelCase.ts @@ -119,4 +119,4 @@ const rule: Rule.RuleModule = { }, }; -export default rule; +export = rule; diff --git a/src/rules/equal-next-line.ts b/src/rules/equal-next-line.ts index 8a221ee..5687ebc 100644 --- a/src/rules/equal-next-line.ts +++ b/src/rules/equal-next-line.ts @@ -148,4 +148,4 @@ const rule: Rule.RuleModule = { }, }; -export default rule; +export = rule; diff --git a/src/rules/no-empty-code-blocks.ts b/src/rules/no-empty-code-blocks.ts index fe8ae6d..b14a60f 100644 --- a/src/rules/no-empty-code-blocks.ts +++ b/src/rules/no-empty-code-blocks.ts @@ -70,4 +70,4 @@ const rule: Rule.RuleModule = { }, }; -export default rule; +export = rule; diff --git a/src/rules/no-empty-initializers.ts b/src/rules/no-empty-initializers.ts index b16f41c..18ddb8c 100644 --- a/src/rules/no-empty-initializers.ts +++ b/src/rules/no-empty-initializers.ts @@ -44,4 +44,4 @@ const rule: Rule.RuleModule = { }, }; -export default rule; +export = rule; diff --git a/src/rules/no-unused-labels.ts b/src/rules/no-unused-labels.ts index 5f40a16..813f5a8 100644 --- a/src/rules/no-unused-labels.ts +++ b/src/rules/no-unused-labels.ts @@ -83,4 +83,4 @@ const rule: Rule.RuleModule = { }, }; -export default rule; +export = rule; diff --git a/src/rules/no-unused-rules.ts b/src/rules/no-unused-rules.ts index 41cffca..67f9601 100644 --- a/src/rules/no-unused-rules.ts +++ b/src/rules/no-unused-rules.ts @@ -95,4 +95,4 @@ const rule: Rule.RuleModule = { }, }; -export default rule; +export = rule; diff --git a/src/rules/quotes.ts b/src/rules/quotes.ts index 5ac9754..cf615c6 100644 --- a/src/rules/quotes.ts +++ b/src/rules/quotes.ts @@ -118,4 +118,4 @@ const rule: Rule.RuleModule = { }, }; -export default rule; +export = rule; diff --git a/src/rules/rule-order.ts b/src/rules/rule-order.ts index 8902144..7f002e4 100644 --- a/src/rules/rule-order.ts +++ b/src/rules/rule-order.ts @@ -72,4 +72,4 @@ const rule: Rule.RuleModule = { }, }; -export default rule; +export = rule; diff --git a/src/rules/semantic-predicate-must-return.ts b/src/rules/semantic-predicate-must-return.ts index 0218260..bfd9d8c 100644 --- a/src/rules/semantic-predicate-must-return.ts +++ b/src/rules/semantic-predicate-must-return.ts @@ -41,4 +41,4 @@ const rule: Rule.RuleModule = { }, }; -export default rule; +export = rule; diff --git a/src/rules/semi.ts b/src/rules/semi.ts index 61fd62a..a71184d 100644 --- a/src/rules/semi.ts +++ b/src/rules/semi.ts @@ -100,4 +100,4 @@ const rule: Rule.RuleModule = { }, }; -export default rule; +export = rule; diff --git a/src/rules/separate-choices.ts b/src/rules/separate-choices.ts index b833e4f..71eebbc 100644 --- a/src/rules/separate-choices.ts +++ b/src/rules/separate-choices.ts @@ -55,4 +55,4 @@ const rule: Rule.RuleModule = { }, }; -export default rule; +export = rule; diff --git a/src/rules/space-ops.ts b/src/rules/space-ops.ts index 944e878..a46491d 100644 --- a/src/rules/space-ops.ts +++ b/src/rules/space-ops.ts @@ -239,4 +239,4 @@ const rule: Rule.RuleModule = { }, }; -export default rule; +export = rule; diff --git a/src/rules/valid-imports.ts b/src/rules/valid-imports.ts index 6c2129e..cee73c5 100644 --- a/src/rules/valid-imports.ts +++ b/src/rules/valid-imports.ts @@ -199,4 +199,4 @@ const rule: Rule.RuleModule = { }, }; -export default rule; +export = rule; diff --git a/test/rules/camelCase.test.js b/test/rules/camelCase.test.js index 564a988..aeaf5f5 100644 --- a/test/rules/camelCase.test.js +++ b/test/rules/camelCase.test.js @@ -1,6 +1,6 @@ "use strict"; -const rule = require("../../lib/rules/camelCase").default; +const rule = require("../../lib/rules/camelCase"); const RuleTester = require("eslint").RuleTester; const ruleTester = new RuleTester({ diff --git a/test/rules/equal-next-line.test.js b/test/rules/equal-next-line.test.js index edbe155..c3a3269 100644 --- a/test/rules/equal-next-line.test.js +++ b/test/rules/equal-next-line.test.js @@ -1,6 +1,6 @@ "use strict"; -const rule = require("../../lib/rules/equal-next-line").default; +const rule = require("../../lib/rules/equal-next-line"); const RuleTester = require("eslint").RuleTester; const ruleTester = new RuleTester({ diff --git a/test/rules/no-empty-code-blocks.test.js b/test/rules/no-empty-code-blocks.test.js index 2bfe5dc..09cec29 100644 --- a/test/rules/no-empty-code-blocks.test.js +++ b/test/rules/no-empty-code-blocks.test.js @@ -1,6 +1,6 @@ "use strict"; -const rule = require("../../lib/rules/no-empty-code-blocks").default; +const rule = require("../../lib/rules/no-empty-code-blocks"); const RuleTester = require("eslint").RuleTester; const ruleTester = new RuleTester({ diff --git a/test/rules/no-empty-initializers.test.js b/test/rules/no-empty-initializers.test.js index 2d4f34d..a9de357 100644 --- a/test/rules/no-empty-initializers.test.js +++ b/test/rules/no-empty-initializers.test.js @@ -1,6 +1,6 @@ "use strict"; -const rule = require("../../lib/rules/no-empty-initializers").default; +const rule = require("../../lib/rules/no-empty-initializers"); const RuleTester = require("eslint").RuleTester; const ruleTester = new RuleTester({ diff --git a/test/rules/no-unused-labels.test.js b/test/rules/no-unused-labels.test.js index e3dd636..6d20f5d 100644 --- a/test/rules/no-unused-labels.test.js +++ b/test/rules/no-unused-labels.test.js @@ -1,6 +1,6 @@ "use strict"; -const rule = require("../../lib/rules/no-unused-labels").default; +const rule = require("../../lib/rules/no-unused-labels"); const RuleTester = require("eslint").RuleTester; const ruleTester = new RuleTester({ diff --git a/test/rules/no-unused-rules.test.js b/test/rules/no-unused-rules.test.js index d36e1b6..2fd9035 100644 --- a/test/rules/no-unused-rules.test.js +++ b/test/rules/no-unused-rules.test.js @@ -1,6 +1,6 @@ "use strict"; -const rule = require("../../lib/rules/no-unused-rules").default; +const rule = require("../../lib/rules/no-unused-rules"); const RuleTester = require("eslint").RuleTester; const ruleTester = new RuleTester({ diff --git a/test/rules/quotes.test.js b/test/rules/quotes.test.js index cdec14c..35127ce 100644 --- a/test/rules/quotes.test.js +++ b/test/rules/quotes.test.js @@ -1,6 +1,6 @@ "use strict"; -const rule = require("../../lib/rules/quotes").default; +const rule = require("../../lib/rules/quotes"); const RuleTester = require("eslint").RuleTester; const ruleTester = new RuleTester({ diff --git a/test/rules/rule-order.test.js b/test/rules/rule-order.test.js index 4d68f52..014f0a3 100644 --- a/test/rules/rule-order.test.js +++ b/test/rules/rule-order.test.js @@ -1,6 +1,6 @@ "use strict"; -const rule = require("../../lib/rules/rule-order").default; +const rule = require("../../lib/rules/rule-order"); const RuleTester = require("eslint").RuleTester; const ruleTester = new RuleTester({ diff --git a/test/rules/semantic-predicate-must-return.test.js b/test/rules/semantic-predicate-must-return.test.js index 7e43752..2079ab5 100644 --- a/test/rules/semantic-predicate-must-return.test.js +++ b/test/rules/semantic-predicate-must-return.test.js @@ -1,6 +1,6 @@ "use strict"; -const rule = require("../../lib/rules/semantic-predicate-must-return").default; +const rule = require("../../lib/rules/semantic-predicate-must-return"); const RuleTester = require("eslint").RuleTester; const ruleTester = new RuleTester({ diff --git a/test/rules/semi.test.js b/test/rules/semi.test.js index fae0694..5c057aa 100644 --- a/test/rules/semi.test.js +++ b/test/rules/semi.test.js @@ -1,6 +1,6 @@ "use strict"; -const rule = require("../../lib/rules/semi").default; +const rule = require("../../lib/rules/semi"); const RuleTester = require("eslint").RuleTester; const ruleTester = new RuleTester({ diff --git a/test/rules/separate-choices.test.js b/test/rules/separate-choices.test.js index 4561bb3..947af81 100644 --- a/test/rules/separate-choices.test.js +++ b/test/rules/separate-choices.test.js @@ -1,6 +1,6 @@ "use strict"; -const rule = require("../../lib/rules/separate-choices").default; +const rule = require("../../lib/rules/separate-choices"); const RuleTester = require("eslint").RuleTester; const ruleTester = new RuleTester({ diff --git a/test/rules/space-ops.test.js b/test/rules/space-ops.test.js index 27e63e2..3965bcd 100644 --- a/test/rules/space-ops.test.js +++ b/test/rules/space-ops.test.js @@ -1,6 +1,6 @@ "use strict"; -const rule = require("../../lib/rules/space-ops").default; +const rule = require("../../lib/rules/space-ops"); const RuleTester = require("eslint").RuleTester; const ruleTester = new RuleTester({ diff --git a/test/rules/valid-imports.test.js b/test/rules/valid-imports.test.js index 617eb48..3d8f2be 100644 --- a/test/rules/valid-imports.test.js +++ b/test/rules/valid-imports.test.js @@ -1,6 +1,6 @@ "use strict"; -const rule = require("../../lib/rules/valid-imports").default; +const rule = require("../../lib/rules/valid-imports"); const RuleTester = require("eslint").RuleTester; const filename = __filename; From 496a5c60a400b96b3734fab1a3ab5d1cbe364143 Mon Sep 17 00:00:00 2001 From: Joe Hildebrand Date: Fri, 1 Mar 2024 11:07:37 -0700 Subject: [PATCH 4/4] Update dependencies --- package.json | 2 +- pnpm-lock.yaml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index cfe8228..114a160 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "@types/debug": "4.1.12", "@types/eslint": "8.56.5", "@types/estree": "1.0.5", - "@types/node": "20.11.22", + "@types/node": "20.11.24", "@types/requireindex": "1.2.4", "@typescript-eslint/eslint-plugin": "7.1.0", "@typescript-eslint/parser": "7.1.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c7f751c..ff28c79 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -26,8 +26,8 @@ devDependencies: specifier: 1.0.5 version: 1.0.5 '@types/node': - specifier: 20.11.22 - version: 20.11.22 + specifier: 20.11.24 + version: 20.11.24 '@types/requireindex': specifier: 1.2.4 version: 1.2.4 @@ -330,8 +330,8 @@ packages: resolution: {integrity: sha512-nG96G3Wp6acyAgJqGasjODb+acrI7KltPiRxzHPXnP3NgI28bpQDRv53olbqGXbfcgF5aiiHmO3xpwEpS5Ld9g==} dev: true - /@types/node@20.11.22: - resolution: {integrity: sha512-/G+IxWxma6V3E+pqK1tSl2Fo1kl41pK1yeCyDsgkF9WlVAme4j5ISYM2zR11bgLFJGLN5sVK40T4RJNuiZbEjA==} + /@types/node@20.11.24: + resolution: {integrity: sha512-Kza43ewS3xoLgCEpQrsT+xRo/EJej1y0kVYGiLFE1NEODXGzTfwiC6tXTLMQskn1X4/Rjlh0MQUvx9W+L9long==} dependencies: undici-types: 5.26.5 dev: true