formatjs / formatjs-old

The monorepo home to all of the FormatJS related libraries.
https://formatjs.io/
156 stars 53 forks source link

ESLint plugin doesn't work without typescript package #666

Closed ybelenko closed 4 years ago

ybelenko commented 4 years ago

Which package? eslint-plugin-formatjs: ^2.2.1

Describe the bug It seems like plugin doesn't work with vanilla javascript(React JSX in my case).

To Reproduce .eslintrc.js:

module.exports = {
  env: {
    browser: true,
    es6: true,
  },
  extends: [
    'plugin:react/recommended',
    'airbnb',
  ],
  globals: {
    Atomics: 'readonly',
    SharedArrayBuffer: 'readonly',
  },
  parserOptions: {
    ecmaFeatures: {
      jsx: true,
    },
    ecmaVersion: 2018,
    sourceType: 'module',
  },
  plugins: [
    'react',
    'formatjs'
  ],
  rules: {
    "formatjs/no-offset": "error"
  }
};

package.json:

{
  "name": "foobar",
  "version": "1.0.0",
  "description": "",
  "main": "src/index.jsx",
  "scripts": {
    "test": "eslint ./src --ext js,jsx",
    "start": "webpack-dev-server --config ./webpack.dev.js"
  },
  "dependencies": {
    "bootstrap": "^4.4.1",
    "prop-types": "^15.7.2",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-hot-loader": "^4.12.20",
    "react-intl": "^4.5.0",
    "react-redux": "^7.2.0",
    "reactstrap": "^8.4.1",
    "redux": "^4.0.5",
    "redux-actions": "^2.6.5",
    "redux-logger": "^3.0.6",
    "redux-thunk": "^2.3.0"
  },
  "devDependencies": {
    "@babel/core": "^7.9.0",
    "@babel/preset-env": "^7.9.5",
    "@babel/preset-react": "^7.9.4",
    "@hot-loader/react-dom": "^16.13.0",
    "autoprefixer": "^9.7.6",
    "babel-loader": "^8.1.0",
    "css-loader": "^3.5.2",
    "eslint": "^6.8.0",
    "eslint-config-airbnb": "^18.1.0",
    "eslint-plugin-formatjs": "^2.2.1",
    "eslint-plugin-import": "^2.20.2",
    "eslint-plugin-jsx-a11y": "^6.2.3",
    "eslint-plugin-react": "^7.19.0",
    "eslint-plugin-react-hooks": "^2.5.1",
    "html-webpack-plugin": "^4.2.0",
    "postcss-loader": "^3.0.0",
    "sass": "^1.26.3",
    "sass-loader": "^8.0.2",
    "style-loader": "^1.1.4",
    "webpack": "^4.43.0",
    "webpack-cli": "^3.3.11",
    "webpack-dev-server": "^3.10.3"
  }
}
$ npm test
Error: Failed to load plugin 'formatjs' declared in '.eslintrc.js':
Cannot find module 'typescript'

After installation of missed package error disappears.

Expected behavior Package should work with vanilla javascript(without typescript package).

longlho commented 4 years ago

ah we do use typescript to parse JS as well. I'll add the missing dependency