1

I configured ecmaVersion 6 for my test files but it does not lint features that are not available in ecma6. Rules are working fine.

.eslintrc.js

module.exports = {
    root: true,

    extends: ['airbnb-base', '.eslintrc.airbnbonlywarnings.js'],

    parser: '@typescript-eslint/parser',

    parserOptions: {
        ecmaVersion: 6,
        ecmaFeatures: {
            blockBindings: false,
            forOf: false
        },
        project: 'tsconfig.json',
        tsconfigRootDir: __dirname
    },

    plugins: ['@typescript-eslint'],

    env: {
        browser: true,
        jasmine: true,
        node: true,
        mocha: false,
        amd: true
    },

    overrides: [{
        files: ['**/e2e/**/*.ts', '**/e2e/**/*.js'],
        parserOptions: {
            ecmaVersion: 6,
            project: 'tsconfig.e2e.json'
        }
    }]
}

tsconfig.e2e.json

{
    "compilerOptions": {
        "rootDir": ".",
        "outDir": "build-e2e",
        "allowJs": true,
        "incremental": true,
        "moduleResolution": "node",
        "module": "commonjs",
        "target": "es6",
        "noEmitOnError": true,
        "strict": false,
        "typeRoots" :[
            "./@types",
            "./node_modules/@types"
        ],
        "removeComments": false,
        "sourceMap": false
    },
    "include": [
        "@types/**/*.d.ts",
        "test/protractor/**/*.ts",
        "test/protractor/**/*.js",
        "src/**/test/e2e/**/*.ts",
        "src/**/test/e2e/**/*.js",
        "grunt/users/**/fake.config.ts"
    ],
    "exclude":[
        "./node_modules",
        "./customer_bundles"
    ]
}

Example code:

const myObj = { a: 'somestring', b: 42, c: false };
const tmp = Object.values(object1);

Expected Result Because Object.values() is a feature introduced in ecma 2017 it should lint that line because I specified ecmaVersion 6 aka 2015

Actual Result It's not linting

Additional Info It's not linting in IntelliJ and also not via console. No errors in console. Upgraded @typescript-eslint/parser 2.25.0 to 4.1 but that didn't help.

Versions

  • @typescript-eslint/parser 2.25.0
  • TypeScript 3.9.2
  • ESLint 6.3.0
  • node 14.4.0

So what I'm doing wrong?

3
  • I didn't see "env" in your .eslint file. Check eslint.org/docs/user-guide/… Commented Sep 8, 2020 at 12:06
  • I thought it's not relevant for my use case, but it's in the code and I added it now above in the example. Commented Sep 8, 2020 at 13:29
  • Add "env": { "es6": true } } and check Commented Sep 8, 2020 at 14:37

2 Answers 2

1

You do not need to lint for features unavailable in ecma6 if you are using typescript (except for new regexp syntax), because typescript will transpile new features to ecma6.

You can use eslint-plugin-es, but only for regular expressions. Everything else gets transpiled.

Sign up to request clarification or add additional context in comments.

Comments

0

Ok, the ecmaVersion doesn't do much in combination with @typescript-eslint/parser according to the developer. I'm now using eslint-plugin-es to lint ecma features. That works as intended.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.