Toolkit

LintCommands extends AbstractCommands
in package

Commands to lint the source code and interact with ESLint.

Table of Contents

getConfigurationFile()  : string
Path to YAML configuration file containing command defaults.
getWorkingDir()  : string
Returns the current working directory.
initializeRuntimeConfiguration()  : mixed
Command initialization.
toolkitLintJs()  : mixed
Run lint JS.
toolkitLintPhp()  : mixed
Run lint PHP.
toolkitLintYaml()  : mixed
Run lint YAML.
toolkitSetupEslint()  : int
Setup the ESLint configurations and dependencies.
getBin()  : string
Validate and return the path to given bin.
getBinPath()  : string
Return the path to given bin.
getConfigValue()  : mixed
{@inheritdoc}
getNodeBin()  : string
Validate and return the path to given bin from node packages.
getNodeBinPath()  : string
Return the path to given bin from node packages.
isSimulating()  : bool
Check if current command is being executed with option simulate.
taskExecute()  : mixed
Execute a command.
taskProcess()  : Process|CollectionBuilder
Process the file.
taskReplaceBlock()  : ReplaceBlock|CollectionBuilder
Replace block in a file.
generateEslintConfigurations()  : mixed
Generate configurations for ESLint.
toolkitRunEsLint()  : mixed
Execute the eslint.

Methods

getConfigurationFile()

Path to YAML configuration file containing command defaults.

public getConfigurationFile() : string
Return values
string —

getWorkingDir()

Returns the current working directory.

public getWorkingDir() : string
Return values
string —

The current working directory.

initializeRuntimeConfiguration()

Command initialization.

public initializeRuntimeConfiguration() : mixed
Tags
hook

pre-command-event *

Return values
mixed —

toolkitLintJs()

Run lint JS.

public toolkitLintJs([array<string|int, mixed> $options = ['config' => InputOption::VALUE_REQUIRED, 'extensions' => InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'options' => InputOption::VALUE_OPTIONAL] ]) : mixed

Check configurations at config/default.yml - 'toolkit.lint.eslint'.

Parameters
$options : array<string|int, mixed> = ['config' => InputOption::VALUE_REQUIRED, 'extensions' => InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'options' => InputOption::VALUE_OPTIONAL]
Tags
command

toolkit:lint-js

option

config The eslint config file.

option

extensions The extensions to check.

option

options Extra options for the command without -- (only options with no value).

aliases

tljs, tk-js

usage

--extensions='.js' --options='fix no-eslintrc'

Return values
mixed —

toolkitLintPhp()

Run lint PHP.

public toolkitLintPhp([array<string|int, mixed> $options = ['extensions' => InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'exclude' => InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'options' => InputOption::VALUE_OPTIONAL] ]) : mixed

Check configurations at config/default.yml - 'toolkit.lint.php'.

Parameters
$options : array<string|int, mixed> = ['extensions' => InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'exclude' => InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'options' => InputOption::VALUE_OPTIONAL]
Tags
command

toolkit:lint-php

option

exclude The eslint config file.

option

extensions The extensions to check.

option

options Extra options for the command without -- (only options with no value).

aliases

tlp, tk-php

Return values
mixed —

toolkitLintYaml()

Run lint YAML.

public toolkitLintYaml([array<string|int, mixed> $options = ['config' => InputOption::VALUE_REQUIRED, 'extensions' => InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'options' => InputOption::VALUE_OPTIONAL] ]) : mixed

Check configurations at config/default.yml - 'toolkit.lint.eslint'.

Parameters
$options : array<string|int, mixed> = ['config' => InputOption::VALUE_REQUIRED, 'extensions' => InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'options' => InputOption::VALUE_OPTIONAL]
Tags
command

toolkit:lint-yaml

option

config The eslint config file.

option

extensions The extensions to check.

option

options Extra options for the command without -- (only options with no value).

aliases

tly, tk-yaml

usage

--extensions='.yml' --options='fix no-eslintrc'

Return values
mixed —

toolkitSetupEslint()

Setup the ESLint configurations and dependencies.

public toolkitSetupEslint([array<string|int, mixed> $options = ['config' => InputOption::VALUE_OPTIONAL, 'ignores' => InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'drupal-root' => InputOption::VALUE_OPTIONAL, 'packages' => InputOption::VALUE_OPTIONAL, 'force' => false] ]) : int

Check configurations at config/default.yml - 'toolkit.lint.eslint'.

Parameters
$options : array<string|int, mixed> = ['config' => InputOption::VALUE_OPTIONAL, 'ignores' => InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'drupal-root' => InputOption::VALUE_OPTIONAL, 'packages' => InputOption::VALUE_OPTIONAL, 'force' => false]
Tags
command

toolkit:setup-eslint

option

config The eslint config file.

option

ignores The patterns to ignore.

option

drupal-root The drupal root.

option

packages The npm packages to install.

option

force If true, the config file will be deleted.

Return values
int —

getBin()

Validate and return the path to given bin.

protected getBin(string $name) : string
Parameters
$name : string

The bin to look for.

Tags
throws
TaskException
Return values
string —

The bin path.

getBinPath()

Return the path to given bin.

protected getBinPath(string $name) : string
Parameters
$name : string
Return values
string —

The path to given binary.

getConfigValue()

{@inheritdoc}

protected getConfigValue(mixed $key[, mixed $default = null ]) : mixed
Parameters
$key : mixed
$default : mixed = null
Return values
mixed —

getNodeBin()

Validate and return the path to given bin from node packages.

protected getNodeBin(string $name) : string
Parameters
$name : string

The bin to look for.

Tags
throws
TaskException
Return values
string —

The bin path.

getNodeBinPath()

Return the path to given bin from node packages.

protected getNodeBinPath(string $name) : string
Parameters
$name : string
Return values
string —

The path to given binary.

isSimulating()

Check if current command is being executed with option simulate.

protected isSimulating() : bool
Return values
bool —

True if using --simulate, false otherwise.

taskExecute()

Execute a command.

protected taskExecute(array<string|int, mixed> $tasks) : mixed
Parameters
$tasks : array<string|int, mixed>

An array with tasks to execute.

Return values
mixed —

taskProcess()

Process the file.

protected taskProcess(string $source[, string $destination = '' ]) : Process|CollectionBuilder
Parameters
$source : string

The source file to process.

$destination : string = ''

The destination file.

Return values
Process|CollectionBuilder —

taskReplaceBlock()

Replace block in a file.

protected taskReplaceBlock([string $filename = '' ]) : ReplaceBlock|CollectionBuilder
Parameters
$filename : string = ''

The file to process.

Return values
ReplaceBlock|CollectionBuilder —

generateEslintConfigurations()

Generate configurations for ESLint.

private generateEslintConfigurations(string $config, array<string|int, mixed> $options) : mixed
Parameters
$config : string

The path for the configuration file.

$options : array<string|int, mixed>

The options passed to the command.

Return values
mixed —

toolkitRunEsLint()

Execute the eslint.

private toolkitRunEsLint(string $config, array<string|int, mixed> $extensions, string $options) : mixed
Parameters
$config : string

The eslint config file.

$extensions : array<string|int, mixed>

The extensions to check.

$options : string

Extra options for the command.

Tags
see
toolkitLintYaml()
see
toolkitLintJs()
Return values
mixed —

Search results