New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@fontoxml/eslint-config

Package Overview
Dependencies
Maintainers
9
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fontoxml/eslint-config

Fonto's opiniated ESLint base configuration.

  • 4.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
9
Created
Source

@fontoxml/eslint-config

Opiniated ESLint (and Prettier) configuration used by Fonto.

Installation

Install this package in your project as a development dependency:

npm install --save-dev @fontoxml/eslint-config

A handful of additional (development) dependencies are required for this configuration to work. Make sure to at least install:

This suffices for linting (most) JavaScript (.js).

If you like to use this configuration to lint React/JSX (.jsx), also install the following:

And for TypeScript (.ts and .tsx):

Usage

Simply extend @fontoxml in your ESLint configuration. The following is an example .eslintrc.js file which extends this configuration:

module.exports = {
	extends: ['@fontoxml'],
	root: true,
};

This will configure all rules except those requiring additional configuration (see below), and requires all peer dependencies to be installed, including the optional ones. The configuration relies on file extensions to determine which additional rules and plugins to run. For React/JSX the .jsx file extension is assumed and for TypeScript it's both .ts and .tsx.

Advanced usage

It's also possible to pick and choose specific parts of the configuration. The following example .eslintrc.js file includes all parts in their intended order:

module.exports = {
	extends: [
		'@fontoxml/eslint-config/base',
		'@fontoxml/eslint-config/react',
		'@fontoxml/eslint-config/typescript',
		'@fontoxml/eslint-config/typeinfo', // ⚠️ Requires configuration, see below.
	],
	root: true,
};

It's recommended to always include the base configuration, as the other parts are configured to extend it. Extending the parts in a different order might cause issues.

Linting with type information

Some TypeScript ESLint rules rely on the availability of type information, and require additional configuration to work properly. These rules are disabled by default, and can be enabled by extending the typeinfo part of the configuration. The following example .eslintrc.js file demonstrates this setup:

module.exports = {
	extends: ['@fontoxml', '@fontoxml/eslint-config/typeinfo'],
	parserOptions: {
		project: '<PATH_TO_TSCONFIG>',
	},
	root: true,
};

Please note that configuring the parserOptions.project option is required for this setup. Please refer to TypeScript ESLint parser's documentation for guidance on configuring it.

Prettier

Prettier is configured for code formatting, and runs as an autofixable ESLint rule. If you like to use the same Prettier configuration for file types not in scope of this configuration (e.g. HTML, Markdown), you can import it directly from this package. The following is an example .prettierrc.js file in which the configuration is used as-is:

module.exports = require('@fontoxml/eslint-config/prettier');

Extending and/or overriding configuration

Please refer to ESLint's configuration guide and its guide for extending configuration to extend and/or override rules defined by this configuration. Also note that in addition to the rules, some of the included plugins have settings that may need to be adjusted for your project.

Keywords

FAQs

Package last updated on 30 Mar 2023

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc