npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

fis-lint-myeslint

v1.0.1

Published

a fis3 lint for js

Downloads

5

Readme

Usage

1、使用fis3配置,fis-conf.js


fis.match( '*.js', {
  //添加eslint
  lint: fis.plugin('myeslint', {
    "formatter": require('eslint-friendly-formatter'),
    eslintConfig: {
        "useFile": true,
        "envs": ["browser", "node", 'es6'],
        "useEslintrc": true,
        "ignoreFiles": ["fis-conf.js", 'lib/**/*.js', 'node_modules/**/*.js'],
        "extends": "standard",
        "globals": [
          "__inline",
          "_",
          "__uri",
          "__RESOURCE_MAP__",
          "$",
          "jQuery",
          "zepto",
          "fis"
        ],
        "rules": {
            // 箭头函数,不提示
            "arrow-parens": 0,
            // 缩进,使用tab键,请设置编辑器右下角的Spaces,设置为Spaces:4.
            "indent": [0, "tab", {
                "SwitchCase": 4,
                "ArrayExpression": 1,
                "ObjectExpression": 1
            }],
            "semi": [1, "always"],//分号
            "keyword-spacing": 0,//关键词空格
            "space-before-blocks": 0,//块前面加空格
            "space-before-function-paren": 0,//函数括号加空格
            "space-in-parens": 0,//括号加空格
            "spaced-comment": 0,//注释前加空格
            "no-var": 0,//不使用var
            "no-loop-func": 2,//循环定义函数
            "no-magic-numbers": 2,//魔鬼数字,暂时提醒?在使用数组的splice时可能会提醒
            "no-unused-vars": 2,//未使用的变量
            "no-use-before-define": 2,//使用前未定义
            "no-undef": 2,//使用未定义的变量
            "no-mixed-spaces-and-tabs": [1, "smart-tabs"],//空格与tab共存
            "brace-style": [1, "1tbs", { "allowSingleLine": true }],
            "curly": [2, "all"],//“{”需要分行,所有的必须,如if、while等,必须带{}
            "no-restricted-globals": 1,//不允许定义全局变量
            "no-global-assign": 2, //全局变量不允许修改
            "quotes": 0,//引号
            "no-console": 1, //不允许使用console
            // 全等
            "eqeqeq": [2, "always", {"null": "ignore"}],
            "no-tabs": 1,//使用tab
            // //在条件语句中不要使用赋值语句
            "no-cond-assign": 2,
            //const申明的变量禁止修改
            "no-const-assign": 2,
            //函数参数禁止重名
            "no-dupe-args": 2,
            //class中的成员禁止重名
            "no-dupe-class-members": 2,
            //在对象字面量中,禁止使用重复的key
            "no-dupe-keys": 2,
            //在switch语句中禁止重复的case
            "no-duplicate-case": 2,
            //禁止使用不匹配任何字符串的正则表达式
            "no-empty-character-class": 2,
            //在一个本来就会自动转化为布尔值的上下文中就没必要再使用!! 进行强制转化了。
            "no-extra-boolean-cast": 1,
            // 尾部逗号
            "comma-dangle": 2,
            // 关键字加空格
            "key-spacing": 1,
            // 空行
            "no-trailing-spaces": 0,
            // 
            "eol-last": 0,
            // 不允许尾部空格
            "no-trailing-spaces": 0,
            //这条规则,简单来说就是在case语句中尽量加break,避免不必要的fallthrough错误,如果需要fall through,那么看官网。
            "no-fallthrough": 1,
            //简单来说不要写这样的数字.1 1.。应该写全,1.1 1.0 .
            "no-floating-decimal": 2,
            //该规则保证了不使用new Function(); 语句。
            "no-new-func": 2,
            //不要通过new Object(),来定义对象
            "no-new-object": 2,    
            //当定义字符串、数字、布尔值就不要使用构造函数了,String、Number、Boolean
            "no-new-wrappers": 2,
            //禁止无意得把全局对象当函数调用了,比如下面写法错误的:Math(), JSON()
            "no-obj-calls": 2,
            //禁止把require方法和new操作符一起使用。
            "no-new-require": 2,
            //不要重复申明一个变量
            "no-redeclare": 2,
            //操作符前后需要加空格
            "space-infix-ops": 2,
            //不要和自身作比较
            "no-self-compare": 2,
            //禁止对一些关键字或者保留字进行赋值操作,比如NaN、Infinity、undefined、eval、arguments等。
            "no-shadow-restricted-names": 2,
            //没有执行不到的代码
            "no-unreachable": 2,
            //在使用parseInt() 方法时,需要传递第二个参数,来帮助解析,告诉方法解析成多少进制。
            "radix": 2,
            // 使用isNaN判断NaN
            "use-isnan": 2,
            //在使用typeof操作符时,作比较的字符串必须是合法字符串eg:'string' 'object'
            "valid-typeof": 2,
            //立即执行函数需要用圆括号包围
            "wrap-iife": [2, "any"],
            // 添加空行
            "padded-blocks": 0,
            // 多个空行
            "no-multiple-empty-lines": 0,
            // =号加空格
            "space-infix-ops": 2,
            // allow debugger during development
            'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
        }
    }
  }),
  // optimizer: fis.plugin( 'uglify-js' ),
  // parser: fis.plugin( 'babel' )
} );

fis.media( 'dev' )
  .match( '*.js', {
    optimizer: null
  } )
  .match( '*', {
    useHash: false,
    relative: true,
    deploy: [ fis.plugin( 'local-deliver', {
      to: './output'
    } ) ]
  } )

