【发布时间】:2020-11-16 12:22:15
【问题描述】:
Atom 包 - 已安装
- 原子打字稿
- 仅语言打字稿语法
- 短绒
- linter-eslint
- linter-stylelint
- linter-ui-default
- 更漂亮的原子
更漂亮 - 设置:
- ESLint 集成 = 已检查
- Stylelint 集成 = 选中
- EditotConfig 集成 = 未选中
.eslintrc
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true,
"modules": true,
"impliedStrict": true,
"experimentalObjectRestSpread": true
}
},
"settings": {
"react": {
"pragma": "React",
"version": "detect"
},
"import/resolver": {
"node": {
"extensions": [".js", ".jsx", ".ts", ".tsx"],
"paths": ["./"]
},
"babel-module": {}
}
},
"extends": [
"plugin:react/recommended",
"airbnb",
"plugin:prettier/recommended",
"plugin:@typescript-eslint/recommended",
"prettier/react",
"prettier/@typescript-eslint",
"plugin:import/typescript"
],
"plugins": ["react", "@typescript-eslint", "prettier", "mocha"],
"env": {
"es6": true,
"browser": true,
"jest": true,
"mocha": true,
"node": true
}
}
tsconfig.json
{
"compileOnSave": false,
"compilerOptions": {
"allowJs": true,
"allowSyntheticDefaultImports": true,
"baseUrl": "./",
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
"jsx": "react",
"module": "esnext",
"moduleResolution": "node",
"noEmit": true,
"noImplicitAny": true,
"outDir": "./dist/out-tsc",
"resolveJsonModule": true,
"sourceMap": true,
"strict": true,
"target": "esnext",
"downlevelIteration": true,
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"skipLibCheck": true,
"esModuleInterop": true
},
"include": [
"src",
"src/__tests__"
],
"exclude": [
"node_modules",
"public"
]
}
SomeLabel.jsx
- 正确显示错误 - 表单标签必须与控件相关联
import React, { FC } from 'react';
const SomeLabel: FC = () => {
return (
<label>hello world</label>
);
};
export default SomeLabel;
SomeLabel.tsx
- 不显示错误!
import React, { FC } from 'react';
const SomeLabel: FC = () => {
return (
<label>hello world</label>
);
};
export default SomeLabel;
jsx 文件正确处理 eslint 错误,而 typescript 文件扩展名则没有。这适用于 Visual Studio 代码,但不适用于 atom。我怎样才能让 atom 以同样的方式工作?
谢谢
【问题讨论】:
标签: typescript eslint prettier