### Install semistandard Source: https://github.com/standard/semistandard/blob/master/README.md Install semistandard globally using npm. Omit the -g flag to install locally. ```bash npm install semistandard ``` ```bash npm install semistandard -g ``` -------------------------------- ### Install and run globally Source: https://context7.com/standard/semistandard/llms.txt Install semistandard globally and run it against all JavaScript files in your project. Violations are printed to stdout with file path, line number, and rule description. ```APIDOC ## Install and run globally Install `semistandard` globally and run it against all JavaScript files in your project. Violations are printed to stdout with file path, line number, and rule description. ```bash # Install globally npm install --global semistandard # Lint all .js files in the current directory (recursive) semistandard # Example output: # Error: Use JavaScript Semi-Standard Style # lib/torrent.js:950:11: Expected '===' and instead saw '=='. # src/index.js:12:30: Missing semicolon. ``` ``` -------------------------------- ### Install and Run Semistandard Globally Source: https://context7.com/standard/semistandard/llms.txt Install semistandard globally to lint all JavaScript files in your project. Violations are printed to stdout. ```bash # Install globally npm install --global semistandard # Lint all .js files in the current directory (recursive) semistandard # Example output: # Error: Use JavaScript Semi-Standard Style # lib/torrent.js:950:11: Expected '===' and instead saw '=='. # src/index.js:12:30: Missing semicolon. ``` -------------------------------- ### Install VS Code StandardJS Extension Source: https://context7.com/standard/semistandard/llms.txt Install the `vscode-standardjs` extension from the VS Code Marketplace for inline linting with semistandard rules. ```bash # Install from VS Code Marketplace # Extension ID: chenxsan.vscode-standardjs # https://marketplace.visualstudio.com/items?itemName=chenxsan.vscode-standardjs ``` -------------------------------- ### Example of semistandard CLI usage Source: https://github.com/standard/semistandard/blob/master/README.md Run semistandard from the command line to check the style of JavaScript files in the current directory. This example shows a potential error output. ```bash $ semistandard Error: Use JavaScript Semi-Standard Style lib/torrent.js:950:11: Expected '===' and instead saw '=='. ``` -------------------------------- ### Using a custom parser Source: https://context7.com/standard/semistandard/llms.txt To lint non-standard JavaScript syntax (e.g., TypeScript via `@typescript-eslint/parser` or experimental syntax via `babel-eslint`), install the parser and declare it in `package.json`. ```APIDOC ## Using a custom parser To lint non-standard JavaScript syntax (e.g., TypeScript via `@typescript-eslint/parser` or experimental syntax via `babel-eslint`), install the parser and declare it in `package.json`. ```bash npm install --save-dev babel-eslint ``` ```json { "semistandard": { "parser": "babel-eslint" } } ``` ``` -------------------------------- ### Pipe semistandard output to snazzy for prettier output Source: https://github.com/standard/semistandard/blob/master/README.md Enhance the output of semistandard by piping its verbose output to the 'snazzy' package for more visually appealing formatting. Ensure 'snazzy' is installed. ```bash $ semistandard --verbose | snazzy ``` -------------------------------- ### Example of npm test output with semistandard failure Source: https://github.com/standard/semistandard/blob/master/README.md This output demonstrates the result of running 'npm test' when semistandard detects style violations. The error message indicates a specific line and character where a style issue was found. ```bash $ npm test Error: Code style check failed: lib/torrent.js:950:11: Expected '===' and instead saw '=='. ``` -------------------------------- ### Configure Ignored Files in package.json Source: https://context7.com/standard/semistandard/llms.txt Specify files or directories to ignore during linting by adding a `semistandard.ignore` array to your `package.json`. Glob patterns are supported. ```json { "name": "my-project", "semistandard": { "ignore": [ "**/out/", "/lib/vendor/", "bundle.js", "tmp.js" ] } } ``` -------------------------------- ### Integration with npm test Source: https://context7.com/standard/semistandard/llms.txt Add `semistandard` as a test step so style checks are enforced automatically in CI and before every release. ```APIDOC ## Integration with `npm test` Add `semistandard` as a test step so style checks are enforced automatically in CI and before every release. ```json { "name": "my-cool-package", "scripts": { "test": "semistandard && node test/index.js" }, "devDependencies": { "semistandard": "*" } } ``` ```bash npm test # Error: Code style check failed: # lib/torrent.js:950:11: Expected '===' and instead saw '=='. ``` ``` -------------------------------- ### Lint Files Programmatically with Semistandard Source: https://context7.com/standard/semistandard/llms.txt Use the `semistandard.lintFiles` function to lint one or more files on disk. It returns a Promise that resolves to an array of ESLint result objects. ```javascript import semistandard from 'semistandard'; import { resolve } from 'node:path'; const filePath = resolve('./src/index.js'); const results = await semistandard.lintFiles([filePath]); for (const result of results) { console.log('File:', result.filePath); console.log('Errors:', result.errorCount); console.log('Warnings:', result.warningCount); for (const msg of result.messages) { console.log(` Line ${msg.line}:${msg.column} — ${msg.message} (${msg.ruleId})`); } } // Example output: // File: /project/src/index.js // Errors: 2 // Warnings: 0 // Line 4:25 — Missing semicolon. (semi) // Line 7:1 — 'foo' is not defined. (no-undef) ``` -------------------------------- ### Integrate Semistandard with npm test Source: https://context7.com/standard/semistandard/llms.txt Add Semistandard as a test script in `package.json` to automatically enforce code style checks during testing, CI, and pre-release steps. ```json { "name": "my-cool-package", "scripts": { "test": "semistandard && node test/index.js" }, "devDependencies": { "semistandard": "*" } } ``` ```bash npm test # Error: Code style check failed: # lib/torrent.js:950:11: Expected '===' and instead saw '=='. ``` -------------------------------- ### Configure ignored files in package.json Source: https://github.com/standard/semistandard/blob/master/README.md Define additional files and directories to ignore during semistandard checks by adding a 'semistandard.ignore' array to your package.json. This complements default ignores like node_modules. ```json "semistandard": { "ignore": [ "**/out/", "/lib/select2/", "/lib/ckeditor/", "tmp.js" ] } ``` -------------------------------- ### semistandard.lintFiles(files) Source: https://context7.com/standard/semistandard/llms.txt Lint one or more files on disk. Accepts an array of file path strings and returns a Promise resolving to an array of ESLint result objects. Each result contains the file path, error/warning counts, and an array of individual message objects with line, column, and rule information. ```APIDOC ## `semistandard.lintFiles(files)` Lint one or more files on disk. Accepts an array of file path strings and returns a Promise resolving to an array of ESLint result objects. Each result contains the file path, error/warning counts, and an array of individual message objects with line, column, and rule information. ```js import semistandard from 'semistandard'; import { resolve } from 'node:path'; const filePath = resolve('./src/index.js'); const results = await semistandard.lintFiles([filePath]); for (const result of results) { console.log('File:', result.filePath); console.log('Errors:', result.errorCount); console.log('Warnings:', result.warningCount); for (const msg of result.messages) { console.log(` Line ${msg.line}:${msg.column} — ${msg.message} (${msg.ruleId})`); } } // Example output: // File: /project/src/index.js // Errors: 2 // Warnings: 0 // Line 4:25 — Missing semicolon. (semi) // Line 7:1 — 'foo' is not defined. (no-undef) ``` ``` -------------------------------- ### Configure Vim with Syntastic for Semistandard Source: https://context7.com/standard/semistandard/llms.txt Configure your `.vimrc` to use semistandard as the JavaScript checker with Syntastic and enable auto-fixing on save. ```vim " Enable semistandard as the JavaScript checker let g:syntastic_javascript_checkers = ['standard'] let g:syntastic_javascript_standard_exec = 'semistandard' " Auto-fix on save autocmd bufwritepost *.js silent !semistandard % --fix set autoread ``` -------------------------------- ### Ignoring files via package.json Source: https://context7.com/standard/semistandard/llms.txt Configure paths to ignore during linting by adding a `semistandard.ignore` array in your `package.json`. Glob patterns are supported. ```APIDOC ## Ignoring files via `package.json` Configure paths to ignore during linting by adding a `semistandard.ignore` array in your `package.json`. Glob patterns are supported. ```json { "name": "my-project", "semistandard": { "ignore": [ "**/out/", "/lib/vendor/", "bundle.js", "tmp.js" ] } } ``` ``` -------------------------------- ### Configure Syntastic for Vim Source: https://github.com/standard/semistandard/blob/master/README.md Set up Syntastic plugin in Vim to use semistandard for JavaScript linting. Configure the checker and execution command in your .vimrc. ```vim let g:syntastic_javascript_checkers=['standard'] let g:syntastic_javascript_standard_exec = 'semistandard' ``` -------------------------------- ### Use a Custom Parser with Semistandard Source: https://context7.com/standard/semistandard/llms.txt Configure Semistandard to use a custom parser, such as `babel-eslint` for experimental syntax or `@typescript-eslint/parser` for TypeScript, by specifying the parser in `package.json`. ```bash npm install --save-dev babel-eslint ``` ```json { "semistandard": { "parser": "babel-eslint" } } ``` -------------------------------- ### Configure custom parser in package.json Source: https://github.com/standard/semistandard/blob/master/README.md Specify a custom parser for semistandard by adding a 'semistandard' configuration object to your package.json. This is useful for transpiled JavaScript. ```json { "semistandard": { "parser": "babel-eslint" } } ``` -------------------------------- ### Alternative markdown badge for js-semistandard-style Source: https://github.com/standard/semistandard/blob/master/README.md An alternative markdown badge for js-semistandard style, using a different shield.io format. ```markdown [![js-semistandard-style](https://img.shields.io/badge/code%20style-semistandard-brightgreen.svg)](https://github.com/standard/semistandard) ``` -------------------------------- ### Lint JavaScript Text with semistandard Source: https://context7.com/standard/semistandard/llms.txt Use `lintText` to lint raw JavaScript strings. Pass an optional `opts` object with `filename` for context. Useful for editor integrations and build tools. ```javascript import semistandard from 'semistandard'; const code = 'console.log("hello world")\n'; const [result] = await semistandard.lintText(code, { filename: 'example.js' }); console.log('Error count:', result.errorCount); // Error count: 2 for (const msg of result.messages) { console.log(`${msg.line}:${msg.column} ${msg.message}`); } // 1:13 Strings must use singlequote. // 1:27 Missing semicolon. // Check clean code: const [clean] = await semistandard.lintText("console.log('hello');\n"); console.log('Errors:', clean.errorCount); // Errors: 0 ``` -------------------------------- ### Add semistandard to package.json scripts Source: https://github.com/standard/semistandard/blob/master/README.md Integrate semistandard into your project's package.json for automated testing. This ensures style checks are performed when 'npm test' is run. ```json { "name": "my-cool-package", "devDependencies": { "semistandard": "*" }, "scripts": { "test": "semistandard && node my-normal-tests-littered-with-semicolons.js" } } ``` -------------------------------- ### semistandard --verbose Source: https://context7.com/standard/semistandard/llms.txt Print the ESLint rule name responsible for each violation alongside the error message. Useful for debugging or understanding which rules are being triggered. ```APIDOC ## `semistandard --verbose` Print the ESLint rule name responsible for each violation alongside the error message. Useful for debugging or understanding which rules are being triggered. ```bash semistandard --verbose # Example output: # Error: Use JavaScript Semi-Standard Style # src/app.js:5:20: Missing semicolon. (semi) # src/app.js:8:1: 'foo' is not defined. (no-undef) ``` ``` -------------------------------- ### semistandard --fix Source: https://context7.com/standard/semistandard/llms.txt Automatically fix all auto-fixable rule violations in place. This replaces the older `--format` flag and handles the vast majority of common style issues, including missing semicolons, quote style, and whitespace. ```APIDOC ## `semistandard --fix` Automatically fix all auto-fixable rule violations in place. This replaces the older `--format` flag and handles the vast majority of common style issues, including missing semicolons, quote style, and whitespace. ```bash # Fix all auto-fixable issues across the project semistandard --fix # Fix a specific file semistandard --fix src/index.js # Combine with verbose output piped to snazzy for prettier formatting semistandard --fix --verbose | snazzy ``` ``` -------------------------------- ### Markdown badge for js-semistandard-style Source: https://github.com/standard/semistandard/blob/master/README.md Include this markdown snippet in your README to display a badge indicating your project uses js-semistandard style. ```markdown [![js-semistandard-style](https://raw.githubusercontent.com/standard/semistandard/master/badge.svg)](https://github.com/standard/semistandard) ``` -------------------------------- ### Verbose Output for Semistandard Linting Source: https://context7.com/standard/semistandard/llms.txt Enable verbose output with the `--verbose` flag to see the ESLint rule name for each violation. This is helpful for debugging and understanding rule triggers. ```bash semistandard --verbose # Example output: # Error: Use JavaScript Semi-Standard Style # src/app.js:5:20: Missing semicolon. (semi) # src/app.js:8:1: 'foo' is not defined. (no-undef) ``` -------------------------------- ### lintText Source: https://context7.com/standard/semistandard/llms.txt Lints a raw JavaScript string without writing to disk. Returns a Promise resolving to an array of ESLint result objects. Useful for editor integrations, build tools, and test suites that generate or transform code dynamically. An optional `opts` object can pass `filename` to provide context for parser and ignore-path resolution. ```APIDOC ## `semistandard.lintText(text, [opts])` ### Description Lint a raw JavaScript string without writing to disk. Returns a Promise resolving to an array of ESLint result objects. Useful for editor integrations, build tools, and test suites that generate or transform code dynamically. An optional `opts` object can pass `filename` to provide context for parser and ignore-path resolution. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```javascript import semistandard from 'semistandard'; const code = 'console.log("hello world")\n'; const [result] = await semistandard.lintText(code, { filename: 'example.js' }); console.log('Error count:', result.errorCount); // Error count: 2 for (const msg of result.messages) { console.log(`${msg.line}:${msg.column} ${msg.message}`); } // 1:13 Strings must use singlequote. // 1:27 Missing semicolon. // Check clean code: const [clean] = await semistandard.lintText("console.log('hello');\n"); console.log('Errors:', clean.errorCount); // Errors: 0 ``` ### Response #### Success Response (Promise resolving to array of ESLint result objects) - **errorCount** (number) - The number of errors found. - **messages** (array) - An array of linting messages. - **line** (number) - The line number where the issue occurred. - **column** (number) - The column number where the issue occurred. - **message** (string) - The description of the linting issue. #### Response Example ```json [ { "filePath": "example.js", "messages": [ { "ruleId": "quotes", "severity": 2, "message": "Strings must use singlequote.", "line": 1, "column": 13, "nodeType": "Literal" }, { "ruleId": "semi", "severity": 2, "message": "Missing semicolon.", "line": 1, "column": 27, "nodeType": "ExpressionStatement" } ], "errorCount": 2, "warningCount": 0, "fixableErrorCount": 0, "fixableWarningCount": 0, "source": "..." } ] ``` ``` -------------------------------- ### Configure automatic formatting on save in Vim Source: https://github.com/standard/semistandard/blob/master/README.md Enable automatic JavaScript formatting on file save in Vim using semistandard. Add these lines to your .vimrc to trigger formatting when a buffer is written. ```vim autocmd bufwritepost *.js silent !semistandard % --fix set autoread ``` -------------------------------- ### Automatically Fix Violations with Semistandard Source: https://context7.com/standard/semistandard/llms.txt Use the `--fix` flag to automatically correct auto-fixable rule violations in place. This handles common issues like missing semicolons and quote styles. ```bash # Fix all auto-fixable issues across the project semistandard --fix # Fix a specific file semistandard --fix src/index.js # Combine with verbose output piped to snazzy for prettier formatting semistandard --fix --verbose | snazzy ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.