npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

eslint-plugin-civet

v0.0.5

Published

ESLint plugin for Civet code

Downloads

58

Readme

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.