facebook / facebook/stylex

[eslint-plugin] Enable the `valid-styles` lint rule to evaluate all static expressions

Open
#726 0 comments 0 reactions 0 assignees View on GitHub
enhancement help wanted
Dominant language
JavaScript
Stars
10.3k
Forks
481
Avg merge
3d 8h
Merged PRs (30d)
13

Description

## Background

The Babel plugin uses a forked version of `path.evaluate()` from Babel to be able to statically evaluate a large number of static expressions during compilation. In addition to being able to evaluate simple expressions such as addition and string interpolation, the forked functionality can also:

- Evaluate imports from `.stylex.js` files without actually reading the file. It resolves the file path, and the uses the locally known export name and key to hash and re-compute the original variable strings.
- Evaluate simple pure arrow functions that do not have a function body (wrapped in `{}`) and return a simple expression instead.

## Task

The Eslint `valid-styles` rule should be refactor and enhanced to be able to do the same evaluation that the Babel plugin does so it is able to more effectively validate the styles being used.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.