11import MatreshkaObject from 'matreshka/object' ;
2+ import calc from 'matreshka/calc' ;
23import lint from './lint' ;
34import { setParser } from './lint/parser' ;
45import Environments from './environments' ;
@@ -11,8 +12,18 @@ module.exports = new class Application extends MatreshkaObject {
1112 constructor ( ) {
1213 super ( {
1314 env : { } ,
14- rules : { }
15+ rules : { } ,
16+ parserOptions : {
17+ ecmaVersion : 2017 ,
18+ ecmaFeatures : {
19+ experimentalObjectRestSpread : true
20+ }
21+ }
1522 } )
23+ . set ( {
24+ configName : localStorage . eslintio ? '' : 'airbnb'
25+ } )
26+ . setData ( JSON . parse ( localStorage . eslintio || '{}' ) )
1627 . bindNode ( {
1728 sandbox : 'form' ,
1829 configName : {
@@ -40,7 +51,8 @@ module.exports = new class Application extends MatreshkaObject {
4051 } )
4152 } ,
4253 parserName : ':sandbox .parser-name' ,
43- useRecommended : ':sandbox .use-recommended'
54+ useRecommended : ':sandbox .use-recommended' ,
55+ modulesFeature : ':sandbox .modules-feature'
4456 } )
4557 . instantiate ( {
4658 env : Environments ,
@@ -70,6 +82,8 @@ module.exports = new class Application extends MatreshkaObject {
7082 const results = lint ( this . code , this . toJSON ( ) ) ;
7183
7284 this . set ( { results } ) ;
85+
86+ localStorage . eslintio = JSON . stringify ( this ) ;
7387 } ,
7488 'change:parserName' : ( ) => setParser ( this . parserName ) ,
7589 'rules@rulechange' : ( ) => {
@@ -82,5 +96,17 @@ module.exports = new class Application extends MatreshkaObject {
8296 }
8397 }
8498 } ) ;
99+
100+ calc ( this , 'modulesFeature' , {
101+ object : this . parserOptions ,
102+ key : 'sourceType'
103+ } , sourceType => sourceType === 'module' ) ;
104+
105+ calc ( this . parserOptions , 'sourceType' , {
106+ object : this ,
107+ key : 'modulesFeature'
108+ } , modulesFeature => modulesFeature ? 'module' : 'script' ) ;
109+
110+
85111 }
86112} ( ) ;
0 commit comments