eslintOptions.js 856 B

12345678910111213141516171819202122232425262728293031
  1. exports.config = api => {
  2. const config = {
  3. root: true,
  4. env: { node: true },
  5. extends: ['plugin:vue/essential'],
  6. rules: {
  7. 'no-console': makeJSOnlyValue(`process.env.NODE_ENV === 'production' ? 'error' : 'off'`),
  8. 'no-debugger': makeJSOnlyValue(`process.env.NODE_ENV === 'production' ? 'error' : 'off'`)
  9. }
  10. }
  11. if (!api.hasPlugin('typescript')) {
  12. config.parserOptions = {
  13. parser: 'babel-eslint'
  14. }
  15. }
  16. return config
  17. }
  18. // __expression is a special flag that allows us to customize stringification
  19. // output when extracting configs into standalone files
  20. function makeJSOnlyValue (str) {
  21. const fn = () => {}
  22. fn.__expression = str
  23. return fn
  24. }
  25. const baseExtensions = ['.js', '.jsx', '.vue']
  26. exports.extensions = api => api.hasPlugin('typescript')
  27. ? baseExtensions.concat('.ts', '.tsx')
  28. : baseExtensions