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

Comments

@cajoy
Copy link

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 triage labels Jul 12, 2019

@g-plane

This comment has been minimized.

Copy link
Member

commented Jul 12, 2019

Thanks for your report.

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

@cajoy

This comment has been minimized.

Copy link
Author

commented Jul 12, 2019

Doesn't help. The same result

@g-plane

This comment has been minimized.

Copy link
Member

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

This comment has been minimized.

Copy link
Member

commented Jul 12, 2019

This looks a duplicate of #11940.

@cajoy

This comment has been minimized.

Copy link
Author

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

This comment has been minimized.

Copy link
Author

commented Jul 12, 2019

@mysticatea Right. Seems like exactly duplicate

@mysticatea

This comment has been minimized.

Copy link
Member

commented Jul 12, 2019

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

@mysticatea mysticatea closed this Jul 12, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.