首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法在Atom编辑器中工作

无法在Atom编辑器中工作
EN

Stack Overflow用户
提问于 2017-09-09 01:52:57
回答 2查看 3.2K关注 0票数 3

在这一点上,我完全搞不懂如何让ESLint安装并使用Atom进行功能。所以我将一步一步地发布,如果有人能帮我做到这一点,那就太棒了。

  • 原子: 1.19.5
  • 原子,linter 2.2.0
  • 原子,linter-eslint 8.2.1

我已经卸载和重新安装的Atom插件,并已禁用所有其他插件,除了那些在核心和2个指针。

  • npm list -g --depth=0

所有全球安装:

代码语言:javascript
复制
├── create-react-app@1.0.4
├── create-react-native-app@1.0.0
├── eslint@4.6.1
├── express-generator@4.14.1
├── json-server@0.9.5
├── mocha@3.2.0
├── nodemon@1.11.0
├── npm@3.10.10
├── pushstate-server@2.2.1
├── react-native-cli@2.0.1
├── react-vr-cli@0.3.5
├── webpack@2.2.1
├── webpack-dev-server@2.3.0
└── yarn@0.21.3

以下是我在Atom项目中为使eslint工作所做的尝试步骤:

  • npm install -g eslint
  • cd /into/project
  • eslint --init
  • ? How would you like to configure ESLint? > User a popular style guide
  • ? Which style guide do you want to follow? >Airbnb
  • ? Do you use React? > y
  • ? What format do you want your config file to be in? > JSON
  • 删除/node_modules
  • npm install /project /node_modules .eslintrc.json index.js package.json

.eslintrc.json

代码语言:javascript
复制
{
  "extends": "airbnb"
}

package.json

代码语言:javascript
复制
{
  "name": "lint-test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "eslint": "^4.6.1",
    "eslint-config-airbnb": "^15.1.0",
    "eslint-config-rallycoding": "^3.2.0",
    "eslint-plugin-import": "^2.7.0",
    "eslint-plugin-jsx-a11y": "^5.1.1",
    "eslint-plugin-react": "^7.3.0"
  }
}

index.js

这只是一个文件,试图从eslint获得某种类型的结果

误差

运行ESLint (开放开发人员控制台)时链接错误

Configuration for rule "jsx-a11y/anchor-has-content" is invalid: Value "[object Object]" no (or more than one) schemas match.

Atom developer控制台中没有出现错误。但是,Atom编辑器中的Linter并没有发生任何事情。我能打字胡言乱语什么都不会发生。

运行调试

  • DEBUG=eslint:* eslint .

调试结果:

代码语言:javascript
复制
Cannot find module 'eslint-config-airbnb'
Referenced from: /Users/user/development/lint-test/.eslintrc.json
Error: Cannot find module 'eslint-config-airbnb'
Referenced from: /Users/user/development/lint-test/.eslintrc.json
at ModuleResolver.resolve (/Users/user/.nvm/versions/node/v6.9.5/lib/node_modules/eslint/lib/util/module-resolver.js:74:19)
at resolve (/Users/user/.nvm/versions/node/v6.9.5/lib/node_modules/eslint/lib/config/config-file.js:515:25)
at load (/Users/user/.nvm/versions/node/v6.9.5/lib/node_modules/eslint/lib/config/config-file.js:584:26)
at configExtends.reduceRight.e (/Users/user/.nvm/versions/node/v6.9.5/lib/node_modules/eslint/lib/config/config-file.js:421:36)
at Array.reduceRight (native)
at applyExtends (/Users/user/.nvm/versions/node/v6.9.5/lib/node_modules/eslint/lib/config/config-file.js:403:28)
at loadFromDisk (/Users/user/.nvm/versions/node/v6.9.5/lib/node_modules/eslint/lib/config/config-file.js:556:22)
at Object.load (/Users/user/.nvm/versions/node/v6.9.5/lib/node_modules/eslint/lib/config/config-file.js:592:20)
at Config.getLocalConfigHierarchy (/Users/user/.nvm/versions/node/v6.9.5/lib/node_modules/eslint/lib/config.js:226:44)
at Config.getConfigHierarchy (/Users/user/.nvm/versions/node/v6.9.5/lib/node_modules/eslint/lib/config.js:180:43)

在这一点上,我假设它是试图从全球而不是本地阅读

现在又什么都没有发生,再次运行调试。

  • DEBUG=eslint:* eslint .

仍然找不到模块

  • 尝试用eslint配置Atom编辑器中的建议

在这一点上,我仍然会遇到Cannot find module 'eslint-config-airbnb'

新本地package.json

代码语言:javascript
复制
"devDependencies": {
  "eslint": "^4.6.1",
  "eslint-config-airbnb": "^15.1.0",
  "eslint-plugin-import": "^2.7.0",
  "eslint-plugin-jsx-a11y": "^5.1.1",
  "eslint-plugin-react": "^7.3.0"
}
  • npm install -g eslint-config-airbnb

新的全局模

代码语言:javascript
复制
├── create-react-app@1.0.4
├── create-react-native-app@1.0.0
├── eslint@4.6.1
├── eslint-config-airbnb@15.1.0
├── eslint-plugin-import@2.7.0
├── UNMET PEER DEPENDENCY eslint-plugin-jsx-a11y@6.0.2
├── eslint-plugin-react@7.3.0
├── express-generator@4.14.1
├── install-peerdeps@1.1.3
├── json-server@0.9.5
├── mocha@3.2.0
├── nodemon@1.11.0
├── npm@3.10.10
├── pushstate-server@2.2.1
├── react-native-cli@2.0.1
├── react-vr-cli@0.3.5
├── webpack@2.2.1
├── webpack-dev-server@2.3.0
└── yarn@0.21.3

所以现在我可以运行DEBUG=eslint:* eslint .并得到一些结果。然而,在Atom中没有任何东西运行。

结果:

代码语言:javascript
复制
/Users/user/development/lint-test/index.js
  1:1   error  Definition for rule 'jsx-a11y/href-no-hash' was not found  jsx-a11y/href-no-hash
  1:7   error  'config' is assigned a value but never used                no-unused-vars
  1:24  error  Unable to resolve path to module '../something'            import/no-unresolved
  1:39  error  Missing semicolon                                          semi

✖ 4 problems (4 errors, 0 warnings)
  1 error, 0 warnings potentially fixable with the `--fix` option.

在这一点上,我没有办法让Atom真正地与埃林特一起工作.

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-09-15 16:00:02

没有深入研究这个问题,也没有找到具体的失败点,我决定重新开始。

  • 删除全局节点模块。
  • 删除所有非核心Atom插件和主题。
  • 卸载Atom。
  • 重新安装Atom。
  • 只安装ESLint并支持依赖关系。

这样做,我就能够毫无问题地运行ESLint。我的假设是,在插件或主题中存在冲突。在那里安装我的核心工具插件是成功的。

票数 0
EN

Stack Overflow用户

发布于 2017-12-19 03:31:05

取消选中ATOM的linter-eslint中的“使用全局ESLint安装”设置将使其正确。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46126464

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档