系统&环境要求

  • sublime3
  • win7 & OSX10
  • node
  • ruby
  • sublime3

脚本安装配置

按下 ctrl+` 复制粘贴以下代码执行,直到弹出【安装成功】弹窗

1
2
pl="SublimeLinter,SublimeLinter-jscs,SublimeLinter-jshint,SublimeLinter-csslint,SublimeLinter-contrib-scss-lint,Emmet,EJS,SCSS,CSScomb,JsFormat,DocBlockr,SnippetMaker,BracketHighlighter,SassBeautify,SideBarEnhancements,CSS Snippets,JavaScript & NodeJS Snippets,TortoiseSVN";import webbrowser,urllib.request,os;jcp=os.path.join(sublime.packages_path(),"User",".jshintrc");scssp=os.path.join(sublime.packages_path(),"User",".scss-lint.yml");jscsp=os.path.join(sublime.packages_path(),"User",".jscsrc");sm={"Preferences":{"translate_tabs_to_spaces":True,"word_wrap":True,"wrap_width":120,"tab_size":4,"default_line_ending":"unix"},"SublimeLinter":{"user":{"gutter_theme":"Packages/SublimeLinter/gutter-themes/Blueberry/round/Blueberry - round.gutter-theme","lint_mode":"manual","linters":{"csslint":{"@disable":False,"args":[],"errors":"","excludes":[],"ignore":"box-model,adjoining-classes,box-sizing,compatible-vendor-prefixes,gradients,text-indent,fallback-colors,star-property-hack,underscore-property-hack,bulletproof-font-face,font-faces,import,regex-selectors,universal-selector,unqualified-attributes,overqualified-elements,duplicate-background-images,floats,font-sizes,ids,important,outline-none,qualified-headings,unique-headings","warnings":""},"jscs":{"@disable":False,"args":["--config",jscsp],"excludes":[]},"scss":{"@disable":False,"args":["--config",scssp],"exclude-linter":"","include-linter":"","excludes":[]},"jshint":{"@disable":False,"args":["--config",jcp],"excludes":[]}},"mark_style":"outline"}},"JsFormat":{"indent_size":4,"indent_char":" ","eol":"\n","indent_level":0,"indent_with_tabs":False,"preserve_newlines":True,"max_preserve_newlines":10,"jslint_happy":False,"space_after_anon_function":False,"brace_style":"collapse","keep_array_indentation":False,"keep_function_indentation":False,"space_before_conditional":True,"break_chained_methods":False,"eval_code":False,"unescape_strings":False,"wrap_line_length":0,"wrap_attributes":"auto","wrap_attributes_indent_size":4,"end_with_newline":True},"CSScomb":{"config":{"remove-empty-rulesets":True,"always-semicolon":True,"color-case":"lower","block-indent":"    ","color-shorthand":True,"element-case":"lower","eof-newline":True,"leading-zero":False,"quotes":"double","sort-order-fallback":"abc","space-before-colon":"","space-after-colon":" ","space-before-combinator":" ","space-after-combinator":" ","space-between-declarations":"\n","space-before-opening-brace":" ","space-after-opening-brace":"\n","space-after-selector-delimiter":"\n","space-before-selector-delimiter":"","space-before-closing-brace":"\n","strip-spaces":True,"tab-size":True,"unitless-zero":True,"vendor-prefix-align":True,"sort-order":[["display","visibility","float","clear","overflow","overflow-x","overflow-y","clip","zoom"],["table-layout","empty-cells","caption-side","border-spacing","border-collapse","list-style","list-style-position","list-style-type","list-style-image"],["-webkit-box-orient","-webkit-box-direction","-webkit-box-decoration-break","-webkit-box-pack","-webkit-box-align","-webkit-box-flex"],["position","top","right","bottom","left","z-index"],["margin","margin-top","margin-right","margin-bottom","margin-left","-webkit-box-sizing","-moz-box-sizing","box-sizing","border","border-width","border-style","border-color","border-top","border-top-width","border-top-style","border-top-color","border-right","border-right-width","border-right-style","border-right-color","border-bottom","border-bottom-width","border-bottom-style","border-bottom-color","border-left","border-left-width","border-left-style","border-left-color","-webkit-border-radius","-moz-border-radius","border-radius","-webkit-border-top-left-radius","-moz-border-radius-topleft","border-top-left-radius","-webkit-border-top-right-radius","-moz-border-radius-topright","border-top-right-radius","-webkit-border-bottom-right-radius","-moz-border-radius-bottomright","border-bottom-right-radius","-webkit-border-bottom-left-radius","-moz-border-radius-bottomleft","border-bottom-left-radius","-webkit-border-image","-moz-border-image","-o-border-image","border-image","-webkit-border-image-source","-moz-border-image-source","-o-border-image-source","border-image-source","-webkit-border-image-slice","-moz-border-image-slice","-o-border-image-slice","border-image-slice","-webkit-border-image-width","-moz-border-image-width","-o-border-image-width","border-image-width","-webkit-border-image-outset","-moz-border-image-outset","-o-border-image-outset","border-image-outset","-webkit-border-image-repeat","-moz-border-image-repeat","-o-border-image-repeat","border-image-repeat","padding","padding-top","padding-right","padding-bottom","padding-left","width","min-width","max-width","height","min-height","max-height"],["font","font-family","font-size","font-weight","font-style","font-variant","font-size-adjust","font-stretch","font-effect","font-emphasize","font-emphasize-position","font-emphasize-style","font-smooth","line-height","text-align","-webkit-text-align-last","-moz-text-align-last","-ms-text-align-last","text-align-last","vertical-align","white-space","text-decoration","text-emphasis","text-emphasis-color","text-emphasis-style","text-emphasis-position","text-indent","-ms-text-justify","text-justify","letter-spacing","word-spacing","-ms-writing-mode","text-outline","text-transform","text-wrap","-ms-text-overflow","text-overflow","text-overflow-ellipsis","text-overflow-mode","-ms-word-wrap","word-wrap","-ms-word-break","word-break"],["color","background","filter:progid:DXImageTransform.Microsoft.AlphaImageLoader","background-color","background-image","background-repeat","background-attachment","background-position","-ms-background-position-x","background-position-x","-ms-background-position-y","background-position-y","-webkit-background-clip","-moz-background-clip","background-clip","background-origin","-webkit-background-size","-moz-background-size","-o-background-size","background-size"],["outline","outline-width","outline-style","outline-color","outline-offset","opacity","filter:progid:DXImageTransform.Microsoft.Alpha(Opacity","-ms-filter:\\'progid:DXImageTransform.Microsoft.Alpha","-ms-interpolation-mode","-webkit-box-shadow","-moz-box-shadow","box-shadow","filter:progid:DXImageTransform.Microsoft.gradient","-ms-filter:\\'progid:DXImageTransform.Microsoft.gradient","text-shadow"],["-webkit-transition","-moz-transition","-ms-transition","-o-transition","transition","-webkit-transition-delay","-moz-transition-delay","-ms-transition-delay","-o-transition-delay","transition-delay","-webkit-transition-timing-function","-moz-transition-timing-function","-ms-transition-timing-function","-o-transition-timing-function","transition-timing-function","-webkit-transition-duration","-moz-transition-duration","-ms-transition-duration","-o-transition-duration","transition-duration","-webkit-transition-property","-moz-transition-property","-ms-transition-property","-o-transition-property","transition-property","-webkit-transform","-moz-transform","-ms-transform","-o-transform","transform","-webkit-transform-origin","-moz-transform-origin","-ms-transform-origin","-o-transform-origin","transform-origin","-webkit-animation","-moz-animation","-ms-animation","-o-animation","animation","-webkit-animation-name","-moz-animation-name","-ms-animation-name","-o-animation-name","animation-name","-webkit-animation-duration","-moz-animation-duration","-ms-animation-duration","-o-animation-duration","animation-duration","-webkit-animation-play-state","-moz-animation-play-state","-ms-animation-play-state","-o-animation-play-state","animation-play-state","-webkit-animation-timing-function","-moz-animation-timing-function","-ms-animation-timing-function","-o-animation-timing-function","animation-timing-function","-webkit-animation-delay","-moz-animation-delay","-ms-animation-delay","-o-animation-delay","animation-delay","-webkit-animation-iteration-count","-moz-animation-iteration-count","-ms-animation-iteration-count","-o-animation-iteration-count","animation-iteration-count","-webkit-animation-direction","-moz-animation-direction","-ms-animation-direction","-o-animation-direction","animation-direction"],["content","quotes","counter-reset","counter-increment","resize","cursor","-webkit-user-select","-moz-user-select","-ms-user-select","user-select","nav-index","nav-up","nav-right","nav-down","nav-left","-moz-tab-size","-o-tab-size","tab-size","-webkit-hyphens","-moz-hyphens","hyphens","pointer-events"]]}}};c1p=None;c1cb=None;arr2=None;arr3=None;pf='Package Control.sublime-package';ipp=sublime.installed_packages_path();pp=sublime.packages_path();arr=[v for v in pl.split(',') if not os.path.exists(os.path.join(ipp,v+'.sublime-package')) and not os.path.exists(os.path.join(pp,v))];pl=','.join(arr);c1=compile('global c1p;global c1cb;cip=os.path.join(ipp,c1p);cip2=os.path.join(pp,c1p.split(".")[0]);sublime.set_timeout(lambda:exec(c1cb),10000) if os.path.exists(cip) or os.path.exists(cip2) else sublime.set_timeout(lambda:exec(c1), 3000);','','exec');c11=compile('global arr;global arr2;global arr3;arr2=[print("=============================================================>",v,"安装成功!") or v for v in arr if os.path.exists(os.path.join(ipp,v+".sublime-package")) or os.path.exists(os.path.join(pp,v))];arr3=[vv for vv in arr if vv not in arr2];arr=arr3;sublime.set_timeout(lambda:exec(c11),1000) if len(arr)>0 else None;','','exec');c2=compile('global c1p;global c1cb;window.run_command("advanced_install_package",{"packages":pl}) if len(pl)>0 else None;pla=pl.split(",");c1p=pla[len(pla)-1]+".sublime-package";c1cb=c3;exec(c1);exec(c11);','','exec');c3=compile('[exec(c4,{"pn":name,"sv":value,"sublime":sublime}) for (name,value) in sm.items()];sublime.set_timeout(lambda:webbrowser.open_new_tab("http://imweb.github.io/CodeGuide/") if sublime.ok_cancel_dialog("安装成功!", "查看规范") else None,2000);','','exec');c4=compile('s=sublime.load_settings(pn+".sublime-settings");[s.set(k, v) for (k,v) in sv.items()];sublime.save_settings(pn+".sublime-settings");','','exec');c=compile('global c1p;global c1cb;os.system("gem install scss_lint");print("=============================================================> gem install scss_lint 安装结束!");os.system("npm install -g jscs");print("=============================================================> npm install -g jscs 安装结束!");os.system("npm install -g jshint");print("=============================================================> npm install -g jshint 安装结束!");os.system("npm install -g csslint");print("=============================================================> npm install -g csslint 安装结束!");c1p=pf;c1cb=c2;exec(c1);jc=\'{"globals":{"$":true,"jQuery":true,"exports":true,"module":true,"define":true,"require":true,"it":true,"before":true,"describe":true,"beforeEach":true,"afterEach":true,"__inline":true,"__uri":true},"nomen":false,"onevar":false,"passfail":false,"white":false,"maxerr":50,"browser":true,"devel":true,"nonstandard":true,"bitwise":true,"camelcase":false,"curly":false,"eqeqeq":false,"forin":false,"immed":true,"latedef":false,"newcap":true,"noarg":true,"noempty":false,"nonew":true,"plusplus":false,"regexp":false,"undef":true,"unused":false,"strict":false,"trailing":false,"quotmark":"false","asi":false,"boss":false,"debug":false,"eqnull":false,"es5":false,"esnext":true,"evil":true,"expr":true,"funcscope":false,"globalstrict":false,"iterator":false,"lastsemic":false,"laxbreak":true,"laxcomma":false,"loopfunc":true,"multistr":true,"proto":false,"onecase":true,"regexdash":false,"scripturl":true,"smarttabs":false,"shadow":false,"sub":true,"supernew":true,"validthis":false,"-W065":false,"-W069":false}\';open(jcp,"w").write(jc);jscsc=\'{"disallowEmptyBlocks":true,"disallowKeywordsOnNewLine":["else","catch","finally"],"disallowMixedSpacesAndTabs":true,"disallowMultipleSpaces":true,"disallowNamedUnassignedFunctions":true,"disallowNewlineBeforeBlockStatements":true,"disallowQuotedKeysInObjects":true,"disallowSpaceAfterObjectKeys":true,"disallowSpaceAfterPrefixUnaryOperators":true,"disallowSpaceBeforePostfixUnaryOperators":true,"disallowSpacesInCallExpression":true,"disallowSpacesInFunction":{"beforeOpeningRoundBrace":true},"disallowSpacesInsideArrayBrackets":true,"disallowSpacesInsideBrackets":true,"disallowSpacesInsideObjectBrackets":true,"disallowSpacesInsideParentheses":true,"disallowTrailingComma":true,"disallowTrailingWhitespace":true,"requireBlocksOnNewline":true,"requireCamelCaseOrUpperCaseIdentifiers":"ignoreProperties","requireCapitalizedConstructors":true,"requireCommaBeforeLineBreak":true,"requireCurlyBraces":["if","else","for","while","do","switch","try","catch","finally","with"],"requireDollarBeforejQueryAssignment":true,"requireLineBreakAfterVariableAssignment":true,"requireLineFeedAtFileEnd":true,"requireMultipleVarDecl":null,"requireOperatorBeforeLineBreak":true,"requirePaddingNewLineAfterVariableDeclaration":true,"requirePaddingNewLinesAfterBlocks":{"allExcept":["inCallExpressions","inArrayExpressions","inProperties"]},"requirePaddingNewLinesBeforeLineComments":{"allExcept":"firstAfterCurly"},"requirePaddingNewLinesInObjects":true,"requireParenthesesAroundIIFE":true,"requireSemicolons":true,"requireSpaceAfterBinaryOperators":true,"requireSpaceAfterKeywords":["if","else","for","while","do","switch","case","try","catch","finally","with","return","typeof"],"requireSpaceAfterLineComment":true,"requireSpaceBeforeBinaryOperators":true,"requireSpaceBeforeBlockStatements":true,"requireSpaceBeforeKeywords":["else","while","catch","finally"],"requireSpaceBeforeObjectValues":true,"requireSpaceBetweenArguments":true,"requireSpacesInConditionalExpression":true,"requireSpacesInForStatement":true,"requireSpacesInFunction":{"beforeOpeningCurlyBrace":true},"safeContextKeyword":["_this","that","self","me"],"validateIndentation":4,"validateLineBreaks":"LF","disallowMultipleLineStrings":true,"disallowMultipleVarDecl":false,"validateParameterSeparator":", ","validateQuoteMarks":"\\\'"}\';open(jscsp,"w").write(jscsc);scssc=\'scss_files: "**/*.scss"\\n\\nlinters:\\n BangFormat:\\n enabled: true\\n space_before_bang: true\\n space_after_bang: false\\n\\n BemDepth:\\n enabled: false\\n max_elements: 1\\n\\n BorderZero:\\n enabled: true\\n convention: zero\\n\\n ColorKeyword:\\n enabled: false\\n\\n ColorVariable:\\n enabled: false\\n\\n Comment:\\n enabled: false\\n\\n DebugStatement:\\n enabled: true\\n\\n DeclarationOrder:\\n enabled: true\\n\\n DuplicateProperty:\\n enabled: false\\n\\n ElsePlacement:\\n enabled: true\\n style: same_line\\n\\n EmptyLineBetweenBlocks:\\n enabled: false\\n ignore_single_line_blocks: false\\n\\n EmptyRule:\\n enabled: true\\n\\n FinalNewline:\\n enabled: false\\n present: true\\n\\n HexLength:\\n enabled: true\\n style: short\\n\\n HexNotation:\\n enabled: true\\n style: lowercase\\n\\n HexValidation:\\n enabled: true\\n\\n IdSelector:\\n enabled: false\\n\\n ImportantRule:\\n enabled: false\\n\\n ImportPath:\\n enabled: true\\n    leading_underscore: false\\n filename_extension: false\\n\\n Indentation:\\n enabled: false\\n allow_non_nested_indentation: false\\n character: space\\n width: 4\\n\\n LeadingZero:\\n enabled: true\\n style: exclude_zero\\n\\n MergeableSelector:\\n enabled: true\\n force_nesting: false\\n\\n NameFormat:\\n enabled: true\\n allow_leading_underscore: false\\n convention: hyphenated_lowercase\\n\\n NestingDepth:\\n enabled: false\\n max_depth: 5\\n\\n PlaceholderInExtend:\\n enabled: true\\n\\n PropertyCount:\\n enabled: false\\n include_nested: false\\n max_properties: 10\\n\\n PropertyUnits:\\n enabled: true\\n global: [\\n \\\'ch\\\',\\\'em\\\',\\\'ex\\\',\\\'rem\\\',\\n \\\'cm\\\',\\\'in\\\',\\\'mm\\\',\\\'pc\\\',\\\'pt\\\',\\\'px\\\',\\\'q\\\',\\n \\\'vh\\\',\\\'vw\\\',\\\'vmin\\\',\\\'vmax\\\',\\n \\\'deg\\\',\\\'grad\\\',\\\'rad\\\',\\\'turn\\\',\\n \\\'ms\\\',\\\'s\\\',\\n \\\'Hz\\\',\\\'kHz\\\',\\n \\\'dpi\\\',\\\'dpcm\\\',\\\'dppx\\\',\\n \\\'%\\\']\\n properties: {}\\n\\n PropertySortOrder:\\n enabled: false\\n ignore_unspecified: false\\n min_properties: 2\\n separate_groups: true\\n\\n PropertySpelling:\\n enabled: true\\n extra_properties: []\\n\\n QualifyingElement:\\n enabled: false\\n allow_element_with_attribute: false\\n allow_element_with_class: false\\n allow_element_with_id: false\\n\\n SelectorDepth:\\n enabled: false\\n max_depth: 4\\n\\n SelectorFormat:\\n enabled: true\\n convention: hyphenated_BEM\\n ignored_types: [\\\'id\\\']\\n\\n Shorthand:\\n enabled: true\\n allowed_shorthands: [1,2,3]\\n\\n SingleLinePerProperty:\\n enabled: true\\n allow_single_line_rule_sets: false\\n\\n SingleLinePerSelector:\\n enabled: true\\n\\n SpaceAfterComma:\\n enabled: true\\n\\n SpaceAfterPropertyColon:\\n enabled: true\\n style: at_least_one_space\\n\\n SpaceAfterPropertyName:\\n enabled: true\\n\\n SpaceBeforeBrace:\\n enabled: true\\n style: space\\n allow_single_line_padding: false\\n\\n SpaceBetweenParens:\\n enabled: true\\n spaces: 0\\n\\n StringQuotes:\\n enabled: true\\n style: double_quotes\\n\\n TrailingSemicolon:\\n enabled: true\\n\\n TrailingZero:\\n enabled: true\\n\\n UnnecessaryMantissa:\\n enabled: true\\n\\n UnnecessaryParentReference:\\n enabled: true\\n\\n UrlFormat:\\n enabled: false\\n\\n UrlQuotes:\\n enabled: true\\n\\n VariableForProperty:\\n enabled: false\\n properties: []\\n\\n VendorPrefix:\\n enabled: false\\n identifier_list: base\\n additional_identifiers: []\\n excluded_identifiers: []\\n\\n ZeroUnit:\\n enabled: true\\n\\n Compass::*:\\n enabled: false\';open(scssp,"w").write(scssc);','','exec');ci=compile('urllib.request.install_opener(urllib.request.build_opener(urllib.request.ProxyHandler()));by=urllib.request.urlopen("http://packagecontrol.io/"+pf.replace(" ", "%20")).read();open(os.path.join(ipp,pf),"wb").write(by);print("=============================================================> package control 安装成功!");exec(c);','','exec');cc=compile('print("=============================================================> 开始安装...");exec(c) if os.path.exists(os.path.join(ipp,pf)) else exec(ci);','','exec');sublime.message_dialog("Please use sublime text 3!") if int(sublime.version()) < 3000 else exec(cc)

备注 脚本中最前面的pl参数就是会安装的package control插件,可以根据需要增删插件,注意要区分大小写 脚本中预安装的插件列表

  • SublimeLinter
  • SublimeLinter-jscs
  • SublimeLinter-jshint
  • SublimeLinter-csslint
  • SublimeLinter-contrib-scss-lint
  • JSFormat
  • CSScomb
  • Emmet
  • EJS
  • SCSS
  • DocBlockr
  • SnippetMaker
  • BracketHighlighter
  • SassBeautify
  • SideBarEnhancements
  • CSS Snippets
  • JavaScript & NodeJS Snippets
  • TortoiseSVN
  • 配置文件列表
  • JSCS 配置文件
  • JSHint 配置文件

注意:全局变量需要手动加到配置文件的globals属性里,例: {“globals”: {“ImageHandle”: true}} CSSLint 配置文件 SCSS-Lint 配置文件

来源: http://imweb.github.io/CodeGuide/#check-sublime3