Toolkit

LintCommands extends AbstractCommands
in package

Commands to lint the source code and interact with ESLint.

Table of Contents

Methods

getConfigurationFile()  : string
Path to YAML configuration file containing command defaults.
getJson()  : array<string|int, mixed>
Returns the JSON parsed content.
getWorkingDir()  : string
Returns the current working directory.
isWebsiteInstalled()  : bool
Check if the website is installed.
toolkitLintBehat()  : int
Run lint Behat.
toolkitLintCsPell()  : int
Run lint CSpell.
toolkitLintCss()  : int
Run lint CSS.
toolkitLintJs()  : CollectionBuilder
Run lint JS.
toolkitLintPhp()  : int
Run lint PHP.
toolkitLintYaml()  : CollectionBuilder
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|null
Return the configuration value.
getNodeBin()  : string
Validate and return the path to given bin from node packages.
getNodeBinPath()  : string
Return the path to given bin from node packages.
isJunit()  : bool
Check whether Junit option is being used, or env var is set.
isSimulating()  : bool
Check if current command is being executed with option simulate.
taskExecute()  : CollectionBuilder
Execute a command.
taskProcess()  : ReplaceBlock|CollectionBuilder
Process the file.
taskReplaceBlock()  : ReplaceBlock|CollectionBuilder
Replace block in a file.
generateEslintConfigurations()  : void
Generate configurations for ESLint.
toolkitRunEsLint()  : CollectionBuilder
Execute the eslint.

Methods

getConfigurationFile()

Path to YAML configuration file containing command defaults.

public getConfigurationFile() : string
Return values
string

Configuration file path.

getJson()

Returns the JSON parsed content.

public getJson(string $filename[, bool $throwException = true ]) : array<string|int, mixed>
Parameters
$filename : string
$throwException : bool = true

If the file is not found.

Return values
array<string|int, mixed>

Json parsed content.

getWorkingDir()

Returns the current working directory.

public getWorkingDir() : string
Return values
string

The current working directory.

isWebsiteInstalled()

Check if the website is installed.

public isWebsiteInstalled() : bool
Return values
bool

toolkitLintBehat()

Run lint Behat.

public toolkitLintBehat([array<string|int, mixed> $options = ['config' => InputOption::VALUE_REQUIRED, 'files' => InputOption::VALUE_REQUIRED] ]) : int
Parameters
$options : array<string|int, mixed> = ['config' => InputOption::VALUE_REQUIRED, 'files' => InputOption::VALUE_REQUIRED]

Command options.

Tags
command

toolkit:lint-behat

option

config The path to the config file.

option

files The files to check.

option

junit Whether to export results as junit.

aliases

tk-lbehat

usage

--files='tests/features' --config='gherkinlint.json'

SuppressWarnings

(PHPMD.CyclomaticComplexity)

Return values
int

The toolkit lint-behat command status.

toolkitLintCsPell()

Run lint CSpell.

public toolkitLintCsPell([array<string|int, mixed> $options = ['config' => InputOption::VALUE_REQUIRED, 'files' => InputOption::VALUE_REQUIRED, 'options' => InputOption::VALUE_OPTIONAL] ]) : int
Parameters
$options : array<string|int, mixed> = ['config' => InputOption::VALUE_REQUIRED, 'files' => InputOption::VALUE_REQUIRED, 'options' => InputOption::VALUE_OPTIONAL]

Command options.

Tags
command

toolkit:lint-cspell

option

config The path to the config file.

option

files The files to check.

option

options Extra options for the command.

option

junit Whether to export results as junit.

aliases

tk-cspell

usage

--files='lib' --config='web/core/.cspell.json' --options='--gitignore'

Return values
int

The toolkit lint-cspell command status.

toolkitLintCss()

Run lint CSS.

public toolkitLintCss([array<string|int, mixed> $options = ['config' => InputOption::VALUE_REQUIRED, 'files' => InputOption::VALUE_REQUIRED] ]) : int
Parameters
$options : array<string|int, mixed> = ['config' => InputOption::VALUE_REQUIRED, 'files' => InputOption::VALUE_REQUIRED]

Command options.

Tags
command

toolkit:lint-css

option

exclude The stylelint config file.

option

files The files to check.

option

junit Whether to export results as junit.

aliases

tk-css

Return values
int

The toolkit lint css command status.

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] ]) : CollectionBuilder
Parameters
$options : array<string|int, mixed> = ['config' => InputOption::VALUE_REQUIRED, 'extensions' => InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'options' => InputOption::VALUE_OPTIONAL]

Command options.

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).

option

junit Whether to export results as junit.

aliases

tk-js, tljs

usage

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

Return values
CollectionBuilder

The toolkit lint js status.

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] ]) : int
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]

Command options.

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).

option

junit Whether to export results as junit.

aliases

tk-php, tlp

SuppressWarnings

(PHPMD.CyclomaticComplexity)

Return values
int

The toolkit lint php command status.

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] ]) : CollectionBuilder
Parameters
$options : array<string|int, mixed> = ['config' => InputOption::VALUE_REQUIRED, 'extensions' => InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'options' => InputOption::VALUE_OPTIONAL]

Command options.

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).

option

junit Whether to export results as junit.

aliases

tk-yaml, tly

usage

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

Return values
CollectionBuilder

The Toolkit lint yaml command status.

toolkitSetupEslint()

Setup the ESLint configurations and dependencies.

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

Command options.

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

The setup eslint configuration status.

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()

Return the configuration value.

protected getConfigValue(string $key[, mixed|null $default = null ]) : mixed|null
Parameters
$key : string

The config item to look up.

$default : mixed|null = null

Default configuration value for the key item if neither has value nor exists.

Return values
mixed|null

The configuration value.

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.

isJunit()

Check whether Junit option is being used, or env var is set.

protected isJunit() : bool
Return values
bool

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, string> $tasks) : CollectionBuilder
Parameters
$tasks : array<string|int, string>

An array with tasks to execute.

Return values
CollectionBuilder

The task executed.

taskProcess()

Process the file.

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

The source file to process.

$destination : string = ''

The destination file.

Return values
ReplaceBlock|CollectionBuilder

The file task processed.

taskReplaceBlock()

Replace block in a file.

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

The file to process.

Return values
ReplaceBlock|CollectionBuilder

The file replaced.

generateEslintConfigurations()

Generate configurations for ESLint.

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

The path for the configuration file.

$options : array<string|int, mixed>

The options passed to the command.

Return values
void

The eslint configuration generated.

toolkitRunEsLint()

Execute the eslint.

private toolkitRunEsLint(string $config, array<string|int, mixed> $extensions, string $options) : CollectionBuilder
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
CollectionBuilder

The toolkit run eslint status.


        
On this page

Search results