Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
eslint-plugin-flowtype
Advanced tools
eslint-plugin-flowtype is an ESLint plugin that provides linting rules for Flow type annotations. It helps ensure that your Flow type annotations are correct and consistent, improving the reliability and maintainability of your code.
Type Annotations
This rule ensures that every file has a valid Flow file annotation. The code sample demonstrates a simple function with Flow type annotations for the parameters and return type.
/* eslint flowtype/require-valid-file-annotation: [2, "always"] */
// @flow
function add(a: number, b: number): number {
return a + b;
}
Type Definitions
This rule ensures that all Flow type definitions are defined correctly. The code sample shows a type definition for a User object and an instance of that type.
/* eslint flowtype/define-flow-type: 2 */
// @flow
type User = {
name: string,
age: number
};
const user: User = { name: 'John', age: 30 };
Type Casting
This rule enforces a naming convention for type identifiers. The code sample demonstrates a type definition that follows the specified naming convention.
/* eslint flowtype/type-id-match: [2, "^([A-Z][a-z0-9]+)+Type$"] */
// @flow
type UserType = {
name: string,
age: number
};
const user: UserType = { name: 'John', age: 30 };
eslint-plugin-typescript is an ESLint plugin that provides linting rules for TypeScript code. It offers similar functionality to eslint-plugin-flowtype but is designed for TypeScript instead of Flow. It helps ensure that your TypeScript code is correct and consistent.
typescript-eslint is a set of tools that allows ESLint to lint TypeScript code. It includes an ESLint plugin and a parser that can handle TypeScript syntax. Like eslint-plugin-flowtype, it helps maintain code quality and consistency, but it is tailored for TypeScript.
A plugin for ESLint that strips FlowType type annonations before linting the files.
If your code uses flow type annotations ( http://flowtype.org/ ) and you would like to lint it using ESLint currently the only option is using babel-eslint as ESLint parser instead of the default Espree.
However, Babel-Eslint currently monkey patches ESLint and I had lots of issues with upgrading to newer versions of ESlint and Babel-Eslint.
This plugins strips the type annotations before handing off the file for linting as such you are able to use the latest and greates ESLint parser: Espree on FlowType'd code.
Internally the plugin makes use of Recast for performing AST transforms and stripping the annotations together with esprima-fb parser( which is now deprecated but i couldn't get flow-parser to play nice with recast as such had to use esprima ).
The plugin also preserves the line numbers by using Recast source maps.
Know issues Issues with max-len ESlint rule reporting the line/column number as "0:0"
FAQs
Flowtype linting rules for ESLint.
The npm package eslint-plugin-flowtype receives a total of 4,058,696 weekly downloads. As such, eslint-plugin-flowtype popularity was classified as popular.
We found that eslint-plugin-flowtype demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.