create-nuxt-app icon indicating copy to clipboard operation
create-nuxt-app copied to clipboard

Feat: Generate typescript package types and tests

Open NickBolles opened this issue 4 years ago • 23 comments

Resubmitting as a pr to the base repo.

Original PR: https://github.com/ChangJoo-Park/create-nuxt-app/pull/1 But it didn't make it into the initial typescript support here: https://github.com/nuxt/create-nuxt-app/pull/449

List of changes

  1. Create nuxt.config.ts

  2. Update nuxt.config.ts with changes from nuxt.config.js

  3. Create a generate component template helper to switch between javascript and typescript

    • Another approach, if there are more typscript differences, could be a seperate file for js and typescript. but that seemed unnecessary right now
  4. Update the following components to generate typescript components using the generateComponent template helper

    • buefy
    • FrameVuerk
    • Iview
    • Vuesax
    • Vuetify
  5. Add typescript files to eslint and lint-staged configs

  6. fix tests for typescript runtime

  7. Add vue-shims.d.ts file

Issues from #448 - @davelsan

  1. [Fix] File XXX is not a module (Vetur error)
  • vue-shims.d.ts included above
  1. [Fix] Remove linting of unused vars
  • Add a fix by prefixing them with a _, which is the standard way to declare an unused var
  1. [Fix] Do not use the base ESLint indent rule
  • No fix for this in this PR. I'm going to leave this for another issue
  1. [Feat] Add TypeScript linting to package.json scripts
  • Included above
  1. [Feat] Add TypeScript support to Jest test files
  • added @types/jest as suggested by @davelsan
  1. [Feat] Port Nuxt config to TypeScript
  • Included above

NickBolles avatar Mar 20 '20 03:03 NickBolles

@NickBolles Ping ;)

mtltechtemp avatar Mar 27 '20 14:03 mtltechtemp

I'll try to look at this again today or tomorrow. Ping me again if you don't hear back by monday

NickBolles avatar Mar 27 '20 16:03 NickBolles

Issues from #448

  1. [Fix] File XXX is not a module (Vetur error)
  • vue-shims.d.ts already included in this PR
  1. [Fix] Remove linting of unused vars
  • Add a fix by prefixing them with a _, which is the standard way to declare an unused var
  1. [Fix] Do not use the base ESLint indent rule
  • No fix for this in this PR (yet). I don't quite understand the issue yet.
  1. [Feat] Add TypeScript linting to package.json scripts
  • Already included in this PR
  1. [Feat] Add TypeScript support to Jest test files
  • Added!
  1. [Feat] Port Nuxt config to TypeScript
  • Already included in this PR

todo: look through the rest of the modules to see if we can install types for them

NickBolles avatar Mar 28 '20 22:03 NickBolles

Thanks for the new additions. A couple of notes:

[Fix] File XXX is not a module (Vetur error)

vue-shims.d.ts already included in this PR

This should be enough. For the additional problem reported in vuejs/vetur#1187, there is a PR vuejs/vetur#1806 on the way.

[Fix] Do not use the base ESLint indent rule

  • No fix for this in this PR (yet). I don't quite understand the issue yet.

Originally reported in nuxt/eslint-config#76.

The issue is that, within *.vue components, indentation enforcement should be handled by eslint-plugin-vue through the vue/script-indent rule.

In the docs (see above link) it is recommended that the base indent rule is switched off within *.vue files, using an override.

{
  "rules": {
    "vue/script-indent": ["error", 2, { "baseIndent": 1 }]
  },
  "overrides": [
    {
      "files": ["*.vue"],
      "rules": {
        "indent": "off"
      }
    }
  ]
}

In *.ts files indentation should enforced by the @typescript-eslint/indent rule. In the docs it is recommended to switch off the base indent rule.

{
 "rules": {
   "indent": "off",
   "vue/script-indent": ["error", 2, { "baseIndent": 1 }]
 },
 "overrides": [
   {
     "files": ["*.ts"],
     "rules": {
       "@typescript-eslint/indent": ["error", 2]
     }
   }
 ]
}

My proposal is thus to switch off the base indent rule altogether, then use vue/script-ident and @typescript-eslint/indent for *.vue and *.ts files, respectively.

If there are reasons to support *.js files in the Nuxt-TypeScript project, then another override could handle that.

Edits: clarity, wording, typos

davelsan avatar Mar 29 '20 01:03 davelsan

