Skip to content

Commit

Permalink
added es lint and linted files
Browse files Browse the repository at this point in the history
  • Loading branch information
vinyll committed Jun 26, 2018
1 parent e4cc162 commit c1a87f4
Show file tree
Hide file tree
Showing 10 changed files with 314 additions and 40 deletions.
258 changes: 258 additions & 0 deletions .eslintrc.json
@@ -0,0 +1,258 @@
{
"env": {
"browser": true,
"es6": true
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 2018
},
"rules": {
"accessor-pairs": "error",
"array-bracket-newline": "error",
"array-bracket-spacing": [
"error",
"never"
],
"array-callback-return": "error",
"array-element-newline": "off",
"arrow-body-style": "error",
"arrow-parens": "error",
"arrow-spacing": "error",
"block-scoped-var": "error",
"block-spacing": "error",
"brace-style": "error",
"callback-return": "error",
"camelcase": "error",
"capitalized-comments": "off",
"class-methods-use-this": "error",
"comma-dangle": "error",
"comma-spacing": [
"error",
{
"after": true,
"before": false
}
],
"comma-style": "error",
"complexity": "error",
"computed-property-spacing": "error",
"consistent-return": "error",
"consistent-this": "error",
"curly": "error",
"default-case": "error",
"dot-location": "error",
"dot-notation": "error",
"eol-last": "error",
"eqeqeq": "error",
"func-call-spacing": "error",
"func-name-matching": "error",
"func-names": "error",
"func-style": [
"error",
"declaration"
],
"function-paren-newline": "error",
"generator-star-spacing": "error",
"global-require": "error",
"guard-for-in": "error",
"handle-callback-err": "error",
"id-blacklist": "error",
"id-length": "off",
"id-match": "error",
"implicit-arrow-linebreak": "error",
"indent": "off",
"indent-legacy": "off",
"init-declarations": "error",
"jsx-quotes": "error",
"key-spacing": "error",
"keyword-spacing": "error",
"line-comment-position": "off",
"linebreak-style": [
"error",
"unix"
],
"lines-around-comment": "error",
"lines-around-directive": "error",
"lines-between-class-members": "error",
"max-classes-per-file": "error",
"max-depth": "error",
"max-len": "error",
"max-lines": "error",
"max-lines-per-function": "error",
"max-nested-callbacks": "error",
"max-params": "error",
"max-statements": "error",
"max-statements-per-line": "error",
"multiline-comment-style": "error",
"multiline-ternary": "error",
"new-cap": "error",
"new-parens": "error",
"newline-after-var": [
"error",
"never"
],
"newline-before-return": "off",
"newline-per-chained-call": "error",
"no-alert": "error",
"no-array-constructor": "error",
"no-await-in-loop": "error",
"no-bitwise": "error",
"no-buffer-constructor": "error",
"no-caller": "error",
"no-catch-shadow": "error",
"no-confusing-arrow": "error",
"no-continue": "error",
"no-div-regex": "error",
"no-duplicate-imports": "error",
"no-else-return": "error",
"no-empty-function": "error",
"no-eq-null": "error",
"no-eval": "error",
"no-extend-native": "error",
"no-extra-bind": "error",
"no-extra-label": "error",
"no-extra-parens": "error",
"no-floating-decimal": "error",
"no-implicit-coercion": "error",
"no-implicit-globals": "off",
"no-implied-eval": "error",
"no-inline-comments": "off",
"no-invalid-this": "error",
"no-iterator": "error",
"no-label-var": "error",
"no-labels": "error",
"no-lone-blocks": "error",
"no-lonely-if": "error",
"no-loop-func": "error",
"no-magic-numbers": "off",
"no-mixed-operators": "off",
"no-mixed-requires": "error",
"no-multi-assign": "error",
"no-multi-spaces": [
"error",
{
"ignoreEOLComments": true
}
],
"no-multi-str": "error",
"no-multiple-empty-lines": "error",
"no-native-reassign": "error",
"no-negated-condition": "error",
"no-negated-in-lhs": "error",
"no-nested-ternary": "error",
"no-new": "error",
"no-new-func": "error",
"no-new-object": "error",
"no-new-require": "error",
"no-new-wrappers": "error",
"no-octal-escape": "error",
"no-param-reassign": "error",
"no-path-concat": "error",
"no-plusplus": "error",
"no-process-env": "error",
"no-process-exit": "error",
"no-proto": "error",
"no-prototype-builtins": "error",
"no-restricted-globals": "error",
"no-restricted-imports": "error",
"no-restricted-modules": "error",
"no-restricted-properties": "error",
"no-restricted-syntax": "error",
"no-return-assign": "error",
"no-return-await": "error",
"no-script-url": "error",
"no-self-compare": "error",
"no-sequences": "error",
"no-shadow": "error",
"no-shadow-restricted-names": "error",
"no-spaced-func": "error",
"no-sync": "error",
"no-tabs": "error",
"no-template-curly-in-string": "error",
"no-ternary": "error",
"no-throw-literal": "error",
"no-trailing-spaces": "error",
"no-undef-init": "error",
"no-undefined": "error",
"no-underscore-dangle": "error",
"no-unmodified-loop-condition": "error",
"no-unneeded-ternary": "error",
"no-unused-expressions": "error",
"no-use-before-define": "off",
"no-useless-call": "error",
"no-useless-computed-key": "error",
"no-useless-concat": "error",
"no-useless-constructor": "error",
"no-useless-rename": "error",
"no-useless-return": "error",
"no-var": "error",
"no-void": "error",
"no-warning-comments": "error",
"no-whitespace-before-property": "error",
"no-with": "error",
"nonblock-statement-body-position": "error",
"object-curly-newline": "error",
"object-curly-spacing": "error",
"object-property-newline": "error",
"object-shorthand": "error",
"one-var": "off",
"one-var-declaration-per-line": "error",
"operator-assignment": "error",
"operator-linebreak": "error",
"padded-blocks": "off",
"padding-line-between-statements": "error",
"prefer-arrow-callback": "error",
"prefer-const": "error",
"prefer-destructuring": "error",
"prefer-numeric-literals": "error",
"prefer-object-spread": "error",
"prefer-promise-reject-errors": "error",
"prefer-reflect": "error",
"prefer-rest-params": "error",
"prefer-spread": "error",
"prefer-template": "error",
"quote-props": "error",
"quotes": "error",
"radix": "error",
"require-await": "error",
"require-jsdoc": "off",
"rest-spread-spacing": "error",
"semi": "off",
"semi-spacing": "error",
"semi-style": "error",
"sort-imports": "error",
"sort-keys": "error",
"sort-vars": "error",
"space-before-blocks": "error",
"space-before-function-paren": "off",
"space-in-parens": [
"error",
"never"
],
"space-infix-ops": "off",
"space-unary-ops": "error",
"spaced-comment": [
"error",
"always"
],
"strict": [
"error",
"never"
],
"switch-colon-spacing": "error",
"symbol-description": "error",
"template-curly-spacing": "error",
"template-tag-spacing": "error",
"unicode-bom": [
"error",
"never"
],
"valid-jsdoc": "error",
"vars-on-top": "error",
"wrap-iife": "error",
"wrap-regex": "error",
"yield-star-spacing": "error",
"yoda": "error"
}
}
23 changes: 14 additions & 9 deletions index.html
Expand Up @@ -83,7 +83,6 @@ <h2>L'Éducation artistique et culturelle à votre portée</h2>

