lint-init-framework
Framework to make your own lint-init CLI tool
Install
npm install --save lint-init-framework
Usage
Create lint-init.js
(or whatever you name it)
#!/usr/bin/env node
import { makeCli } from 'lint-init-framework';
makeCli({
packageName: '@myorg/lint-init',
commandName: 'lint-init',
version: '1.2.0',
eslint: [{}],
stylelint: [],
markdownlint: {},
prettier: {},
editorconfig: '',
vscode: {},
});
Modify your package.json
:
{
"bin": {
"lint-init": "./lint-init.js"
}
}
Options
packageName
name
field in package.json
commandName
Name of the bin (see bin
field in your package.json
)
version
version
field in package.json
eslint
Enalbe ESLint support
If you have multiple presets for different type of projects, pass an array of config with the following options:
eslint.deps
Entries of devDependencies
.
makeCli({
eslint: {
deps: {
'eslint-config-airbnb': '^8.0.0',
'eslint-plugin-import': '^11.0.0',
},
},
});
eslint.config
Content of .eslintrc.json
or eslintConfig
field in package.json
eslint.configFile
File name of ESLint configuration
-
package.json
(eslintConfig
field) .eslintrc
.eslintrc.json
.eslintrc.yaml
.eslintrc.js
eslint.ignore
Content of .eslintignore
makeCli({
eslint: {
ignore: `node_modules/
build/
coverage/
dist/
`,
},
});
stylelint
Enalbe Stylelint support
If you have multiple presets for different type of projects, pass an array of config with the following options:
stylelint.deps
Entries of devDependencies
.
makeCli({
eslint: {
deps: {
'stylelint-config-standard': '^8.0.0',
'stylelint-scss': '^5.0.0',
},
},
});
stylelint.config
Content of .stylelintrc.json
or stylelint
field in package.json
stylelint.configFile
File name of Stylelint configuration
-
package.json
(stylelint
field) .stylelintrc
.stylelintrc.json
.stylelintrc.yaml
.stylelintrc.js
stylelint.ignore
Content of .eslintignore
makeCli({
eslint: {
ignore: `node_modules/
build/
coverage/
dist/
`,
},
});
markdownlint
prettier
Enable Prettier support
prettier.deps
Entries of devDependencies
.
makeCli({
eslint: {
deps: {
prettier: '^3.0.0',
'prettier-plugin-packagejson': '^2.0.0',
},
},
});
prettier.config
Content of .prettierrc.json
or prettier
field in package.json
prettier.configFile
File name of Stylelint configuration
-
package.json
(prettier
field) .prettierrc
.prettierrc.json
.prettierrc.yaml
.prettierrc.js
prettier.ignore
Content of .prettierignore
makeCli({
eslint: {
ignore: `node_modules/
build/
coverage/
dist/
package-lock.json
pnpm-lock.yaml
yarn.lock
`,
},
});
editorconfig
Content of .editorconfig
:
makeCli({
editorconfig: `# Generated by lint-init
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
quote_type = single
`,
});
vscode
VS Code configuration
vscode.settings
Content of .vscode/settings.json
:
makeCli({
vscode: {
settings: {
'eslint.validate': ['javascript', 'typescript'],
'editor.codeActionsOnSave': {
'source.fixAll.eslint': true,
'source.organizeImports': true,
},
'editor.defaultFormatter': 'esbenp.prettier-vscode',
'editor.formatOnSave': true,
'editor.rulers': [100],
'[javascript]': {
'editor.defaultFormatter': 'esbenp.prettier-vscode',
},
'[typescript]': {
'editor.defaultFormatter': 'esbenp.prettier-vscode',
},
'[json]': {
'editor.defaultFormatter': 'esbenp.prettier-vscode',
},
'[jsonc]': {
'editor.defaultFormatter': 'esbenp.prettier-vscode',
},
},
},
});
vscode.extensions
Content of .vscode/extensions.json
:
makeCli({
vscode: {
extensions: {
recommendations: [
'dbaeumer.vscode-eslint',
'editorconfig.editorconfig',
'esbenp.prettier-vscode',
],
},
},
});