vendredi 1 septembre 2017

Why do I need to repeat the `parserOptions.ecmaVersion` in my config?

Configuration

Project Configuration

module.exports = {
  root: true,
  extends: ['my_config/ember'],
  rules: {}
};

my_config/ember.js Configuration

module.exports = {
  env: {
    browser: true
  },
  extends: ['./base.js', 'plugin:ember-suave/recommended']
};

my_config/base.js Configuration

module.exports = {
  extends: ['eslint:recommended'],
  env: {
    es6: true
  },
  parserOptions: {
    ecmaVersion: 2017,
    sourceType: 'module'
  },
  rules: {
    // ES6
  }
};


What did I do?

When I lint one of my file

$ eslint ./tests/acceptance/login-form-test.js

What did I expect to happen?

I expected the parserOptions.ecmaVersion from _my_config/base.js_ to be available in the project's context as per extending hierarchy: .eslintrc.js → _my_config/ember.js_ → _my_config/base.js_.

If I add parserOptions.ecmaVersion in the project .eslintrc.js configuration file, no more error.

  parserOptions: {
    ecmaVersion: 2017
  }

What actually happened?

If I remove parserOptions.ecmaVersion I got the error:

/data/projects/employee-app-front/tests/acceptance/login-form-test.js
  14:61  error  Parsing error: Unexpected token function

Error is on the function of this line:

test('clicking "forgotten…" link redirect to /reset', async function(assert) {

Question

Why do I need to repeat the parserOptions.ecmaVersion in my config?

related: DockYard/eslint-plugin-ember-suave#53, eslint/eslint#9191




Aucun commentaire:

Enregistrer un commentaire