Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPA todo setup #10

Open
Pave91 opened this issue May 30, 2018 · 0 comments
Open

SPA todo setup #10

Pave91 opened this issue May 30, 2018 · 0 comments

Comments

@Pave91
Copy link

Pave91 commented May 30, 2018

We used SPA template for https://github.com/strvcom/strv-admin-web, at the beginning we dealt with a few issues or not completed configuration. I wrote small guideline which may help others to use it.

Before creating PR I would like to discuss what you consider as mandatory and other aspects.

Here is the list of changes in SPA project itself:

tasks in package.json

eslint

  • missing task for run eslint/lint

  • after checking eslint, several warnings/errors appeared, mainly that some Definition for rule was not found:

    • solved adding eslint-plugin-import package
    • edited file registerServiceWorker to have export default at the end of file
    • had to add in .eslintrc
    "globals": {
        "process": true
      },
    "env": {
        "jest": true
      }
    
    • App.js doesn't suit to eslint rule react/prefer-stateless-function and also contains classNames through styled-components option

flow

  • discussion and issue here: Add .flowconfig #3
  • my summary:
    • flow option: missing task in precommit
    • after first running: app reference error:
    Module build failed: ReferenceError: Unknown plugin "flow" specified in "/home/paave/WebstormProjects/create-strv-app/test/.babelrc" at 0, attempted to resolve relative to "/home/paave/WebstormProjects/create-strv-app/test"
         at Array.map (<anonymous>)
    
    • missing .flowconfig file

relative paths - module resolving

  • had to add babel-plugin-module-resolver and eslint-import-resolver-babel-module
  • added file .env with NODE_PATH='src'
  • in .flowconfig options section added module.system.node.resolve_dirname=./src module.system.node.resolve_dirname=node_modules
  • in .eslintrc:
"settings": {
     "import/resolver": {
       "babel-module": {},
       "node": {
         "paths": [
           "./src"
         ]
       }
     }

Worth considering

  • checking if every file has // @flow comment: credit to @koss-lebedev
 FILES_COUNT=$(echo $FILES_WITHOUT_FLOW | wc -w)
 
 if [ $FILES_COUNT -ne 0 ]
 then
   echo "Following files are missing @flow annotation:"
   echo $FILES_WITHOUT_FLOW | tr " " "\n"
   exit 1
 fi 

last but not least

  • missing .editorconfig
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant