Comments (12)
Interesting, thank you for that analysis!! I was using the Webstorm/VsCode linting warnings when I made those comments above, and forgot to actually try out invoking the Nx linter above 🤦
If you explicitly set the files you want linted in the builder, it should start picking them up:
"lint": {
"builder": "@nrwl/linter:lint",
"options": {
"linter": "eslint",
"files": ["**/*.{ts,vue}"],
"exclude": ["**/node_modules/**", "!apps/my-app/**/*"]
}
},
I tried using a few rules which require type information and it continues to work fine and pick them up. The downside I guess is that it includes all files in the glob, rather than only the ones you use in your tsconfig
dependency graph.
I did notice that the @angular-eslint/builder
(after which our builder is based off) has removed any references to createProgram
etc., and I think is using the eslint
config overrides to specify tsconfigs
:
We do plan on updating our Nx linter to reflect some of the awesome updates made by James Henry above - but in the meantime, I don't know if you want to try using the above builder directly? (if the files
option doesn't work for you)
from nx-plus.
It seems we have a couple of options to think through. @rarmatei thanks for your help on this! 😄
Cool!! Excited to see this plugin grow! Let me know if you need any more help! 👍
from nx-plus.
10.3.0 has been released with a new eslint builder. We might be able to take advantage of this!
from nx-plus.
@rarmatei I see you did quite a bit of work on @nrwl/linter
. I don't think this issue belongs in Nx because it doesn't support Vue internally, but I was hoping you could provide some direction.
from nx-plus.
@BuckyMaler sorry for the late response - I'm wondering if it's missing a plugin?
if you create an Nx workspace with a React app, you'll notice "plugins": ["@typescript-eslint", "@nrwl/nx"],
in the root .eslintrc
- which allows it to lint .ts
files.
I've not worked with Vue before, but could it be that you need something like https://eslint.vuejs.org/ in there?
EDIT: sorry, I rushed to an answer above, I managed to replicate the issue, I'll more into it this week 👍
from nx-plus.
Can you try adding this to your local .eslintrc.js
file:
"parser": "vue-eslint-parser",
"parserOptions": {
"parser": "@typescript-eslint/parser",
"project": null
},
// ........
That should make it lint the .vue
files.
We use the project
option to give "type information context" to the @typescript-eslint/parser
- but for some reason that is not working with the vue-eslint-parser
parser. They do tell you in their docs that you can use a custom parser, but it might be a question for them as to why you can't pass in the project
option as well.
The above should work fine. The only cases where it won't work, is if somebody needs to use a rule that needs type info like the ones in:
"plugin:@typescript-eslint/recommended-requiring-type-checking"
from nx-plus.
@rarmatei thanks for responding. Unfortunately, adding that snippet to the local .eslintrc.js
didn't work.
I think the linter builder is excluding .vue
files. As you can see in the screenshot below I logged the files to lint and no .vue
files were logged.
I also added the following npm script with no ESLint config changes and App.vue
was linted.
"eslint": "eslint --config apps/my-app/.eslintrc.js --ext .js,.ts,.vue apps/my-app/src"
I think the issue maybe the arguments passed to ts.parseJsonConfigFileContent
or ts.createProgram
found here.
from nx-plus.
Oh, I was using Nx 10 when trying the example above!
Can you show me what options you're sending to the linter, please? Or if you have an example repo that would help too, please.
There's been a recent change to what pattern we use for the "exclude" array.
from nx-plus.
I've narrowed in on the issue. parseJsonConfigFileContent
excludes .vue
files by default. However, it accepts an extraFileExtensions
argument. Replacing that line with the following gets us half way there:
const parsed = ts.parseJsonConfigFileContent(
config.config,
parseConfigHost,
path.resolve(projectDirectory),
{ noEmit: true },
undefined,
undefined,
[{ extension: '.vue', isMixedContent: true, scriptKind: 7 }]
);
createProgram
also exlcudes .vue
file by default. Unfortunately, it doesn't accept an extraFileExtensions
argument. However, if you set allowNonTsExtensions
to true
before calling it, then .vue
files will be included. To do that, add the following right after the line above:
parsed.options.allowNonTsExtensions = true;
With those two changes .vue
files are linted. I can see the first change being a PR into Nx, but not the second. allowNonTsExtensions
is a private/internal TS option. Here is where createProgram
filters out .vue
files if allowNonTsExtensions
is not true
.
Because of how createProgram
works, I think we'll need to write our own linter builder, but here is a repo to easily reproduce the issue if you want to take a closer look. After cloning the repo and installing deps, run nx lint my-app
. There should be lint errors in main.ts
and App.vue
, but only the lint errors in main.ts
are reported.
from nx-plus.
It seems we have a couple of options to think through. @rarmatei thanks for your help on this! 😄
from nx-plus.
I'll look into this soon. 🤞
from nx-plus.
Updating to Nx v10.3.0 fixes this issue. I'll get to work on the update.
from nx-plus.
Related Issues (20)
- Add NX 14.3.X Support HOT 3
- high severity vulnerabilities
- How do you get source maps to work?
- Composing generators requires '@angular-devkit/schematics' HOT 3
- Cannot start freshly generated vue app due to "Rule can only have one resource source" error HOT 14
- Error "Cannot read properties of null (reading 'npmScope')" when generating docusaurus app
- When building with nx-plus/vue, lots of command windows pop up. Can this be suppressed?
- Build options "generatePackageJson" in project.json for Create package.json
- Support for Paths resolve for SASS files inside .vue component HOT 1
- vue3-jest Issue : nx test myAppName HOT 1
- Resolve dependency conflict with @nrwl/workspace@15 HOT 3
- @nx-plus/nuxt:static dont behavior like nuxt generate ignoring dir folder on nuxt.config HOT 2
- @nx-plus/nuxt - possibility to add port on project.json HOT 1
- [vite] `appRootPath` is undefined in `vite.config.ts`
- seeing 'formats' is not found in schema HOT 1
- Support nuxt.config.ts
- TS18002: The 'files' list in config file 'tsconfig.json' is empty.
- Nx moving JS graph building to new location HOT 1
- Is @nx-plus/docusaurus 15.0.0-rc.0 stable? HOT 1
- @nx-plus/docusaurus with nx@16 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nx-plus.