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

Introduce code linting #1024

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# EditorConfig is awesome: http://EditorConfig.org

root = true

[*]
end_of_line = lf
insert_final_newline = false
trim_trailing_whitespace = false

[*.{js}]
insert_final_newline = false
trim_trailing_whitespace = false
indent_style = tab
indent_size = 2
19 changes: 19 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
test/sea/sea_old.js
test/mocha.js
test/expect.js
test/json2.js
test/ptsd/*
test/tmp/*

# only because of CRLF
lib/jsonp.js
lib/wsp.js
lib/http.js
lib/aws.js
test/common.js
test/old/shotgun.js
test/old/server.js
test/old/interface.js
test/bug/686.js
test/old/interface.js
test/old/shoot.js
41 changes: 21 additions & 20 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
node_modules
npm-debug.log
yarn.lock
*data.json
*data*
*.db
.idea/
*.bak
*.new
*.log
v8.json
*.DS_store
isolate*.log
.esm-cache
.sessionStorage
.localStorage
/types/**/*.ts
!/types/**/*.d.ts
/gun.ts
/temp/
node_modules
npm-debug.log
yarn.lock
*data.json
*data*
*.db
.idea/
*.bak
*.new
*.log
v8.json
*.DS_store
isolate*.log
.esm-cache
.sessionStorage
.localStorage
/types/**/*.ts
!/types/**/*.d.ts
/gun.ts
/temp/
.nyc_output/
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This btw is a prefect example of why you need linting. This file clearly had CRLF line breaks, and because I added 1 small change at the end my editor detected inconsistencies and normalized it. The .eslintignore file actually has a list of such files in the *.js realm which fail to be consistent with the rest of the project.

271 changes: 271 additions & 0 deletions lib/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,271 @@
# Carefully curated
# https://eslint.org/docs/rules/

env: { es6: true, node: true, browser: true }
parserOptions: { ecmaVersion: 2018 }

