stencil-community / stencil-eslint

ESLint rules specific to Stencil JS projects
MIT License
61 stars 34 forks source link

feat: support eslint ^9.0.0 #114

Open iterox opened 2 months ago

iterox commented 2 months ago

Prerequisites

Describe the Feature Request

As per April 5, 2024 eslint v9.0.0 has been released. As of July 26, 2024 eslint v9.8.0 has been released. This plugin does not support eslint v9.0.0. This prevents projects using @stencil-community/eslint-plugin from upgrading eslint to the latest version.

Among others see ESLint v9.0.0 released and Migrate to v9.x for more details on the changes (some of which impact plugins).

Describe the Use Case

I want to be able to keep up-to-date dependencies.

Describe Preferred Solution

No response

Describe Alternatives

No response

Related Code

No response

Additional Information

No response

Tallyb commented 2 months ago

here is a the patch package code for 0.8.0

diff --git a/node_modules/@stencil-community/eslint-plugin/dist/index.js b/node_modules/@stencil-community/eslint-plugin/dist/index.js
index eaca0cf..2176da1 100644
--- a/node_modules/@stencil-community/eslint-plugin/dist/index.js
+++ b/node_modules/@stencil-community/eslint-plugin/dist/index.js
@@ -189,7 +189,7 @@ const rule$o = {
     },
     create(context) {
         const stencil = stencilComponentContext();
-        const parserServices = context.parserServices;
+        const parserServices = context.parserServices || context.sourceCode.parserServices;
         const typeChecker = parserServices.program.getTypeChecker();
         return Object.assign(Object.assign({}, stencil.rules), { 'MethodDefinition > Decorator[expression.callee.name=Method]': (decoratorNode) => {
                 if (!stencil.isComponent()) {
@@ -322,7 +322,7 @@ const rule$l = {
     },
     create(context) {
         const stencil = stencilComponentContext();
-        const parserServices = context.parserServices;
+        const parserServices = context.parserServices || context.sourceCode.parserServices;
         return Object.assign(Object.assign({}, stencil.rules), { 'ClassDeclaration': (node) => {
                 const component = getDecorator(node, 'Component');
                 const options = context.options[0];
@@ -455,7 +455,7 @@ const rule$j = {
     },
     create(context) {
         const stencil = stencilComponentContext();
-        const parserServices = context.parserServices;
+        const parserServices = context.parserServices || context.sourceCode.parserServices;
         const opts = context.options[0] || {};
         const options = Object.assign(Object.assign({}, DEFAULTS$1), opts);
         function checkStyle(decorator) {
@@ -576,7 +576,7 @@ const rule$g = {
     },
     create(context) {
         const stencil = stencilComponentContext();
-        const parserServices = context.parserServices;
+        const parserServices = context.parserServices || context.sourceCode.parserServices;
         return Object.assign(Object.assign({}, stencil.rules), { 'MethodDefinition[kind=method]': (node) => {
                 if (stencil.isComponent() && getDecorator(node, 'Method')) {
                     const originalNode = parserServices.esTreeNodeToTSNodeMap.get(node);
@@ -604,7 +604,7 @@ const rule$f = {
     },
     create(context) {
         const stencil = stencilComponentContext();
-        const parserServices = context.parserServices;
+        const parserServices = context.parserServices || context.sourceCode.parserServices;
         function getVars(node) {
             if (!stencil.isComponent()) {
                 return;
@@ -696,7 +696,7 @@ const rule$e = {
     },
     create(context) {
         const stencil = stencilComponentContext();
-        const parserServices = context.parserServices;
+        const parserServices = context.parserServices || context.sourceCode.parserServices;
         return Object.assign(Object.assign({}, stencil.rules), { "MethodDefinition[kind=method]": (node) => {
                 if (!stencil.isComponent()) {
                     return;
@@ -740,7 +740,7 @@ const rule$d = {
     },
     create(context) {
         const stencil = stencilComponentContext();
-        const parserServices = context.parserServices;
+        const parserServices = context.parserServices || context.sourceCode.parserServices;
         return Object.assign(Object.assign({}, stencil.rules), { PropertyDefinition: (node) => {
                 if (!stencil.isComponent()) {
                     return;
@@ -830,7 +830,7 @@ const rule$b = {
     },
     create(context) {
         const stencil = stencilComponentContext();
-        const parserServices = context.parserServices;
+        const parserServices = context.parserServices || context.sourceCode.parserServices;
         return Object.assign(Object.assign({}, stencil.rules), { 'PropertyDefinition': (node) => {
                 if (stencil.isComponent() && getDecorator(node, 'Prop')) {
                     const originalNode = parserServices.esTreeNodeToTSNodeMap.get(node);
@@ -858,7 +858,7 @@ const rule$a = {
     },
     create(context) {
         const stencil = stencilComponentContext();
-        const parserServices = context.parserServices;
+        const parserServices = context.parserServices || context.sourceCode.parserServices;
         return Object.assign(Object.assign({}, stencil.rules), { 'PropertyDefinition': (node) => {
                 var _a;
                 const propDecorator = getDecorator(node, 'Prop');
@@ -903,7 +903,7 @@ const rule$9 = {
         // Public
         //----------------------------------------------------------------------
         const stencil = stencilComponentContext();
-        const parserServices = context.parserServices;
+        const parserServices = context.parserServices || context.sourceCode.parserServices;
         const typeChecker = parserServices.program.getTypeChecker();
         return Object.assign(Object.assign({}, stencil.rules), { 'MethodDefinition[kind=method][key.name=render] ReturnStatement': (node) => {
                 if (!stencil.isComponent()) {
@@ -935,7 +935,7 @@ const rule$8 = {
     },
     create(context) {
         const stencil = stencilComponentContext();
-        const parserServices = context.parserServices;
+        const parserServices = context.parserServices || context.sourceCode.parserServices;
         function getJSDoc(node) {
             if (!stencil.isComponent()) {
                 return;
@@ -1119,7 +1119,7 @@ const rule$5 = {
         type: 'problem'
     },
     create(context) {
-        const parserServices = context.parserServices;
+        const parserServices = context.parserServices || context.sourceCode.parserServices;
         const typeChecker = parserServices.program.getTypeChecker();
         return {
             'ClassDeclaration': (node) => {
@@ -1312,7 +1312,7 @@ const rule$2 = {
         type: 'problem'
     },
     create(context) {
-        const parserServices = context.parserServices;
+        const parserServices = context.parserServices || context.sourceCode.parserServices;
         const program = parserServices.program;
         const rawOptions = context.options[0] || ['allow-null-union', 'allow-undefined-union', 'allow-boolean-or-undefined'];
         const options = parseOptions(rawOptions, true);
iterox commented 2 months ago

Thanks @Tallyb for the patch.

Please could you remove line 11?

+        console.dir(parserServices)
Tallyb commented 2 months ago

udpated

iterox commented 2 months ago

Thank you very much @Tallyb, now we have a working flat config eslint v9, @typescript-eslint v8 with @stencil-community/eslint-plugin v0.8.0 incl. the patch you provided 👏