neostandard
Advanced tools
Comparing version 0.7.2 to 0.8.0
@@ -9,3 +9,3 @@ declare namespace _exports { | ||
export = _exports; | ||
type NeostandardOptions = import('./lib/main').NeostandardOptions; | ||
type NeostandardOptions = import("./lib/main").NeostandardOptions; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -12,25 +12,16 @@ 'use strict' | ||
const style = require('./configs/style') | ||
const { configExtend } = require('./config-extend') | ||
const { typescriptify } = require('./ts') | ||
const { isNonEmpty } = require('./utils') | ||
// TODO: Ensure both commonjs and esm are evaluated properly: https://github.com/eslint/eslint/discussions/18300#discussioncomment-9062217 And how does it interact with TS? | ||
const DEFAULT_FILES = [ | ||
'**/*.js', | ||
'**/*.cjs', | ||
'**/*.mjs', | ||
] | ||
const DEFAULT_TS_FILES = [ | ||
'**/*.ts', | ||
] | ||
/** | ||
* @typedef NeostandardOptions | ||
* @property {Array<keyof import('globals')>|undefined} [env] | ||
* @property {import('@typescript-eslint/utils/ts-eslint').FlatConfig.GlobalsConfig|string[]|undefined} [globals] | ||
* @property {string[]|undefined} [ignores] | ||
* @property {boolean|undefined} [noStyle] - skip style rules | ||
* @property {boolean|undefined} [semi] - enforce rather than forbid semicolons | ||
* @property {boolean|undefined} [ts] - enable TypeScript checks | ||
* @property {Array<keyof import('globals')>|undefined} [env] - resolves globals for the provided environment names using the {@link https://www.npmjs.com/package/globals|globals module} | ||
* @property {string[]|undefined} [files] - file patterns, in minimatch syntax, the config applies to, see {@link https://eslint.org/docs/latest/use/configure/configuration-files#specifying-files-and-ignores|ESLint Docs} | ||
* @property {string[]|undefined} [filesTs] - additional file patterns, in minimatch syntax, that TS rules will to apply to | ||
* @property {import('@typescript-eslint/utils/ts-eslint').FlatConfig.GlobalsConfig|string[]|undefined} [globals] - the base globals that should be considered available, see {@link https://eslint.org/docs/latest/use/configure/language-options#specifying-globals|ESLint Docs} | ||
* @property {string[]|undefined} [ignores] - patterns in minimatch syntax for files to ignore | ||
* @property {boolean|undefined} [noStyle] - when set, skips style rules | ||
* @property {boolean|undefined} [semi] - when set, enforces rather than forbids semicolons | ||
* @property {boolean|undefined} [ts] - when set, enables TypeScript checks | ||
*/ | ||
@@ -45,2 +36,4 @@ | ||
env, | ||
files, | ||
filesTs, | ||
globals: rawGlobals, | ||
@@ -53,2 +46,6 @@ ignores, | ||
if (filesTs && !ts) { | ||
throw new Error('"filesTs" is only usable with the "ts" option') | ||
} | ||
/** @type {import('@typescript-eslint/utils/ts-eslint').FlatConfig.GlobalsConfig} */ | ||
@@ -83,17 +80,21 @@ const resolvedGlobals = Array.isArray(rawGlobals) | ||
const configs = configExtend(jsConfigs, { | ||
files: ts ? [...DEFAULT_FILES, ...DEFAULT_TS_FILES] : DEFAULT_FILES, | ||
globals: Object.keys(resolvedGlobals).length ? resolvedGlobals : undefined, | ||
ignores, | ||
}) | ||
if (ts) { | ||
configs.push(typescriptify(configs, { | ||
files: DEFAULT_TS_FILES, | ||
ignores, | ||
name: 'neostandard/ts', | ||
})) | ||
/** @satisfies {import('@typescript-eslint/utils/ts-eslint').FlatConfig.Config} */ | ||
const meta = { | ||
...isNonEmpty(resolvedGlobals) && { languageOptions: { globals: resolvedGlobals } }, | ||
...files && { files }, | ||
} | ||
return configs | ||
return [ | ||
// To make it a global ignore, "ignores" has to be the lone key of the config: https://eslint.org/docs/latest/use/configure/configuration-files#globally-ignoring-files-with-ignores | ||
...ignores ? [{ ignores }] : [], | ||
...isNonEmpty(meta) ? [{ name: 'neostandard/meta', ...meta }] : [], | ||
...jsConfigs, | ||
...ts | ||
? [typescriptify(jsConfigs, { | ||
files: ['**/*.ts', ...filesTs || []], | ||
ignores, | ||
name: 'neostandard/ts', | ||
})] | ||
: [], | ||
] | ||
} | ||
@@ -100,0 +101,0 @@ |
export type TypescriptifyOptions = { | ||
files?: import('typescript-eslint').ConfigWithExtends['files']; | ||
files?: import("typescript-eslint").ConfigWithExtends["files"]; | ||
ignores?: string[] | undefined; | ||
@@ -9,3 +9,3 @@ name?: string; | ||
}; | ||
export function typescriptify(configs: import('@typescript-eslint/utils/ts-eslint').FlatConfig.ConfigArray, options: TypescriptifyOptions): import('@typescript-eslint/utils/ts-eslint').FlatConfig.Config; | ||
export function typescriptify(configs: import("@typescript-eslint/utils/ts-eslint").FlatConfig.ConfigArray, options: TypescriptifyOptions): import("@typescript-eslint/utils/ts-eslint").FlatConfig.Config; | ||
//# sourceMappingURL=ts.d.ts.map |
@@ -0,2 +1,3 @@ | ||
export function isNonEmpty(value: object): boolean; | ||
export function isStringArray(value: unknown): value is string[]; | ||
//# sourceMappingURL=utils.d.ts.map |
@@ -20,4 +20,13 @@ /** | ||
/** | ||
* @param {object} value | ||
* @returns {boolean} | ||
*/ | ||
function isNonEmpty (value) { | ||
return Object.keys(value).length !== 0 | ||
} | ||
module.exports = { | ||
isNonEmpty, | ||
isStringArray, | ||
} |
{ | ||
"name": "neostandard", | ||
"version": "0.7.2", | ||
"version": "0.8.0", | ||
"description": "A modern successor to standard", | ||
@@ -63,21 +63,21 @@ "homepage": "http://github.com/neostandard/neostandard", | ||
"@voxpelli/tsconfig": "^12.0.1", | ||
"eslint": "^9.4.0", | ||
"eslint": "^9.5.0", | ||
"husky": "^9.0.11", | ||
"installed-check": "^9.3.0", | ||
"knip": "^5.18.1", | ||
"list-dependents-cli": "^2.3.0", | ||
"knip": "^5.22.1", | ||
"list-dependents-cli": "^2.4.0", | ||
"npm-run-all2": "^6.2.0", | ||
"type-coverage": "^2.29.0", | ||
"typescript": "~5.4.5" | ||
"typescript": "~5.5.2" | ||
}, | ||
"dependencies": { | ||
"@humanwhocodes/gitignore-to-minimatch": "^1.0.2", | ||
"@stylistic/eslint-plugin-js": "^2.1.0", | ||
"@typescript-eslint/eslint-plugin": "^8.0.0-alpha.28", | ||
"@typescript-eslint/utils": "^8.0.0-alpha.28", | ||
"eslint-plugin-n": "^17.8.1", | ||
"@stylistic/eslint-plugin-js": "^2.2.2", | ||
"@typescript-eslint/eslint-plugin": "^8.0.0-alpha.30", | ||
"@typescript-eslint/utils": "^8.0.0-alpha.30", | ||
"eslint-plugin-n": "^17.9.0", | ||
"find-up": "^5.0.0", | ||
"globals": "^15.4.0", | ||
"peowly": "^1.3.0", | ||
"typescript-eslint": "^8.0.0-alpha.28" | ||
"globals": "^15.6.0", | ||
"peowly": "^1.3.1", | ||
"typescript-eslint": "^8.0.0-alpha.30" | ||
}, | ||
@@ -84,0 +84,0 @@ "peerDependencies": { |
@@ -97,2 +97,4 @@ <div align="center"> | ||
* `env` - *`string[]`* - adds additional globals by importing them from the [globals](https://www.npmjs.com/package/globals) npm module | ||
* `files` - *`string[]`* - additional file patterns to match. Uses the same shape as ESLint [`files`](https://eslint.org/docs/latest/use/configure/configuration-files#specifying-files-and-ignores) | ||
* `filesTs` - *`string[]`* - additional file patterns for the TypeScript configs to match. Uses the same shape as ESLint [`files`](https://eslint.org/docs/latest/use/configure/configuration-files#specifying-files-and-ignores) | ||
* `globals` - *`string[] | object`* - an array of names of globals or an object of the same shape as ESLint [`languageOptions.globals`](https://eslint.org/docs/latest/use/configure/language-options#using-configuration-files) | ||
@@ -102,3 +104,3 @@ * `ignores` - *`string[]`* - an array of glob patterns for files that the config should not apply to, see [ESLint documentation](https://eslint.org/docs/latest/use/configure/ignore) for details | ||
* `semi` - *`boolean`* - if set, enforce rather than forbid semicolons (same as `semistandard` did) | ||
* `ts` - *`boolean`* - if set, `.ts` (and `.d.ts`) files will be checked | ||
* `ts` - *`boolean`* - if set, TypeScript syntax will be supported and `*.ts` (including `*.d.ts`) will be checked. To add additional file patterns to the TypeScript checks, use `filesTs` | ||
@@ -105,0 +107,0 @@ ## resolveIgnoresFromGitignore() |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
211
180891
34
4119