2、使用.eslintrc.js或者.eslintrc.*或者package.json的形式配置,不指定fis-conf.js中的options.eslintConfig选项即可。

fis.match( '*.js', {
  //添加eslint
  lint: fis.plugin('myeslint', {
    "formatter": require('eslint-friendly-formatter')
  })
});
fis.media( 'dev' )
.match( '*.js', {
optimizer: null
} )
.match( '*', {
    useHash: false,
    relative: true,
    deploy: [ fis.plugin( 'local-deliver', {
        to: './output'
    } ) ]
} )

在项目根目录下创建一个文件.eslintrc.js

// http://eslint.org/docs/user-guide/configuring

module.exports = {
    root: true,
    parser: 'babel-eslint',
    parserOptions: {
        sourceType: 'module'
    },
    env: {
        browser: true,
    },
    // 定义全局变量
    globals: {
        "$": true,
        "jQuery": true,
        "zepto": true,
        "qs": true,
        "echarts": true,
        "moment": true
    },
    // https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style
    extends: 'standard',
    // required to lint *.vue files
    plugins: [
    'html'
    ],
    // add your custom rules here
    'rules': {
        // 箭头函数,不提示
        "arrow-parens": 0,
        // 缩进,使用tab键,请设置编辑器右下角的Spaces,设置为Spaces:4.
        "indent": [0, "tab", {
            "SwitchCase": 4,
            "ArrayExpression": 1,
            "ObjectExpression": 1
        }],
        "semi": [1, "always"],//分号
        "keyword-spacing": 0,//关键词空格
        "space-before-blocks": 0,//块前面加空格
        "space-before-function-paren": 0,//函数括号加空格
        "space-in-parens": 0,//括号加空格
        "spaced-comment": 0,//注释前加空格
        "no-var": 0,//不使用var
        "no-loop-func": 1,//循环定义函数
        "no-magic-numbers": 0,//魔鬼数字,暂时提醒?在使用数组的splice时可能会提醒
        "no-unused-vars": 1,//未使用的变量
        "no-use-before-define": "warn",//使用前未定义
        "no-undef": 1,//使用未定义的变量
        "no-mixed-spaces-and-tabs": [0, "smart-tabs"],//空格与tab共存
        "brace-style": [1, "1tbs", { "allowSingleLine": true }],
        "curly": [1, "all"],//“{”需要分行,所有的必须,如if、while等,必须带{}
        "no-restricted-globals": 1,//不允许定义全局变量
        "no-global-assign": 1, //全局变量不允许修改
        "quotes": 0,//引号
        "no-console": 0, //不允许使用console
        // 全等
        "eqeqeq": [0, "always", {"null": "ignore"}],
        "no-tabs": 0,//使用tab
        // //在条件语句中不要使用赋值语句
        "no-cond-assign": 1,
        //const申明的变量禁止修改
        "no-const-assign": 1,
        //函数参数禁止重名
        "no-dupe-args": 1,
        //class中的成员禁止重名
        "no-dupe-class-members": 1,
        //在对象字面量中,禁止使用重复的key
        "no-dupe-keys": 1,
        //在switch语句中禁止重复的case
        "no-duplicate-case": 1,
        //禁止使用不匹配任何字符串的正则表达式
        "no-empty-character-class": 1,
        //在一个本来就会自动转化为布尔值的上下文中就没必要再使用!! 进行强制转化了。
        "no-extra-boolean-cast": 1,
        // 尾部逗号
        "comma-dangle": 0,
        // 
        "key-spacing": 0,
        // 空行
        "no-trailing-spaces": 0,
        // 
        "eol-last": 0,
        // 不允许尾部空格
        "no-trailing-spaces": 0,
        //这条规则,简单来说就是在case语句中尽量加break,避免不必要的fallthrough错误,如果需要fall through,那么看官网。
        "no-fallthrough": 1,
        //简单来说不要写这样的数字.1 1.。应该写全,1.1 1.0 .
        "no-floating-decimal": 1,
        //该规则保证了不使用new Function(); 语句。
        "no-new-func": 1,
        //不要通过new Object(),来定义对象
        "no-new-object": 1,    
        //当定义字符串、数字、布尔值就不要使用构造函数了,String、Number、Boolean
        "no-new-wrappers": 1,
        //禁止无意得把全局对象当函数调用了,比如下面写法错误的:Math(), JSON()
        "no-obj-calls": 1,
        //禁止把require方法和new操作符一起使用。
        "no-new-require": 1,
        //不要重复申明一个变量
        "no-redeclare": 1,
        //操作符前后需要加空格
        "space-infix-ops": 1,
        //不要和自身作比较
        "no-self-compare": 1,
        //禁止对一些关键字或者保留字进行赋值操作,比如NaN、Infinity、undefined、eval、arguments等。
        "no-shadow-restricted-names": 1,
        //没有执行不到的代码
        "no-unreachable": 1,
        //在使用parseInt() 方法时,需要传递第二个参数,来帮助解析,告诉方法解析成多少进制。
        "radix": 1,
        // 使用isNaN判断NaN
        "use-isnan": 1,
        //在使用typeof操作符时,作比较的字符串必须是合法字符串eg:'string' 'object'
        "valid-typeof": 1,
        //立即执行函数需要用圆括号包围
        "wrap-iife": [1, "any"],
        // 添加空行
        "padded-blocks": 0,
        // 多个空行
        "no-multiple-empty-lines": 0,
        // =号加空格
        "space-infix-ops": 1,
        // allow debugger during development
        'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
    }
}