GithubHelp home page GithubHelp logo

andrii-bodnar / eslint-plugin-figma-plugins Goto Github PK

View Code? Open in Web Editor NEW

This project forked from figma/eslint-plugin-figma-plugins

0.0 0.0 0.0 3.34 MB

License: MIT License

JavaScript 1.93% TypeScript 98.07%

eslint-plugin-figma-plugins's Introduction

eslint-plugin-figma-plugins

This repository defines typescript-eslint rules for Figma plugin development.

This tool helps you stay up to date with best practices and deprecations in the Figma Plugin API. You can use it to help identify, and in many cases automatically fix, issues in your plugin code. Like any ESLint plugin, it integrates with IDEs like VSCode to provide inline warnings and quick-fix functionality.

A quick look

An animation of VSCode quick fixes enabled by this plugin

Installation

Dependencies

This linter requires TypeScript, ESLint, typescript-eslint, and the Figma Plugin API type definitions. To install all of these, run:

npm install -D typescript eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin @figma/plugin-typings

Install the ESLint plugin package

npm install -D @figma/eslint-plugin-figma-plugins

Configure eslint

Configure typescript-eslint as normal using these instructions.

Next, update your ESLint config's extends array to include the plugin:@figma/figma-plugins/recommended ruleset. We also recommend the following rulesets:

  • eslint:recommended,
  • plugin:@typescript-eslint/recommended

To work with TypeScript code, ESLint also requires the following parser settings:

{
  ...
  parser: '@typescript-eslint/parser',
  parserOptions: {
    project: './tsconfig.json',
  },
  ...
}

Here's a full example of .eslintrc.js:

/* eslint-env node */
module.exports = {
  extends: [
    'eslint:recommended',
    'plugin:@typescript-eslint/recommended',
    'plugin:@figma/figma-plugins/recommended',
  ],
  parser: '@typescript-eslint/parser',
  parserOptions: {
    project: './tsconfig.json',
  },
  root: true
}

Restart the ESLint server

If you've run npm install and updated to a newer version of this package, remember to restart your IDE. In VSCode, you can restart the ESLint server independently by opening the command palette and choosing "Restart ESLint Server".

Usage

Linting and autofixing

You can lint your project using these rules by running

npx eslint ./path/to/source

Some rules provide autofixes, which you can run using --fix.

npx eslint --fix ./path/to/source

Autofixes are also available via some IDEs.

VSCode

To use ESLint with VSCode, see the ESLint VSCode extension. This extension will show rule violations inline, as well as provide opportunities to run autofixes directly in the IDE.

Rules

๐Ÿ’ผ Configurations enabled in.
โš ๏ธ Configurations set to warn in.
๐Ÿ‘ Set in the recommended configuration.
๐Ÿ”ฆ Set in the recommended-problems-only configuration.
๐Ÿ”ง Automatically fixable by the --fix CLI option.

Name Description ๐Ÿ’ผ โš ๏ธ ๐Ÿ”ง
await-requires-async Require functions that contain await to be async ๐Ÿ‘ ๐Ÿ”ฆ ๐Ÿ”ง
ban-deprecated-id-params Ban use of deprecated string ID parameters ๐Ÿ‘ ๐Ÿ”ฆ ๐Ÿ”ง
ban-deprecated-sync-methods Ban use of deprecated synchronous methods ๐Ÿ‘ ๐Ÿ”ฆ ๐Ÿ”ง
ban-deprecated-sync-prop-getters Ban use of deprecated synchronous property getters ๐Ÿ‘ ๐Ÿ”ฆ ๐Ÿ”ง
ban-deprecated-sync-prop-setters Ban use of deprecated synchronous property getters ๐Ÿ‘ ๐Ÿ”ฆ ๐Ÿ”ง
dynamic-page-documentchange-event-advice Advice on using the documentchange event ๐Ÿ‘
dynamic-page-find-method-advice Advice on using the find*() family of methods ๐Ÿ‘

Contributing

Please see CONTRIBUTING.md

eslint-plugin-figma-plugins's People

Contributors

jefflee-figma avatar andrii-bodnar avatar

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.