Guest User

Untitled

a guest
May 20th, 2018
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.75 KB | None | 0 0
  1. # ESLint + TSLint + TypeScript + Create React App TS
  2.  
  3. ## .eslintrc
  4.  
  5. ```json
  6. {
  7. "parser": "typescript-eslint-parser",
  8. "extends": [
  9. "airbnb",
  10. "prettier",
  11. "prettier/react",
  12. "plugin:prettier/recommended",
  13. "plugin:jest/recommended",
  14. "plugin:unicorn/recommended"
  15. ],
  16. "plugins": ["prettier", "jest", "unicorn"],
  17. "parserOptions": {
  18. "sourceType": "module",
  19. "ecmaFeatures": {
  20. "jsx": true
  21. }
  22. },
  23. "env": {
  24. "es6": true,
  25. "browser": true,
  26. "jest": true
  27. },
  28. "rules": {
  29. "prettier/prettier": [
  30. "error",
  31. {
  32. "singleQuote": true,
  33. "trailingComma": "all"
  34. }
  35. ],
  36. "jsx-a11y/anchor-is-valid": [
  37. "error",
  38. {
  39. "components": ["Link"],
  40. "specialLink": ["to"],
  41. "aspects": ["noHref", "invalidHref", "preferButton"]
  42. }
  43. ],
  44. "react/jsx-filename-extension": "off",
  45. "unicorn/filename-case": "off",
  46. "import/extensions": { "ts": "never", "tsx": "never" },
  47. "no-use-before-define": "warn",
  48. "no-param-reassign": "warn"
  49. },
  50. "settings": {
  51. "import/resolver": {
  52. "node": {
  53. "extensions": [".ts", ".tsx"]
  54. }
  55. }
  56. },
  57. "overrides": [
  58. {
  59. "files": ["**/*.ts", "**/*.tsx"],
  60. "parser": "typescript-eslint-parser",
  61. "rules": {
  62. "no-undef": "off"
  63. }
  64. }
  65. ]
  66. }
  67. ```
  68.  
  69. ## tslint.json
  70.  
  71. ```json
  72. {
  73. "extends": [
  74. "tslint:recommended",
  75. "tslint-config-airbnb",
  76. "tslint-react",
  77. "tslint-config-prettier"
  78. ],
  79. "linterOptions": {
  80. "exclude": ["config/**/*.js", "node_modules/**/*.ts"]
  81. }
  82. }
  83. ```
  84.  
  85. ## .prettierrc
  86.  
  87. ```json
  88. {
  89. "printWidth": 89,
  90. "tabWidth": 2,
  91. "useTabs": false,
  92. "semi": true,
  93. "singleQuote": true,
  94. "trailingComma": "all",
  95. "bracketSpacing": true,
  96. "jsxBracketSameLine": false
  97. }
  98. ```
  99.  
  100. ## package.json
  101.  
  102. ```json
  103. {
  104. "name": "eslint-typescript",
  105. "version": "0.1.0",
  106. "private": true,
  107. "dependencies": {
  108. "react": "^16.3.2",
  109. "react-dom": "^16.3.2",
  110. "react-scripts-ts": "2.16.0"
  111. },
  112. "scripts": {
  113. "start": "react-scripts-ts start",
  114. "build": "react-scripts-ts build",
  115. "test": "react-scripts-ts test --env=jsdom",
  116. "eject": "react-scripts-ts eject"
  117. },
  118. "devDependencies": {
  119. "@types/jest": "^22.2.3",
  120. "@types/node": "^10.0.9",
  121. "@types/react": "^16.3.14",
  122. "@types/react-dom": "^16.0.5",
  123. "eslint": "^4.9.0",
  124. "eslint-config-airbnb": "16.1.0",
  125. "eslint-config-prettier": "^2.9.0",
  126. "eslint-plugin-import": "^2.7.0",
  127. "eslint-plugin-jest": "^21.15.1",
  128. "eslint-plugin-jsx-a11y": "^6.0.2",
  129. "eslint-plugin-prettier": "^2.6.0",
  130. "eslint-plugin-react": "^7.4.0",
  131. "eslint-plugin-unicorn": "^4.0.3",
  132. "prettier": "^1.12.1",
  133. "tslint-config-airbnb": "^5.8.0",
  134. "typescript": "^2.8.3",
  135. "typescript-eslint-parser": "^15.0.0"
  136. }
  137. }
  138. ```
Add Comment
Please, Sign In to add comment