rules:
# ==> Possible Errors
for-direction: error
getter-return: error
# no-async-promise-executor: error
no-await-in-loop: error
no-compare-neg-zero: error
# no-cond-assign: error
no-console: 0
# no-constant-condition: error
no-control-regex: error
no-debugger: error
no-dupe-args: error
no-dupe-else-if: error
no-dupe-keys: error
no-duplicate-case: error
# no-empty: error
no-empty-character-class: error
no-ex-assign: error
no-extra-boolean-cast: error
# no-extra-parens: error
# no-extra-semi: error
no-func-assign: error
no-import-assign: error
# no-inner-declarations: error
no-invalid-regexp: error
no-irregular-whitespace: error
no-loss-of-precision: error
no-misleading-character-class: error
no-obj-calls: error
no-promise-executor-return: error
# no-prototype-builtins: error
no-regex-spaces: error
no-setter-return: error
no-sparse-arrays: error
no-template-curly-in-string: error
no-unexpected-multiline: error
# no-unreachable: error
no-unreachable-loop: error
no-unsafe-finally: error
no-unsafe-negation: error
no-useless-backreference: error
# require-atomic-updates: error
use-isnan: error
valid-typeof: error
# ==> Best Practices
accessor-pairs: error
# array-callback-return: error
# block-scoped-var: error
class-methods-use-this: error
# complexity: [error, 3]
# consistent-return: [error, { treatUndefinedAsUnspecified: true }]
# curly: error
# default-case: error
default-case-last: error
default-param-last: error
# dot-location: [ error, object ]
# dot-notation: error
# eqeqeq: [ error, smart ]
grouped-accessor-pairs: error
# guard-for-in: error
max-classes-per-file: error
no-alert: error
no-caller: error
no-case-declarations: error
no-constructor-return: error
no-div-regex: error
# no-else-return: error
# no-empty-function: error
no-empty-pattern: error
# no-eq-null: error
# no-eval: error
no-extra-bind: error
no-extra-label: error
no-fallthrough: error
no-floating-decimal: error
no-global-assign: error
# no-implicit-coercion: error
# no-implicit-globals: error
no-implied-eval: error
no-invalid-this: error
no-iterator: error
no-labels: error
no-lone-blocks: error
# no-loop-func: error
# no-magic-numbers: error
# no-multi-spaces: error
no-multi-str: error
no-new: error
no-new-func: error
no-new-wrappers: error
no-octal: error
no-octal-escape: error
# no-param-reassign: error
no-proto: error
# no-redeclare: error
no-restricted-properties: 0
# no-return-assign: error
no-return-await: error
no-script-url: error
no-self-assign: error
no-self-compare: error
# no-sequences: error
# no-throw-literal: error
no-unmodified-loop-condition: error
# no-unused-expressions: error
no-unused-labels: error
no-useless-call: error
no-useless-catch: error
no-useless-concat: error
# no-useless-escape: error
# no-useless-return: error
# no-void: error
no-warning-comments: 0
no-with: error
prefer-named-capture-group: error
# prefer-promise-reject-errors: error
prefer-regex-literals: error
radix: error
# require-await: error
require-unicode-regexp: 0
# vars-on-top: error
wrap-iife: [error, outside]
# yoda: error
# ==> Strict Mode
strict: 0
# ==> Variables
# init-declarations: error
no-delete-var: error
no-label-var: error
no-restricted-globals: error
# no-shadow: error
no-shadow-restricted-names: error
# no-undef: error
no-undef-init: error
# no-undefined: error
# no-unused-vars: error
# no-use-before-define: error
# ==> Stylistic Issues
# array-bracket-newline: error
array-bracket-spacing: error
# array-element-newline: error
# block-spacing: error
# brace-style: error
# camelcase: error
# capitalized-comments: error
# comma-dangle: error
# comma-spacing: error
# comma-style: error
computed-property-spacing: error
# consistent-this: error
# eol-last: error
func-call-spacing: error
# func-name-matching: error
# func-names: error
# func-style: error
# function-call-argument-newline: error
# function-paren-newline: error
id-denylist: error
# id-length: error
id-match: error
implicit-arrow-linebreak: error
# indent: error << okay wow
jsx-quotes: error
# key-spacing: error
# keyword-spacing: error
# line-comment-position: error
linebreak-style: error
# lines-around-comment: error
lines-between-class-members: 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-per-chained-call: error
no-array-constructor: error
# no-bitwise: error
# no-continue: error
# no-inline-comments: error
# no-lonely-if: error
# no-mixed-operators: error
# no-mixed-spaces-and-tabs: error
# no-multi-assign: error
# no-multiple-empty-lines: error
# no-negated-condition: error
# no-nested-ternary: error
no-new-object: error
# no-plusplus: error
no-restricted-syntax: error
# no-tabs: error
# no-ternary: error
# no-trailing-spaces: error
# no-underscore-dangle: error
no-unneeded-ternary: error
no-whitespace-before-property: error
# nonblock-statement-body-position: error
# object-curly-newline: error
# object-curly-spacing: error
# object-property-newline: error
# one-var: error
# one-var-declaration-per-line: error
# operator-assignment: error
# operator-linebreak: error
# padded-blocks: error
padding-line-between-statements: error
prefer-exponentiation-operator: error
# prefer-object-spread: error
# quote-props: error
# quotes: error
# semi: error
# semi-spacing: error
# semi-style: error
# sort-keys: error
# sort-vars: error
# space-before-blocks: error
# space-before-function-paren: error
# space-in-parens: error
# space-infix-ops: error
# space-unary-ops: error
# spaced-comment: error
switch-colon-spacing: error
template-tag-spacing: error
unicode-bom: error
wrap-regex: error
# ==> ECMAScript 6
# arrow-body-style: error
# arrow-parens: error
# arrow-spacing: error
constructor-super: error
generator-star-spacing: error
no-class-assign: error
# no-confusing-arrow: error
no-const-assign: error
no-dupe-class-members: error
no-duplicate-imports: error
no-new-symbol: error
no-restricted-exports: error
no-restricted-imports: error
no-this-before-super: error
no-useless-computed-key: error
no-useless-constructor: error
no-useless-rename: error
# no-var: error
# object-shorthand: error
# prefer-arrow-callback: error
# prefer-const: error
# prefer-destructuring: error
prefer-numeric-literals: error
# prefer-rest-params: error
prefer-spread: error
# prefer-template: error
require-yield: error
rest-spread-spacing: error
sort-imports: error
# symbol-description: error
template-curly-spacing: error
yield-star-spacing: error
10 changes: 5 additions & 5 deletions lib/monotype.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;var monotype = monotype || (function(monotype){
;var monotype = monotype || ((function(monotype){
monotype.range = function(n){
var R, s, t, n = n || 0, win = monotype.win || window, doc = win.document;
if(!arguments.length) return doc.createRange();
Expand Down Expand Up @@ -147,7 +147,7 @@
t = m.deep(n, o);
(!t.offset && !r.H.e.length) && (c += 0.1); // Same as above.
return c;
})(r.R.endContainer, r.R.endOffset);
}(r.R.endContainer, r.R.endOffset));
//console.log(r.s, r.R.startOffset, r.H.s, 'M',r.d,'E', r.H.e, r.R.endOffset, r.e);
t = r.root.text();
r.L = t.length;
Expand Down Expand Up @@ -208,8 +208,8 @@
e = p(e, r.H.e);
//console.log("START", parseInt(s.i), 'in """',(s.$[0]),'""" with hint of', r.H.s, 'from original', r.s);
//console.log("END", parseInt(e.i), 'in """',(e.$[0]),'""" hint clue of', r.H.e, 'from original', r.e);
R.setStart(s.$[0], parseInt(s.i));
R.setEnd(e.$[0], parseInt(e.i));
R.setStart(s.$[0], parseInt(s.i, 10));
R.setEnd(e.$[0], parseInt(e.i, 10));
return R;
}
r.restore = function(R){
Expand All @@ -227,7 +227,7 @@
}
return monotype.late(r,opt);
//return r;
});
}));
monotype.late = function(r,opt){
var u, m = r //monotype(r,opt)
, strhml = function(t){
Expand Down
4 changes: 2 additions & 2 deletions lib/normalize.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(function(){
((function(){

$.normalize = function(html, customOpt){
html = html || '';
Expand Down Expand Up @@ -288,4 +288,4 @@
addUnstable(a);
}
}
})();
})());
Loading