Git Product home page Git Product logo

eslint-plugin-top's Introduction


Hello there! My name is Damien, and this is my profile! ♥

☀️ By day, I work at Front as a Front-end engineer

🌙 By night, I like to tinker around by writing userscripts, extensions and random programs that make my life easier and/or more fun!

📫 You can reach me:

Have a nice day!

eslint-plugin-top's People

Contributors

eramdam avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

ericcornelissen

eslint-plugin-top's Issues

Allow top-level literal assignments

I started using this plugin but was surprised to find out it reports about top-level literal assignments to constants (e.g. const bar = 1337;). Since these can't be changed, I don't think they should be considered problematic (even considering the ref from eslint-plugin-toplevel). Do let me know if that assumption is wrong.

I think this could be achieved quite simply by adding a check isLiteral to noTopLevelVariables.ts#L32-L42 like:

const isMatching = Array.from(options.kind).includes(node.kind);
const isRequire =
  node.declarations[0].init?.type === 'CallExpression' &&
  node.declarations[0].init.callee.type === 'Identifier' &&
  node.declarations[0].init.callee.name === 'require';
const isLiteral =
  node.kind === 'const' &&
  node.declarations[0].init?.type === 'Literal';

if (isMatching && !isRequire && !isLiteral) {
  if (isTopLevel(node)) {
    context.report({node, messageId: 'message'});
  }
}

As a temporary solution, I started a fork scoped to my personal npm namespace with the above patch applied.

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.