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-pathmark

v1.0.2

Published

add path metadata to all files

Downloads

15

Readme

eslint-plugin-pathmark

Mark a Path to every file, in that file.

// PathMark: ./index.js
console.logo("Hello world");
// EOF

PathMark is an eslint plugin that automates the inclusion of specific tags within your JavaScript files, marking the start with a #PathMark tag that includes the file path and ensuring an end-of-file (EOF) marker is present. This preparation enriches code snippets with contextual information, optimizing them for analysis by AI tools or for more straightforward navigation and understanding by human developers.

Example output:

console.logo("Hello world");

Would be fixed to:

// PathMark: ./src/index.js
console.logo("Hello world");
// EOF

Y Tho

Consider:

function logMessage(message) {
  console.log(`[INFO]: ${message}`);
}

The given code can have drastic recommendation differences depending on context. For instance,

// #PathMark: ./src/client/utils/logger.js
function logMessage(message) {
  console.log(`[INFO]: ${message}`);
}

vs

// #PathMark: ./src/server/utils/logger.js
function logMessage(message) {
  console.log(`[INFO]: ${message}`);
}

Despite the function's identical implementation, its placement within the client or server directory shifts its intended use and operational context. For the client-side, an AI might suggest enhancements related to user experience or development practices, like wrapping the log calls to only execute in non-production environments. On the server-side, the recommendations could focus on reliability, security, and performance, such as implementing different log levels (info, warn, error) and directing output to more persistent storage solutions suited for production environments.

% cat ./src/server/utils/logger.js | ChatGPT what does this do
'The given JavaScript function `logMessage(message)` is designed to log information to the console.
Here is how it works:
1. It receives one parameter: `message`. This is expected to be a string and this is the information that you want to log.
2. The `console.log()` statement is used to print information to the JavaScript console. This is usually used for troubleshooting purposes (debugging) or simply to provide information about the status/progress of a program.
3. In the `console.log()`, a template literal (denoted by the backticks) is used to concatenate "[INFO]: " with whatever `message` was passed into the function.
So, if you call `logMessage("Hello World")`, it would print out `[INFO]: Hello World` to the console.'

% cat ./src/client/utils/logger.js | ChatGPT what does this do
'This is a JavaScript function named `logMessage`. It takes one parameter called `message`.
The function uses `console.log` to print the message to the console, providing a way to log information for debugging purposes.
This can be useful for debugging issues in the code, tracking certain actions in the client-side JavaScript, or displaying informational messages.
As an example, if youd use `logMessage("Page loaded")`, it would output `[INFO]: Page loaded` in your web browsers JavaScript console.'

Likewise, an EOF tag can inform context:

function logMessage(message) {
  console.log(`[INFO]: ${message}`);
}
% cat ./src/server/utils/logger.js | ChatGPT what is missing
'The function `logMessage(message)` itself looks fine. Its a simple logging utility that displays a given message prefixed with `[INFO]: `. However, without further context, its hard to determine whats missing.'
function logMessage(message) {
  console.log(`[INFO]: ${message}`);
}
// EOF
% cat ./src/server/utils/logger.js | ChatGPT what is missing
'From what youve provided, it doesnt seem like anything is missing. You have a simple Javascript function named `logMessage` that takes a `message` argument. It uses Nodes console.log function to print a string to the console with `[INFO]: ` prepended to the `message` to be logged. The code seems correctly formatted. Nevertheless, if you want a module to export this function or want others to use it, you would need to add `module.exports = logMessage;` to the end of the file.'

Installation

You'll first need to install ESLint:

npm i eslint --save-dev

Next, install eslint-plugin-pathmark:

npm install eslint-plugin-pathmark --save-dev

Usage

This package requires ESM.

Flat config ships with recommended rules. For flat config:

// PathMark: ./eslint.congif.js
import pathmark from "eslint-plugin-pathmark";

export default [
  pathmark.configs.flat,
  // Adjust rules like so:
  {
    rules: {
      "pathmark/add-path": 0,
    },
  },
];
// EOF

Legacy

Add pathmark to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:

{
  "plugins": ["pathmark"]
}

Then configure the rules you want to use under the rules section.

{
  "rules": {
    "pathmark/add-path": 2
  }
}

Configurations

| | Name | | :-- | :------------ | | ✅ | recommended |

Rules

⚠️ Configurations set to warn in.
✅ Set in the recommended configuration.
🔧 Automatically fixable by the --fix CLI option.

| Name       | Description | ⚠️ | 🔧 | | :------------------------------------- | :-------------------------------------------------------------------- | :-- | :-- | | add-eof | enforce a specific tag to be present at the very end of a file. | ✅ | 🔧 | | add-path | enforce each file includes a #PathMark comment indicating its path | ✅ | 🔧 | | check-path | disallow #PathMark tag's path to not match the file's actual location | ✅ | 🔧 |