Git Product home page Git Product logo

eslint-closure's Introduction

Closure Linter - ESLint Plugin and Config for the Google JavaScript Style Guide

A heavily customized ESLint config and plugin for JavaScript following the Google JavaScript style guide.

Check out the demo page.

Google Style Guide Specific Features

  • Recognizes goog.scope as an immediately invoked function expression (IIFE) that doesn't increase the indent.

    goog.scope(function() {
    var noIndent = 2;
    });
  • Recognizes goog.provide and goog.require.

    goog.provide('my.module');
    goog.require('other.module');
    
    my.module.Foo = other.module.Bar;
  • Avoids flagging typedef, export and other type-related tags as unused.

    /** @export {number} */
    my.module.foo = 2;

See the Google JavaScript style guide for the rest of the rules.

Disclaimer

This is not an official Google product (experimental or otherwise), it is just code that happens to be owned by Google.

Developing

Pull requests are always welcome. To get started, install Bazel, Google's open-source build system, and Yarn, an NPM replacement.

A typical development flow looks like this:

  1. make develop to download dependencies from NPM and to link the projects together.
  2. make test to ensure everything works first.
  3. Add a feature or fix a bug.
  4. make test
  5. git commit
  6. git push

eslint-closure's People

Contributors

jschaf avatar kolorful avatar ronapelbaum avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

eslint-closure's Issues

Cannot find module './dist/closure-eslint-plugin'

After I added

    "eslint-closure": "^0.0.1",
    "eslint-plugin-closure": "^0.0.1",
    "eslint-config-closure-base": "^0.0.1",
    "eslint-config-closure-es5": "^0.0.1",
    "eslint-config-closure-es6": "^0.0.1"

into package.json and did npm install. When I do npm run lint (with closure-base config), it says:

Cannot find module './dist/closure-eslint-plugin'
Error: Cannot find module './dist/closure-eslint-plugin'
    at Function.Module._resolveFilename (module.js:440:15)
    at Function.Module._load (module.js:388:25)
    at Module.require (module.js:468:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/xxx/xxx/xxx/node_modules/eslint-plugin-closure/index.js:15:18)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)

I looked at node_modules/eslint-plugin-closure/ and there is no dist folder in there.

Could you add some instructions in the README file to illustrate how to config this with eslint?

Thanks!

Not sure about how to use the plugin

Hi,

I tried to use this plugin following the next steps:
npm i -D eslint-plugin-closure

Modified .eslintrc.json
.eslintrc.json:

{
  ...
  "extends": ["closure"],
  ...
}

But when I tried to run eslint, it shows the message:

Cannot find module 'eslint-config-closure'

I also tried using "closure-es6", "closure-base", "plugin:closure" but none of them worked.

It would be great to have documentation about the right way to use this plugin.

better output for 'closure/no-undef' rule

when using this rule with namespace pattern:

goog.require('ns.A');
ns.A();
ns.B();

in that case we'll get 'ns' is not defined..

IMO it will be very helpful to get the full name.

don't know what I should add to support the `new` type

Question

The linter throws an error of type new unknow.
How could I config the eslint to support this type?

type reference

function-new-type

error

Syntax error in type: {new(source: {documents: Map<string, D>}): DListConstructor} jsdoc/valid-types

.eslintrc config

{
    "plugins": [
        "jsdoc",
        "closure"
    ],
    "env": {
        "es6": true
    },
    "rules": {
        "jsdoc/check-param-names": 1,
        "jsdoc/check-tag-names": 1,
        "jsdoc/check-types": 1,
        "jsdoc/newline-after-description": 1,
        "jsdoc/require-description-complete-sentence": 1,
        "jsdoc/require-param": 1,
        "jsdoc/require-param-type": 1,
        "jsdoc/require-returns-type": 1,
        "jsdoc/valid-types": 1
    },
    "settings": {
        "jsdoc": {
            "additionalTagNames": {
                "customTags": ["template"]
            }
        }
    }
}

the comment

/**
 * @param {{new(source: {documents: Map<string, D>}): DListConstructor}} ObjectiveClass
 */

Yarn workspaces

I noticed that there are Makefile's in the repo that just symlink dependencies within the repo with yarn.

In yarn@>=1, the workspaces feature will do the same thing.

If welcome, I can submit a PR that drops use of the Makefiles in favor of the workspaces feature.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.