Hi Ilya, I'd suggest you learn about Node.js and CommonJS format. require is the way that modules are imported, so it looks like your code is just stubbing it out so things will work.
The "!function" is not from ESLint, that's something that someone or something added. Maybe you're using browserify? Unfortunately, you're really asking is how did this other person make ESLint work outside of Node.js, and while I can offer theories, I really can't give you a complete answer. -N On Wed, May 6, 2015 at 7:10 AM, Ilya Dachkovsky <[email protected]> wrote: > Hi Nicholas, > > Many thanks for your suggestion. > > Just as a follow up to our conversation. We did a change to eslint 0.17.0 > code by wrapping it inside a let's call it "not a function": > > !function(e){ if("object"==typeof exports&&"undefined"!=typeof > module)module.exports=e(); else if("function"==typeof > define&&define.amd)define([],e); else{var f;"undefined"!=typeof > window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof > self&&(f=self),f.eslint=e()} } (function(){var define,module,exports; return > (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof > require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var > f=new Error("Cannot find module '"+o+"'");throw > f.code="MODULE_NOT_FOUND",f}var > l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var > n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var > i=typeof require=="function"&&require;for(var > o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ > > See the full code on dropbox if you need: > https://www.dropbox.com/s/tgxi90xg2dtt09z/eslint0.17.0withnotfunctionline.txt?dl=0 > > Now it works... for the time being. Hope it will be sustainable for a long > time. > > Now, the code snipped above was simply copied from our eslint 0.9 version > which is used now. We replaced with this not a function wrapping a line > which starts with require: > > require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a= > typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i( > o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code= > "MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports, > function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return > n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r. > length;o++)s(r[o]);return s})({1:[function(require,module,exports){ > > A person who implemented the eslint version 0.9 is not responsible for the > code any more. So would you be so kind as to explain what require does at > the beginning of all the eslint.js versions? And was "!function" present at > eslint 0.9 originally? If yes, then why was it changed to "require..." and > do you think the replacement can possibly somehow detrimentally affect > ESLint's performance? > > Thank you very much indeed for your answer in advance. > > Best, > Ilya > > On Monday, May 4, 2015 at 9:00:09 PM UTC+3, Nicholas Zakas wrote: >> >> ESLint will never say "severity is not defined" (if you search the code >> base, you'll see this error message doesn't exist), so the only thing I can >> think to recommend is that your wrapper is throwing an error. >> >> ESLint is made to be used only with Node.js, so I'm afraid there's not >> much further advise I can offer. >> >> On Mon, May 4, 2015 at 6:15 AM, Ilya Dachkovsky <[email protected]> >> wrote: >> >>> Hi everyone, >>> >>> I am trying to update ESLint version for a web based IDE. Currently the >>> IDE uses ESLint version 0.9 and the upgrade is going to update it to ESLint >>> 0.17.0. But unfortunately, I stumbled upon some problems which is web IDE >>> is not being able to load rules in options menu (versions 18, 19 and >>> 20 also were tested and failed as well). And then an error appears, >>> saying "severity is not defined". This is the first update since version >>> 0.9, so I have a suspicion a lot was changed since then and there might be >>> a need to change the way default rules are configured in json file. >>> >>> Now to the explanation of what is done with ESLint. I know I should >>> build eslint.js file using npm ("npm test" in command line, I also tried to >>> run "npm run browserify" a few times, although previously it worked fine >>> without it). I also create default rules json file (if there is a need to >>> take a loot at the entire jason file with rules configuration, I can upload >>> it on dropbox later, just ask) which is used to upload rules and their >>> configurations to web IDE. The rules used in every specific version are >>> found in eslint.js file itself by searching it for "rules" and copying >>> all the rules mentioned there. >>> >>> And the json begins with the following code: >>> >>> "eslintConfig": { >>> "env" : { >>> "browser" : false, //(also tried to switch it to true out of curiosity - >>> didn't help) >>> "node" : false, >>> "amd" : false, >>> "mocha" : false >>> }, >>> // global variables with keys as names and a boolean value to determine >>> if they are assignable >>> "globals" : { >>> // CouchDB globals >>> "require" : false, >>> more globals... >>> >>> then rules and rulesExt go. >>> >>> In the latter all rules for now are switched off like this: >>> "rules": { >>> "no-alert": 0, >>> etc... >>> >>> and after that all rules are mentioned and switched off, they are defined >>> as info like that: >>> "rulesExt": { >>> "no-alert" : { >>> "severity" : "info", >>> "category" : "Stylistic Issue" >>> }, >>> more rules... >>> >>> >>> >>> Web IDE has a Java wrapper to execute ESLint without Node.js, in other >>> words in browser in our case. >>> >>> ESLint 0.9 still works perfectly with this kind of rules settings, but >>> lately all manual tests with version 17 (and 19, 20 as well) started to >>> fail with "severity is not defined" error. That is why I think the >>> problem is in json configuration file. Or, probably, I didn't build >>> eslint.js correctly. Anyway, I am not sure what exactly is wrong and will >>> be grateful for your tips and suggestions where to look for the source of >>> the problem. >>> >>> Many thanks in advance, >>> >>> Ilya >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "ESLint" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> >> >> -- >> >> ______________________________ >> Nicholas C. Zakas >> @slicknet >> >> Author, Professional JavaScript for Web Developers >> Buy it at Amazon.com: >> http://www.amazon.com/Professional-JavaScript-Developers-Nicholas-Zakas/dp/1118026691/ref=sr_1_3 >> > -- > You received this message because you are subscribed to the Google Groups > "ESLint" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- ______________________________ Nicholas C. Zakas @slicknet Author, Professional JavaScript for Web Developers Buy it at Amazon.com: http://www.amazon.com/Professional-JavaScript-Developers-Nicholas-Zakas/dp/1118026691/ref=sr_1_3 -- You received this message because you are subscribed to the Google Groups "ESLint" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
