Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eslint-plugin-civet

Package Overview
Dependencies
Maintainers
0
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-civet

ESLint plugin for Civet code

  • 0.0.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9
increased by200%
Maintainers
0
Weekly downloads
 
Created
Source

Civet ESLint plugin

This plugin enables using ESLint (and optionally typescript-eslint) directly on your .civet files. Specifically, it provides a processor for converting .civet files into TypeScript or JavaScript, and provides some recommended rules for Civet code.

Installation

Install the plugin, along with Civet, ESLint, and (optionally) typescript-eslint if you haven't already:

npm install -D eslint-plugin-civet @danielx/civet eslint @eslint/js typescript-eslint

Simple Usage with typescript-eslint

Here is a sample eslint.config.mjs (ESM mode):

import civetPlugin from "eslint-plugin-civet/ts"

export default [
  // Rules from eslint.configs.recommended
  ...civetPlugin.configs.jsRecommended,
  // Rules from tseslint.configs.strict
  ...civetPlugin.configs.strict,
]

Here is a sample eslint.config.cjs (CJS mode):

const civetPlugin = require("eslint-plugin-civet/ts")

module.exports = [
  // Rules from eslint.configs.recommended
  ...civetPlugin.configs.jsRecommended,
  // Rules from tseslint.configs.strict
  ...civetPlugin.configs.strict,
]

This will load the plugin, enable the processor for *.civet files, and turn on eslint's recommended rules and typescript-eslint's strict rules. Alternatively, change configs.strict to configs.recommended or another of typescript-eslint's available configurations.

Simple Usage with ESLint and JavaScript

If you'd rather not use typescript-eslint, and just want to use ESLint to check your Civet code as JavaScript, here is a sample eslint.config.mjs (ESM mode):

import civetPlugin from "eslint-plugin-civet"

export default [
  ...civetPlugin.configs.recommended
]

Here is a sample eslint.config.cjs (CJS mode):

module.exports = [
  ...require("eslint-plugin-civet").configs.recommended
]

This will load the plugin, enable the processor for *.civet files, and turn on ESLint's recommended rules. Alternatively, change configs.recommended to configs.all to enable all of ESLint's rules.

Complex Usage with ESLint and JavaScript

Here is a sample eslint.config.mjs that more explicitly configures behavior for .civet files and otherwise:

import civetPlugin from "eslint-plugin-civet"
import js from "@eslint/js"

export default [
  // Enable recommended rules for all files
  js.configs.recommended,
  // Load plugin and enable processor for .civet files
  {
    files: ["**/*.civet"],
    plugins: {
      civet: civetPlugin,
    },
    processor: "civet/civet",
    // Here is where you would override specific rules.
    // We provide an `overrides` rule set that disables rules that
    // don't work well with Civet output.
    ...civetPlugin.configs.overrides,
  },
]

Civet Configuration

If you need to customize the Civet compiler's configuration (beyond just js: true vs. js: false), import { civet } from either "eslint-plugin-civet" or "eslint-plugin-civet/ts" (also available as .civet` from the default import). This function takes an options object for the Civet compiler, and returns a plugin:

import { civet } from "eslint-plugin-civet"
const civetPlugin = civet({
  parseOptions: {
    // coffeeCompat: true,
    // ...
  },
})
// rest as before

Example

You can see a full working example in the example directory.

Keywords

FAQs

Package last updated on 26 Aug 2024

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