This should be enough. For the additional problem reported in vuejs/vetur#1187, there is a PR vuejs/vetur#1806 on the way.

Nice! This should be good for now though.

[Fix] Do not use the base ESLint indent rule

  • No fix for this in this PR (yet). I don't quite understand the issue yet.

Your reasoning sounds good to me.

Could we do something like this though?

{
  "rules": {
    "vue/script-indent": ["error", 2, { "baseIndent": 1 }]
  },
  "overrides": [
    {
      "files": ["*.vue","*.ts"],
      "rules": {
        "indent": "off"
      }
    }
  ]
}

Would that result in the same functionality and also retain the "indent" rule for non ts or vue files?

NickBolles avatar Mar 29 '20 02:03 NickBolles

Would that result in the same functionality and also retain the "indent" rule for non ts or vue files?

Yes, that would work, but we are still not using the @typescript-eslint/indent rule for *.ts files, and it feels a bit weird to have a vue/script-indent base config with a separate *.vue override as well.

We could decide on a base config and turn on/off rules for specific files. For a Nuxt-TypeScript project, I'd suggest the following:

  • Base: set vue/script-indent and turn off indent
  • Override: set @typescript-eslint/indent rule for *.ts files
  • (Optional) Override: set indent for *.js files

Because the three rules conflict with each other, I think this is a cleaner approach.

{
  // .eslintrc.json
  "rules": {
    "indent":"off",
    "vue/script-indent": [ "error", 2, {
      "baseIndent": 1
    }]
  },
  "overrides": [
    {
      "files": [ "*.ts" ],
      "rules": {
        "@typescript-eslint/indent": ["error", 2]
      }
    },
    {
      "files": [ "*.js" ],
      "rules": {
        "indent": [ "error", 2 ]
      }
    }
  ]
}

