Skip to content
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

Can't parse filenames like [id].tsx #11980

Closed
cajoy opened this issue Jul 12, 2019 · 7 comments
Closed

Can't parse filenames like [id].tsx #11980

cajoy opened this issue Jul 12, 2019 · 7 comments
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly triage An ESLint team member will look at this issue soon

Comments

@cajoy
Copy link

cajoy commented Jul 12, 2019

  • ESLint Version: 6.0.1

What parser (default, Babel-ESLint, etc.) are you using?

Typescript, Next.js 9

Please show your full configuration:

Configuration
module.exports = {
  root: true,
  parser: '@typescript-eslint/parser',
  plugins: [
    '@typescript-eslint',
    'react',
    'cypress',
    'security'
  ],
  extends: [
    'eslint:recommended',
    'plugin:import/recommended',
    'plugin:react/recommended',
    'plugin:@typescript-eslint/recommended',
    'plugin:security/recommended',
    'airbnb-base'
  ],
  settings: {
    'import/resolver': {
      alias: {
        map: [
          ['@cbdc/shared', './shared'],
          ['@cbdc/ui', './ui'],
          ['@cbdc/website', './website']
        ],
        extensions: ['.js', '.jsx', '.ts', '.tsx', '.mjs', '.json']
      }
    },
    react: {
      version: 'detect'
    }
  },
  env: {
    browser: true,
    es6: true,
    node: true,
    'cypress/globals': true
  },
  globals: {
    Atomics: 'readonly',
    SharedArrayBuffer: 'readonly'
  },
  parserOptions: {
    ecmaFeatures: {
      jsx: true
    },
    ecmaVersion: 2018,
    project: 'tsconfig.json',
    tsconfigRootDir: __dirname,
    sourceType: 'module'
  },
  rules: {
    'arrow-parens': ['off'], // async functions need parameters wrapped in (), which this fails to detect right with typescript
    'class-methods-use-this': ['off', {exceptMethods: ['render']}],
    'comma-dangle': ['error', 'never'],
    'import/extensions': ['error', 'ignorePackages', {
      js: 'never', ts: 'never', mjs: 'never', jsx: 'never', tsx: 'never'
    }],
    'import/no-default-export': ['error'],
    'import/no-extraneous-dependencies': ['error', {devDependencies: ['**/__tests__/**', 'jest.setup.ts'], optionalDependencies: false, peerDependencies: false}],
    'import/no-unresolved': [2, {ignore: ['^\\@cbdc\\/']}],
    'import/prefer-default-export': 'off', // We should not use default export
    indent: ['error', 2, {SwitchCase: 1}],
    'max-len': 'off',
    'newline-before-return': 'error',
    'no-multi-spaces': ['error', {ignoreEOLComments: true}],
    'no-param-reassign': ['error', {props: false}],
    'no-shadow': 'error',
    'no-use-before-define': ['error', {functions: false, classes: false}],
    'object-curly-spacing': ['error', 'never'],
    quotes: ['error', 'single'],
    'react/jsx-filename-extension': ['error', {extensions: ['.tsx', '.jsx']}],
    'react/jsx-props-no-spreading': ['error', {html: 'enforce', custom: 'enforce', exceptions: ['MUIButton', 'MUILink', 'MUIButton']}],
    'react/prop-types': 'off', // Typechecking done by Typescript
    semi: 'off', // use typescript version instead
    'space-infix-ops': ['error'],
    '@typescript-eslint/explicit-function-return-type': 'error', // TODO - good practice
    '@typescript-eslint/explicit-member-accessibility': ['error', {accessibility: 'no-public'}],
    '@typescript-eslint/indent': ['error', 2, {SwitchCase: 1}],
    '@typescript-eslint/interface-name-prefix': ['error', 'always'],
    '@typescript-eslint/member-delimiter-style': ['error', {multiline: {delimiter: 'none', requireLast: false}, singleline: {delimiter: 'semi', requireLast: false}}],
    '@typescript-eslint/no-empty-interface': 'off', // Empty interfaces could be imported and updated later. So makes sense to allow it and avoid futher refactoring of {} to interfaces
    '@typescript-eslint/no-use-before-define': ['error', {functions: false, classes: false}],
    '@typescript-eslint/no-var-requires': 'error',
    '@typescript-eslint/semi': ['error', 'never'],
    '@typescript-eslint/type-annotation-spacing': ['error', {before: false, after: true, overrides: {arrow: {before: true, after: true}}}],
    '@typescript-eslint/no-unnecessary-type-assertion': ['error']
  }
}

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

I am using latest version of Next.js 9 with dynamic file based routes. So it works with parametrized file names such as [id].tsx

so when I run eslint I am getting erros only for this kind of files

Screen Shot 2019-07-11 at 6 08 54 PM

node_modules/.bin/eslint ./pages/\[id\].tsx

What did you expect to happen?

It should be working and linted

What actually happened? Please include the actual, raw output from ESLint.

For some reason eslint can't find it or can't properly parse this kind of filenames

@cajoy cajoy added bug ESLint is working incorrectly triage An ESLint team member will look at this issue soon labels Jul 12, 2019
@g-plane
Copy link
Member

g-plane commented Jul 12, 2019

Thanks for your report.

You can add this at CLI: --ext=.tsx,.ts .

@cajoy
Copy link
Author

cajoy commented Jul 12, 2019

Doesn't help. The same result

@g-plane
Copy link
Member

g-plane commented Jul 12, 2019

However, I noticed that your files may not be existed, because you've run ls before and it showed nothing matched.

@mysticatea
Copy link
Member

This looks a duplicate of #11940.

@cajoy
Copy link
Author

cajoy commented Jul 12, 2019

Files exists. you just have to add backslash so bash can find it. There is other commands related to it.

@cajoy
Copy link
Author

cajoy commented Jul 12, 2019

@mysticatea Right. Seems like exactly duplicate

@mysticatea
Copy link
Member

OK, thank you for confirming. Please track that issue.

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Jan 9, 2020
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Jan 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly triage An ESLint team member will look at this issue soon
Projects
None yet
Development

No branches or pull requests

3 participants