pex-gl / pex-context

Modern WebGL state wrapper for PEX: allocate GPU resources (textures, buffers), setup state pipelines and passes, and combine them into commands.
http://pex-gl.github.io/pex-context/
MIT License
160 stars 12 forks source link

Add prettier and eslint #65

Closed dmnsgn closed 5 years ago

dmnsgn commented 5 years ago

Same config as for pex-renderer but in pex-context now is probably a good time to review/merge while there's no PR open.

vorg commented 5 years ago

Can you link description of default prettier rules and config options.

There is stuff that i learned for standard and would need to unlearn like

Space after function name

Screenshot 2019-03-13 at 23 35 54 Screenshot 2019-03-13 at 23 35 57

Um why?

Screenshot 2019-03-13 at 23 38 14 Screenshot 2019-03-13 at 23 43 42

Is the goal "minimum typing"

Screenshot 2019-03-13 at 23 45 08 Screenshot 2019-03-13 at 23 45 15

And stuff that I avoid like fire

Arrow function parentheses (a => b => c anyone?)

Screenshot 2019-03-13 at 23 36 51 Screenshot 2019-03-13 at 23 36 54

In the end i know for 100 devs there is 100 styles and i'll need to learn to live with it. Just like i did with misaligned } else {... but want to learn first.

dmnsgn commented 5 years ago

Can you link description of default prettier rules and config options.

There is stuff that i learned for standard and would need to unlearn like

All options are here with good explanation why: https://prettier.io/docs/en/options.html

With explicit defaults, these would be our config:

{
  "printWidth": 80,
  "tabWidth": 2,
  "useTabs": false,
  "semi": false,
  "singleQuote": true,
  "trailingComma": "none",
  "bracketSpacing": true,
  "arrowParens": "avoid"
}

Space after function name

Screenshot 2019-03-13 at 23 35 54 Screenshot 2019-03-13 at 23 35 57

Not with prettier

Um why?

Screenshot 2019-03-13 at 23 38 14 Screenshot 2019-03-13 at 23 43 42

Because the parenthesis are unnecessary before the ternary.

Is the goal "minimum typing"

Screenshot 2019-03-13 at 23 45 08 Screenshot 2019-03-13 at 23 45 15

Just the result of the bracketSpacing rule

And stuff that I avoid like fire

Arrow function parentheses (a => b => c anyone?)

Screenshot 2019-03-13 at 23 36 51 Screenshot 2019-03-13 at 23 36 54

Can be forced with arrowParens option but I usually omit them. Your call.

dmnsgn commented 5 years ago

Linter/formatter config with detailed explanations:

{
  "devDependencies": {
    "eslint": "^5.15.1",
    "eslint-config-prettier": "^4.1.0",
    "eslint-plugin-markdown": "^1.0.0",
    "eslint-plugin-prettier": "^3.0.1",
    "prettier": "1.16.4"
  },
  // Formatting options
  "prettier": {
    "semi": false,
    "singleQuote": true,
    "arrowParens": "always"
  },
  // Linting options
  "eslintConfig": {
    "extends": [
      "eslint:recommended", // Enable rules from eslint
      "plugin:prettier/recommended" // Disable rules clashing with prettier
    ],
    "plugins": [
      "prettier", // Make eslint report formatting issues
      "markdown" // Lint code blocks in Markdown documents
    ],
    "rules": {
      "prettier/prettier": "error" // Tag reported formatting issues as errors (red dot in editors)
    },
    "parserOptions": {
      "ecmaVersion": 2019 // Allows use of the latest js syntax
    },
    "env": {
      "es6": true, // Enable all ECMAScript 6 features except for modules
      "browser": true, // Enable use of browser global variables
      "node": true // Enable use of Node.js global variables and Node.js scoping
    }
  }
}
vorg commented 5 years ago

This looks good 👍