If you prefer to have indent on by default (I don't recommend this), then vue/script-indent and @typescript-eslint/indent should be in separate overrides, plus indent should be switched off in each.


This is just a side note. For reasons unknown to me yet, even in *.js files the indent rule causes the following error in vscode (e.g. when typing const)

ESLint: Cannot read property 'loc' of undefined

Maybe this is a problem that should be reported in the microsoft/vscode-eslint repo. Though a lot more testing is needed before that.

Edits: clarity, typos, wording

davelsan avatar Mar 29 '20 13:03 davelsan

i'm not sure why there are so many commits. I had rebased onto master, not picking all of ChangJoo Parks commits. Diffs are only from my commits though.

@kevinmarrec could you review?

I'm also getting the following eslint errors. Probably because it's the first time ejs directives are being used in vue files...

C:\Users\nickb\Resilio Sync\Development\OpenSource Repos\nuxt ecosystem\create-nuxt-app\template\frameworks\buefy\components\Card.vue
  29:2  error  Parsing error: invalid-first-character-of-tag-name  vue/no-parsing-error

C:\Users\nickb\Resilio Sync\Development\OpenSource Repos\nuxt ecosystem\create-nuxt-app\template\frameworks\buefy\layouts\default.vue
  55:2  error  Parsing error: invalid-first-character-of-tag-name  vue/no-parsing-error

C:\Users\nickb\Resilio Sync\Development\OpenSource Repos\nuxt ecosystem\create-nuxt-app\template\frameworks\buefy\pages\index.vue
  43:2  error  Parsing error: invalid-first-character-of-tag-name  vue/no-parsing-error

C:\Users\nickb\Resilio Sync\Development\OpenSource Repos\nuxt ecosystem\create-nuxt-app\template\frameworks\framevuerk\components\FramevuerkLogo.vue
  29:2  error  Parsing error: invalid-first-character-of-tag-name  vue/no-parsing-error

C:\Users\nickb\Resilio Sync\Development\OpenSource Repos\nuxt ecosystem\create-nuxt-app\template\frameworks\framevuerk\pages\index.vue
  136:2  error  Parsing error: invalid-first-character-of-tag-name  vue/no-parsing-error

C:\Users\nickb\Resilio Sync\Development\OpenSource Repos\nuxt ecosystem\create-nuxt-app\template\frameworks\vuesax\pages\index.vue
  64:2  error  Parsing error: invalid-first-character-of-tag-name  vue/no-parsing-error

C:\Users\nickb\Resilio Sync\Development\OpenSource Repos\nuxt ecosystem\create-nuxt-app\template\frameworks\vuetify\layouts\default.vue
  91:2  error  Parsing error: invalid-first-character-of-tag-name  vue/no-parsing-error

C:\Users\nickb\Resilio Sync\Development\OpenSource Repos\nuxt ecosystem\create-nuxt-app\template\frameworks\vuetify\layouts\error.vue
  15:2  error  Parsing error: invalid-first-character-of-tag-name  vue/no-parsing-error

C:\Users\nickb\Resilio Sync\Development\OpenSource Repos\nuxt ecosystem\create-nuxt-app\template\frameworks\vuetify\pages\index.vue
  82:2  error  Parsing error: invalid-first-character-of-tag-name  vue/no-parsing-error

NickBolles avatar Mar 29 '20 19:03 NickBolles

@NickBolles Might be related to this issue https://github.com/vuejs/eslint-plugin-vue/issues/370

mtltechtemp avatar Apr 01 '20 11:04 mtltechtemp

@NickBolles Might be related to this issue https://github.com/vuejs/eslint-plugin-vue/issues/370

That's the eslint error. But it's not the same cause. The cause is that we are using ejs tags (<%_ _%> for example) in Vue files. That's unexpected in most cases.

Linting for anything with ejs syntax seems like a challenge.

That being said, I think disabling that rule for the repo would be the fix.

NickBolles avatar Apr 01 '20 12:04 NickBolles

Hey, I wanted to drop by and say I appreciate very much the work you're doing in this PR. Sometimes the way I write is not the most sensible, so I'm just trying to make sure I convey the right message.

So, yeah, looking forwards to this being merged!

That being said, I think disabling that rule for the repo would be the fix.

(Trying to stay on topic) I don't know the next thing about SAO or ejs, but my uneducated guess is that you're right. I say this after various messy and unsuccessful attempts to generate the <script/> tags without the linter yelling at me.

davelsan avatar Apr 05 '20 10:04 davelsan

Thanks for the pr, could you please fix the lint errors ?

done!

NickBolles avatar Apr 07 '20 04:04 NickBolles

@davelsan and @NickBolles You might find this useful https://github.com/jtmthf/eslint-plugin-ejs

Edit: I think if you add the file type there it might just work with no extra work.

Edit2: I made it work by patching the package with patch-package

The only error left is this one: error clear vue/comment-directive Not sure how we can fix it.

Here's the git diff so you can help me with the same base:

diff --git a/.eslintrc b/.eslintrc
index 37e661d96e42f4a9f06ae6c8666a615e3ea44d68..af3a0f04843de030406a9387d85265e285ddc0a0 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -1,12 +1,10 @@
 {
-  "extends": [
-    "@nuxtjs"
-  ],
+  "plugins": ["ejs"],
+  "extends": ["@nuxtjs"],
   "globals": {
     "use": true
   },
   "rules": {
-    "no-console": "off",
-    "vue/no-parsing-error": "off"
+    "no-console": "off"
   }
 }
diff --git a/package.json b/package.json
index eb13abb1c087ab4996b8241f01458e59a37068d2..e641f8f6b9c5a81ee079e99782a18e07a0c5aad3 100644
--- a/package.json
+++ b/package.json
@@ -24,15 +24,18 @@
     "chalk": "^2.4.2",
     "cross-spawn": "^7.0.1",
     "envinfo": "^7.5.0",
+    "eslint-plugin-ejs": "^0.0.2",
     "glob": "^7.1.6",
     "lodash": "^4.17.15",
+    "patch-package": "^6.2.2",
+    "postinstall-postinstall": "^2.1.0",
     "sao": "^1.7.0",
     "superb": "^4.0.0",
     "validate-npm-package-name": "^3.0.0"
   },
   "devDependencies": {
-    "@nuxtjs/eslint-config": "^2.0.2",
     "@ava/babel": "^1.0.1",
+    "@nuxtjs/eslint-config": "^2.0.2",
     "ava": "^3.5.0",
     "eslint": "^6.8.0",
     "standard-version": "^7.1.0"
diff --git a/yarn.lock b/yarn.lock
index 6132a8abd90577fe93216f09f44964ec2246297c..25846459c1730de6fb6997ee20e7f13594cfc845 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -366,6 +366,11 @@
     semver "^6.3.0"
     tsutils "^3.17.1"
 
+"@yarnpkg/lockfile@^1.1.0":
+  version "1.1.0"
+  resolved "https://registry.yarnpkg.com/@yarnpkg/lockfile/-/lockfile-1.1.0.tgz#e77a97fbd345b76d83245edcd17d393b1b41fb31"
+  integrity sha512-GpSwvyXOcOOlV70vbnzjj4fW5xW/FdUF6nQEt1ENy7m4ZCczi1+/buVUPAqmGfqznsORNFzUMjctTIp8a9tuCQ==
+
 JSONStream@^1.0.4:
   version "1.3.5"
   resolved "https://registry.yarnpkg.com/JSONStream/-/JSONStream-1.3.5.tgz#3208c1f08d3a4d99261ab64f92302bc15e111ca0"
@@ -1847,6 +1852,11 @@ eslint-module-utils@^2.4.1:
     debug "^2.6.9"
     pkg-dir "^2.0.0"
 
+eslint-plugin-ejs@^0.0.2:
+  version "0.0.2"
+  resolved "https://registry.yarnpkg.com/eslint-plugin-ejs/-/eslint-plugin-ejs-0.0.2.tgz#d17be92e8010262491d11efbeba7d626681eb18d"
+  integrity sha1-0XvpLoAQJiSR0R7766fWJmgesY0=
+
 eslint-plugin-es@^3.0.0:
   version "3.0.0"
   resolved "https://registry.yarnpkg.com/eslint-plugin-es/-/eslint-plugin-es-3.0.0.tgz#98cb1bc8ab0aa807977855e11ad9d1c9422d014b"
@@ -2292,6 +2302,14 @@ find-up@^3.0.0:
   dependencies:
     locate-path "^3.0.0"
 
+find-yarn-workspace-root@^1.2.1:
+  version "1.2.1"
+  resolved "https://registry.yarnpkg.com/find-yarn-workspace-root/-/find-yarn-workspace-root-1.2.1.tgz#40eb8e6e7c2502ddfaa2577c176f221422f860db"
+  integrity sha512-dVtfb0WuQG+8Ag2uWkbG79hOUzEsRrhBzgfn86g2sJPkzmcpGdghbNTfUKGTxymFrY/tLIodDzLoW9nOJ4FY8Q==
+  dependencies:
+    fs-extra "^4.0.3"
+    micromatch "^3.1.4"
+
 flat-cache@^2.0.1:
   version "2.0.1"
   resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-2.0.1.tgz#5d296d6f04bda44a4630a301413bdbc2ec085ec0"
@@ -2330,7 +2348,16 @@ fs-constants@^1.0.0:
   resolved "https://registry.yarnpkg.com/fs-constants/-/fs-constants-1.0.0.tgz#6be0de9be998ce16af8afc24497b9ee9b7ccd9ad"
   integrity sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==
 
-fs-extra@^7.0.0:
+fs-extra@^4.0.3:
+  version "4.0.3"
+  resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-4.0.3.tgz#0d852122e5bc5beb453fb028e9c0c9bf36340c94"
+  integrity sha512-q6rbdDd1o2mAnQreO7YADIxf/Whx4AHBiRf6d+/cVT8h44ss+lHgxf1FemcqDnQt9X3ct4McHr+JMGlYSsK7Cg==
+  dependencies:
+    graceful-fs "^4.1.2"
+    jsonfile "^4.0.0"
+    universalify "^0.1.0"
+
+fs-extra@^7.0.0, fs-extra@^7.0.1:
   version "7.0.1"
   resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-7.0.1.tgz#4f189c44aa123b895f722804f55ea23eadc348e9"
   integrity sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==
@@ -3302,6 +3329,13 @@ kind-of@^6.0.0, kind-of@^6.0.2:
   resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd"
   integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==
 
+klaw-sync@^6.0.0:
+  version "6.0.0"
+  resolved "https://registry.yarnpkg.com/klaw-sync/-/klaw-sync-6.0.0.tgz#1fd2cfd56ebb6250181114f0a581167099c2b28c"
+  integrity sha512-nIeuVSzdCCs6TDPTqI8w1Yre34sSq7AkZ4B3sfOBbI2CgVSB4Du4aLQijFU2+lhAFCwt9+42Hel6lQNIv6AntQ==
+  dependencies:
+    graceful-fs "^4.1.11"
+
 latest-version@^3.0.0:
   version "3.1.0"
   resolved "https://registry.yarnpkg.com/latest-version/-/latest-version-3.1.0.tgz#a205383fea322b33b5ae3b18abee0dc2f356ee15"
@@ -3649,7 +3683,7 @@ merge2@^1.2.3, merge2@^1.3.0:
   resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.3.0.tgz#5b366ee83b2f1582c48f87e47cf1a9352103ca81"
   integrity sha512-2j4DAdlBOkiSZIsaXk4mTE3sRS02yBHAtfy127xRV3bQUFqXkjHCHLW6Scv7DwNRbIWNHH8zpnz9zMaKXIdvYw==
 
-micromatch@^3.1.10:
+micromatch@^3.1.10, micromatch@^3.1.4:
   version "3.1.10"
   resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-3.1.10.tgz#70859bc95c9840952f359a068a3fc49f9ecfac23"
   integrity sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==
@@ -4127,6 +4161,24 @@ pascalcase@^0.1.1:
   resolved "https://registry.yarnpkg.com/pascalcase/-/pascalcase-0.1.1.tgz#b363e55e8006ca6fe21784d2db22bd15d7917f14"
   integrity sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=
 
+patch-package@^6.2.2:
+  version "6.2.2"
+  resolved "https://registry.yarnpkg.com/patch-package/-/patch-package-6.2.2.tgz#71d170d650c65c26556f0d0fbbb48d92b6cc5f39"
+  integrity sha512-YqScVYkVcClUY0v8fF0kWOjDYopzIM8e3bj/RU1DPeEF14+dCGm6UeOYm4jvCyxqIEQ5/eJzmbWfDWnUleFNMg==
+  dependencies:
+    "@yarnpkg/lockfile" "^1.1.0"
+    chalk "^2.4.2"
+    cross-spawn "^6.0.5"
+    find-yarn-workspace-root "^1.2.1"
+    fs-extra "^7.0.1"
+    is-ci "^2.0.0"
+    klaw-sync "^6.0.0"
+    minimist "^1.2.0"
+    rimraf "^2.6.3"
+    semver "^5.6.0"
+    slash "^2.0.0"
+    tmp "^0.0.33"
+
 path-dirname@^1.0.0:
   version "1.0.2"
   resolved "https://registry.yarnpkg.com/path-dirname/-/path-dirname-1.0.2.tgz#cc33d24d525e099a5388c0336c6e32b9160609e0"
@@ -4280,6 +4332,11 @@ posix-character-classes@^0.1.0:
   resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab"
   integrity sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=
 
+postinstall-postinstall@^2.1.0:
+  version "2.1.0"
+  resolved "https://registry.yarnpkg.com/postinstall-postinstall/-/postinstall-postinstall-2.1.0.tgz#4f7f77441ef539d1512c40bd04c71b06a4704ca3"
+  integrity sha512-7hQX6ZlZXIoRiWNrbMQaLzUUfH+sSx39u8EJ9HYuDc1kLo9IXKWjM5RSquZN1ad5GnH8CGFM78fsAAQi3OKEEQ==
+
 prelude-ls@~1.1.2:
   version "1.1.2"
   resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54"
@@ -4652,7 +4709,7 @@ [email protected]:
   dependencies:
     glob "^7.1.3"
 
-rimraf@^2.6.1:
+rimraf@^2.6.1, rimraf@^2.6.3:
   version "2.7.1"
   resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.7.1.tgz#35797f13a7fdadc566142c29d4f07ccad483e3ec"
   integrity sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==
@@ -4826,6 +4883,11 @@ signal-exit@^3.0.0, signal-exit@^3.0.2:
   resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d"
   integrity sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=
 
+slash@^2.0.0:
+  version "2.0.0"
+  resolved "https://registry.yarnpkg.com/slash/-/slash-2.0.0.tgz#de552851a1759df3a8f206535442f5ec4ddeab44"
+  integrity sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A==
+
 slash@^3.0.0:
   version "3.0.0"
   resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634"
diff --git a/patches/eslint-plugin-ejs+0.0.2.patch b/patches/eslint-plugin-ejs+0.0.2.patch
new file mode 100644
index 0000000000000000000000000000000000000000..8eb286ae4d28081a68404ca3a165f4f120d605f4
--- /dev/null
+++ b/patches/eslint-plugin-ejs+0.0.2.patch
@@ -0,0 +1,34 @@
+diff --git a/node_modules/eslint-plugin-ejs/lib/index.js b/node_modules/eslint-plugin-ejs/lib/index.js
+index 9870fd6..dd01dac 100644
+--- a/node_modules/eslint-plugin-ejs/lib/index.js
++++ b/node_modules/eslint-plugin-ejs/lib/index.js
+@@ -15,5 +15,6 @@ module.exports.processors = {
+
+     // add your processors here
+     ".js": ejs,
+-    ".jsx": ejs
++    ".jsx": ejs,
++    ".vue": ejs
+ };
+diff --git a/node_modules/eslint-plugin-ejs/lib/processors/ejs.js b/node_modules/eslint-plugin-ejs/lib/processors/ejs.js
+index 7586023..10bef5d 100644
+--- a/node_modules/eslint-plugin-ejs/lib/processors/ejs.js
++++ b/node_modules/eslint-plugin-ejs/lib/processors/ejs.js
+@@ -38,7 +38,7 @@ module.exports = {
+
+       // Create array of marker locations and for each marker to remove
+       var locations = [];
+-      ['<%= ', '<% ', ' %>'].forEach(function(token) {
++      ['<%= ', '<%- ', '<% ', ' %>'].forEach(function(token) {
+
+         // Set width to the marker length
+         var width = token.length
+@@ -70,7 +70,7 @@ module.exports = {
+       markers.push(locations);
+
+       // Create final line that removes all markers
+-      finalLines.push(line.split(/\<\%\= |\<\% | \%\>/).join(''));
++      finalLines.push(line.split(/\<\%\=|\<\%\- |\<\% | \%\>/).join(''));
+     }
+
+     // Join all lines back into one string that is sent in an array structure

mtltechtemp avatar Apr 07 '20 11:04 mtltechtemp

Is this important enough to patch the package? Seems like it might belong in a seperate pr?

NickBolles avatar Apr 07 '20 12:04 NickBolles

Is this important enough to patch the package? Seems like it might belong in a seperate pr?

That's just a 3 line patch to make the ejs lib do the work.

mtltechtemp avatar Apr 07 '20 13:04 mtltechtemp

@NickBolles Did you understand why we have error clear vue/comment-directive ?

Edit: Apparently "view/comment-directive" is used to disable eslint rules by making comments in the template. There is a bug with this when this directive is enabled. So I simply disabled it:

{
  "plugins": ["ejs"],
  "extends": ["@nuxtjs"],
  "globals": {
    "use": true
  },
  "rules": {
    "no-console": "off",
    "vue/comment-directive": "off"
  }
}

At least it's not as bad as having no linter at all.

@NickBolles What do you think about that?

mtltechtemp avatar Apr 07 '20 14:04 mtltechtemp

@NickBolles ping

mtltechtemp avatar Apr 09 '20 10:04 mtltechtemp

@mtltechtemp If you want to put a pull request together, either to follow up this one, or to merge into this branch I'd be fine with that. Although IMO a better fix would be to update eslint-plugin-ejs to register a pre-processor ID (https://eslint.org/docs/developer-guide/working-with-plugins#processors-in-plugins) and then allow users to configure it via the processor config, or overrides configs: https://eslint.org/docs/user-guide/configuring#specifying-processor

I hate doing one time patches of modules when with a little bit more work everyone can benefit.

NickBolles avatar Apr 09 '20 17:04 NickBolles

@NickBolles Could you take into account my requested changes ? then make your PR compatible with new monorepo (that's why you get lot of conflicts)

kevinmarrec avatar Apr 12 '20 15:04 kevinmarrec

@NickBolles Can you fix conflicts & tests ? Thanks :)

kevinmarrec avatar Apr 23 '20 09:04 kevinmarrec

@kevinmarrec updated. Could you take a look at this today? It's getting kinda difficult to keep this up to date with all of the other changes going on. :/

Edit: also looks like there are some timeout requests on the CI checks

NickBolles avatar Apr 23 '20 13:04 NickBolles

Great feature and nice work @NickBolles

kaangokdemir avatar Jun 06 '20 22:06 kaangokdemir

@NickBolles fo you mind resolving the conflicts one last time?

atinux avatar Jul 22 '20 12:07 atinux

Is there any plan to continue working on this, or will it be changed after Nuxt 3 anyway?

scscgit avatar Apr 10 '22 17:04 scscgit