New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Crash in projects without *.js files #50
Comments
Workaround: import-js/eslint-plugin-import#1645 (comment). |
Hi! I read the linked thread, tried to copy the workaround to my .eslintrc.js, but I still get this issue. Could you please help me run eslint on my React Typescript project? This is my .eslintrc.js. Is there any other relevant information I should provide? |
@brunoparga Hi! Try adding |
Thanks, but sorry, it doesn't work. I get the same error as before. |
@brunoparga Sorry to hear that. I guess then you should just turn the |
Wait, I am confused. Isn't that what I just tried? If not, how do I do it, please? Edit for clarity: what I just did was running eslint with the config from the gist I linked, plus The reason I am confused is that I think that the thing I did is how your suggestion would be implemented. What am I missing? |
@brunoparga You tried to enable the rule by using To turn the rule off completely, you should make these changes: module.exports = {
env: {
browser: true,
es6: true,
'jest/globals': true
},
extends: [
'eslint:recommended',
'hardcore',
'plugin:jest/recommended',
'plugin:jest/style',
'plugin:@typescript-eslint/recommended',
'plugin:react/recommended',
],
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
},
overrides: [
{
"files": ["*.js"],
"extends": ["hardcore/ts-for-js"],
"parserOptions": { "project": "./tsconfig.json" }
},
- {
- "files": ["*.js"],
- "rules": {
- "import/no-unused-modules": [
- "error",
- {
- "src": ["**/*.js"],
- "missingExports": false,
- "unusedExports": true
- }
- ]
- }
- },
- {
- "files": ["*.jsx"],
- "rules": {
- "import/no-unused-modules": [
- "error",
- {
- "src": ["**/*.jsx"],
- "missingExports": false,
- "unusedExports": true
- }
- ]
- }
- },
- {
- "files": ["*.ts"],
- "rules": {
- "import/no-unused-modules": [
- "error",
- {
- "src": ["**/*.ts"],
- "missingExports": false,
- "unusedExports": true
- }
- ]
- }
- },
- {
- "files": ["*.tsx"],
- "rules": {
- "import/no-unused-modules": [
- "error",
- {
- "src": ["**/*.tsx"],
- "missingExports": false,
- "unusedExports": true
- }
- ]
- }
- },
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 2018,
sourceType: 'module',
},
plugins: [
'inclusive-language',
'jest',
'woke',
'react',
'@typescript-eslint',
],
rules: {
'inclusive-language/use-inclusive-words': 'error',
'import/extensions': 'off',
'import/no-unresolved': 'off',
'import/prefer-default-export': 'off',
'no-use-before-define': 'off',
'react/jsx-filename-extension': [1, { extensions: ['.jsx', '.tsx'] }],
'react/prop-types': 'off',
'woke/all': 'error',
+ 'import/no-unused-modules': 'off'
},
settings: {
react: {
version: "detect"
}
}
}; |
@EvgenyOrekhov thank you for clarifying that, it was really helpful. I have now realized that I might have had a different problem all along (oops). I was trying to just run eslint against the whole
I checked and, unfortunately, this is probably related to So, I'm happy, since I can properly lint my project; but also dumbfounded that these two irrelevant files have to be excluded from the linter run so it can work properly. |
@brunoparga I created those two files in the root of the project, but I can't reproduce any failures, linting works fine:
If you could create a repo with a minimal reproducible case, that would be really helpful! |
Hi! First of all, I am sorry I did not provide a minimal reproducible case for the previous case. I wasn't sure what to include if I started from a fresh new project, or where to start removing stuff from a copy of the actual project. I now have the same issue on another project, with Angular this time. And one thing that I find really weird is that everything works fine if I use the default Prettier configuration, but not if I try to set either I thought this would be useful for you to know. |
@brunoparga I was able to successfully set up eslint-config-hardcore for a TypeScript project by wrapping the entire config in {
"overrides": [
{
"files": ["*.ts", "*.tsx"],
"extends": [
"hardcore",
"hardcore/fp",
"hardcore/ts-for-js",
"plugin:import/typescript"
],
"parserOptions": {
"project": "./tsconfig.json"
},
"env": {
"browser": true
}
},
{
"files": ["*.json"],
"extends": ["plugin:json/recommended"]
}
]
} I see no errors from Could you try that? |
@brunoparga This issue should be fixed now. I just released eslint-config-hardcore v20.0.0, which now has support for TypeScript and React. Please see the Usage section of the README. |
See import-js/eslint-plugin-import#1645.
TODO:
plugin:import/typescript
toextends
can solve this (see https://github.com/benmosher/eslint-plugin-import#typescript). Update: it doesn't solve the issue, it's not related to TypeScript.The text was updated successfully, but these errors were encountered: