totaljs / framework

Node.js framework
http://www.totaljs.com
Other
4.36k stars 451 forks source link

eslint errors for totaljs vars #656

Closed 211217613 closed 6 years ago

211217613 commented 6 years ago

Maybe it's not the right place for this but when using eslint and eslint style guides I get errors for:

92:5 error 'F' is not defined no-undef

190:28 error 'CONFIG' is not defined no-undef

I'm using CONFIG like this:

var version = CONFIG("version")

and I'm using F like this:

exports.install = function () {
    F.route('/', root);
    F.route('/users', handle_users, ['post']);
    F.route('/webhook', print_users, ['get']);
}
ckpiggy commented 6 years ago

Declare before you use global variables.

const CONFIG = global.CONFIG
const F = global.F
petersirka commented 6 years ago

@211217613 this is the content of my .eslintrc.js:

module.exports = {
    "env": {
        "browser": true,
        "commonjs": true,
        "es6": true
    },
    "globals": {
        "DBMS": true,
        "WEBSOCKETCLIENT": true,
        "ERROR": true,
        "FUNCTIONS": true,
        "GRAPHDB": true,
        "COMPONENT_CONFIG": true,
        "COMPONENT_EXTEND": true,
        "clearImmediate": true,
        "HASH": true,
        "$INSERT": true,
        "$UPDATE": true,
        "$SAVE": true,
        "FILESTORAGE": true,
        "TESTUSER": true,
        "TABLE": true,
        "OK": true,
        "BIND": true,
        "FAIL": true,
        "FREE": true,
        "G": true,
        "AUTH": true,
        "REQUEST": true,
        "MIDDLEWARE": true,
        "RESET": true,
        "Callback": true,
        "DEF": true,
        "WW": true,
        "WH": true,
        "NOW": true,
        "COMPILE": true,
        "framework_builders": true,
        "framework_internal": true,
        "EMPTYCONTROLLER": true,
        "framework_utils": true,
        "framework_image": true,
        "PRINTLN": true,
        "framework_nosql": true,
        "MERGE": true,
        "CORS": true,
        "MAIL": true,
        "MAP": true,
        "LOGMAIL": true,
        "CONVERT": true,
        "LOCALIZE": true,
        "FLOW": true,
        "COMPONENT": true,
        "DEFAULT": true,
        "SCROLLBARWIDTH": true,
        "DATETIME": true,
        "MONTHS": true,
        "DAYS": true,
        "process": true,
        "EMPTYOBJECT": true,
        "EMPTYARRAY": true,
        "TransformBuilder": true,
        "Pagination": true,
        "Page": true,
        "REWRITE": true,
        "user": true,
        "PING": true,
        "FILE": true,
        "GROUP": true,
        "URLBuilder": true,
        "UrlBuilder": true,
        "SchemaBuilder": true,
        "Image": true,
        "Builders": true,
        "U": true,
        "Mail": true,
        "MAIN": true,
        "common": true,
        "WTF": true,
        "SOURCE": true,
        "INCLUDE": true,
        "MODULE": true,
        "NOSQL": true,
        "NOBIN": true,
        "NOCOUNTER": true,
        "NOSQLMEMORY": true,
        "NOMEM": true,
        "DATABASE": true,
        "DB": true,
        "CONFIG": true,
        "INSTALL": true,
        "UNINSTALL": true,
        "RESOURCE": true,
        "TRANSLATOR": true,
        "TRANSLATE": true,
        "VIRTUALIZE": true,
        "LOGGER": true,
        "MODEL": true,
        "GETSCHEMA": true,
        "CREATE": true,
        "UID": true,
        "TRANSFORM": true,
        "MAKE": true,
        "SINGLETON": true,
        "NEWTRANSFORM": true,
        "NEWSCHEMA": true,
        "EACHSCHEMA": true,
        "FUNCTION": true,
        "ROUTING": true,
        "SCHEDULE": true,
        "OBSOLETE": true,
        "DEBUG": true,
        "TEST": true,
        "EMIT": true,
        "ON": true,
        "OFF": true,
        "$QUERY": true,
        "$GET": true,
        "$CREATE": true,
        "$WORKFLOW": true,
        "$TRANSFORM": true,
        "$OPERATION": true,
        "$MAKE": true,
        "setImmediate": true,
        "Buffer": true,
        "NOOP": true,
        "RELEASE": true,
        "is_client": true,
        "is_server": true,
        "F": true,
        "framework": true,
        "Controller": true,
        "setTimeout2": true,
        "clearTimeout2": true,
        "isomorphic": true,
        "COOKIES": true,
        "I": true,
        "UPTODATE": true,
        "WEBSOCKET": true,
        "WARN": true,
        "LOG": true,
        "NEWOPERATION": true,
        "OPERATION": true,
        "isMOBILE": true,
        "$$$": true,
        "SET": true,
        "GET": true,
        "EXEC": true,
        "jC": true,
        "NAVIGATION": true,
        "NAV": true,
        "ENV": true,
        "$": true,
        "KEYPRESS": true,
        "FN": true,
        "Tangular": true,
        "Ta": true,
        "MAN": true,
        "FIND": true,
        "SETTER": true,
        "IMPORT": true,
        "EVALUATE": true,
        "NOTMODIFIED": true,
        "WIDTH": true,
        "d3": true,
        "GUID": true,
        "BLOCKED": true,
        "CodeMirror": true,
        "jQuery": true,
        "MAKE": true,
        "CACHE": true,
        "UPLOAD": true,
        "AJAX": true,
        "AJAXCACHE": true,
        "WAIT": true,
        "ROUTE": true,
        "CONTROLLER": true,
        "SUCCESS": true,
        "REDIRECT": true,
        "CACHEPATH": true,
        "marked": true,
        "CLONE": true,
        "STRINGIFY": true,
        "PARSE": true,
        "hljs": true,
        "UPDATE": true,
        "WATCH": true,
        "SCRIPT": true,
        "RESTBuilder": true,
        "clearSchedule": true,
        "TRY": true,
        "CLEANUP": true,
        "ErrorBuilder": true
    },
    "extends": "eslint:recommended",
    "rules": {
        "indent": [
            "error",
            "tab",
            { "SwitchCase": 1 }
        ],
        "linebreak-style": [
            "error",
            "unix"
        ],
        "no-empty": "off",
        "no-redeclare": "off",
        "no-console": "off",
        "no-constant-condition": "off",
        "quotes": [
            "error",
            "single"
        ],
        "semi": [
            "error",
            "always"
        ]
    }
};

So you have several ways how to fix it:


@ckpiggy thank you, this will work too.