<main><div class=loading></div></main>

<script type=riot/tag src=./tags/checkbox.tag.html></script>
<script type=riot/tag src=./tags/page-home.tag.html></script>
<script type=riot/tag src=./tags/page-actor.tag.html></script>
<script type=riot/tag src=./tags/form-search.tag.html></script>
Expand All @@ -97,12 +96,19 @@ <h2>L'Éducation artistique et culturelle à votre portée</h2>
<script src=./js/page.query.js></script>
<script src=./js/awesomplete.min.js></script>
<script>
const user = {location: {latitude: 0, longitude: 0}}
/* global
fetch,
localStorage,
location,
page,
qs,
riot,
*/
const app = document.querySelector('main')
const apiUrl = localStorage.getItem('apiUrl') || 'https://eac-api.herokuapp.com'
let school = localStorage.getItem('school') && JSON.parse(localStorage.getItem('school'))

function api(url) {
function api (url) {
return fetch(`${apiUrl}${url}`, {mode: 'cors'})
.then(r => r.json())
.catch(console.error.bind(console))
Expand All @@ -113,8 +119,7 @@ <h2>L'Éducation artistique et culturelle à votre portée</h2>
*/
page('*', (ctx, next) => {
const hash = location.hash
if(hash.indexOf('?') >= 0)
ctx.query = qs.parse(hash.slice(hash.indexOf('?') + 1))
if (hash.indexOf('?') >= 0) { ctx.query = qs.parse(hash.slice(hash.indexOf('?') + 1)) }
next()
})

Expand All @@ -130,14 +135,14 @@ <h2>L'Éducation artistique et culturelle à votre portée</h2>
})

page('/search/:query/:filters', async ctx => {
if(!school) {
if (!school) {
page('/')
}
app.innerHTML = '<page-home></page-home>'
const q = ctx.params.query
const filters = JSON.parse(decodeURI(ctx.params.filters))
let params = filters.domains ? `?domains=${filters.domains}` : ''
if(school.loc.coordinates) {
if (school.loc.coordinates) {
params += (params ? '&' : '?')
params += `from=${school.loc.coordinates[1]},${school.loc.coordinates[0]}`
}
Expand All @@ -148,12 +153,12 @@ <h2>L'Éducation artistique et culturelle à votre portée</h2>
page('/actor/:id', async (ctx) => {
app.innerHTML = '<page-actor></page-actor>'
let params = ''
if(school.loc) params = `?from=${school.loc.coordinates[1]},${school.loc.coordinates[0]}`
if (school.loc) params = `?from=${school.loc.coordinates[1]},${school.loc.coordinates[0]}`
const actor = await api(`/actors/${ctx.params.id}${params}`)
riot.mount('page-actor', { actor, school })
})

async function init() {
async function init () {
page({hashbang: true})
}

Expand Down
24 changes: 24 additions & 0 deletions package.json
@@ -0,0 +1,24 @@
{
"name": "eac-client",
"version": "1.0.0",
"description": "Education Artistique et Culturelle",
"main": "index.html",
"scripts": {
"lint": "standard --fix --plugin html '**/*.html'",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/betagouv/eac.git"
},
"author": "BetaGouv",
"license": "MIT",
"bugs": {
"url": "https://github.com/betagouv/eac/issues"
},
"homepage": "https://github.com/betagouv/eac#readme",
"dependencies": {
"eslint-plugin-html": "^4.0.5",
"standard": "^11.0.1"
}
}
1 change: 1 addition & 0 deletions tags/actor-card.tag.html
Expand Up @@ -10,6 +10,7 @@ <h3>{ this.actor.name } <small>(dept { this.actor.department })</small></h3>
<a href=/actor/{ this.actor._id }></a>

<script>
/* global opts */
this.actor = opts.actor
this.maxlength = this.opts.maxlength || 150
</script>
Expand Down
18 changes: 0 additions & 18 deletions tags/checkbox.tag.html

This file was deleted.

0 comments on commit c1a87f4

Please sign in to comment.