Skip to content

Commit

Permalink
ci: linting (#4)
Browse files Browse the repository at this point in the history
* ci: disable lint temporarly

* ci: disable npm cache

* ci: add pnpm cache

* ci: add cache dir

* feat: add changesets

* fix: wrong version for dep

* feat: add linting action task
  • Loading branch information
lotyp authored Dec 13, 2022
1 parent 3d80edb commit 89ee0b7
Show file tree
Hide file tree
Showing 17 changed files with 160 additions and 156 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
uses: actions/cache@v3
with:
path: node_modules
key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
key: pnpm-${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}

- name: Install frontend dependencies
if: steps.cached-pnpm-dependencies.outputs.cache-hit != 'true'
Expand Down
4 changes: 4 additions & 0 deletions .markdownlintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules/
CHANGELOG.md
**/node_modules/
**/CHANGELOG.md
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"scripts": {
"prepare": "husky install",
"lint": "pnpm run lint:md && pnpm run lint:js && pnpm run lint:secrets",
"lint:md": "markdownlint --fix **/*.md --ignore node_modules --ignore **/CHANGELOG.md",
"lint:md": "markdownlint --fix **/*.md",
"lint:js": "eslint --fix **/*.js",
"lint:secrets": "secretlint **/*"
},
Expand Down
10 changes: 5 additions & 5 deletions packages/commitizen-config/scripts/postinstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ const path = require('node:path');
const filePath = path.join(process.env.INIT_CWD, '.czrc');

const fileConfigObject = {
path: 'cz-conventional-changelog',
path: 'cz-conventional-changelog',
};

if (!fs.existsSync(filePath)) {
fs.writeFileSync(
filePath,
`${JSON.stringify(fileConfigObject, undefined, 2)}`
);
fs.writeFileSync(
filePath,
`${JSON.stringify(fileConfigObject, undefined, 2)}`
);
}
14 changes: 7 additions & 7 deletions packages/commitlint-config/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const automaticCommitPattern = /^chore\(release\):.*\[skip ci]/;

module.exports = {
extends: ['@commitlint/config-conventional'],
/*
This resolves a linting conflict between commitlint's body-max-line-length
due to @semantic-release/git putting release notes in the commit body
https://github.com/semantic-release/git/issues/331
*/
ignores: [commitMessage => automaticCommitPattern.test(commitMessage)],
extends: ['@commitlint/config-conventional'],
/*
This resolves a linting conflict between commitlint's body-max-line-length
due to @semantic-release/git putting release notes in the commit body
https://github.com/semantic-release/git/issues/331
*/
ignores: [commitMessage => automaticCommitPattern.test(commitMessage)],
};
10 changes: 5 additions & 5 deletions packages/commitlint-config/scripts/postinstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ const path = require('node:path');
const filePath = path.join(process.env.INIT_CWD, 'commitlint.config.js');

const fileConfigObject = {
extends: '@wayofdev/commitlint-config',
extends: '@wayofdev/commitlint-config',
};

if (!fs.existsSync(filePath)) {
fs.writeFileSync(
filePath,
`module.exports = ${JSON.stringify(fileConfigObject, undefined, 2)}`
);
fs.writeFileSync(
filePath,
`module.exports = ${JSON.stringify(fileConfigObject, undefined, 2)}`
);
}
80 changes: 40 additions & 40 deletions packages/eslint-config/index.js
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
module.exports = {
// Plugins that provide the processors to parse code for linting
plugins: ['sonarjs', 'prettier'],
extends: [
'plugin:unicorn/recommended',
'plugin:promise/recommended',
'plugin:sonarjs/recommended',
'plugin:security/recommended',
// Uses the recommended rules from eslint
'eslint:recommended',
/*
Uses the recommended rules from eslint-config-airbnb-base
Note: depends on eslint-plugin-import to work
*/
'airbnb-base',
/*
Enables eslint-plugin-prettier and displays prettier errors as
ESLint errors. Make sure this is always the last configuration
in the extends array.
https://github.com/prettier/eslint-plugin-prettier#recommended-configuration
*/
'plugin:prettier/recommended',
],
// @babel/eslint-parser and prettier rules go here
rules: {
// https://github.com/prettier/eslint-config-prettier#max-len
'max-len': [
'error',
{
code: 80,
ignoreUrls: true,
},
// Plugins that provide the processors to parse code for linting
plugins: ['sonarjs', 'prettier'],
extends: [
'plugin:unicorn/recommended',
'plugin:promise/recommended',
'plugin:sonarjs/recommended',
'plugin:security/recommended',
// Uses the recommended rules from eslint
'eslint:recommended',
/*
Uses the recommended rules from eslint-config-airbnb-base
Note: depends on eslint-plugin-import to work
*/
'airbnb-base',
/*
Enables eslint-plugin-prettier and displays prettier errors as
ESLint errors. Make sure this is always the last configuration
in the extends array.
https://github.com/prettier/eslint-plugin-prettier#recommended-configuration
*/
'plugin:prettier/recommended',
],
// https://stackoverflow.com/questions/44939304/eslint-should-be-listed-in-the-projects-dependencies-not-devdependencies
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: true,
},
],
'unicorn/prefer-module': 0,
},
// @babel/eslint-parser and prettier rules go here
rules: {
// https://github.com/prettier/eslint-config-prettier#max-len
'max-len': [
'error',
{
code: 80,
ignoreUrls: true,
},
],
// https://stackoverflow.com/questions/44939304/eslint-should-be-listed-in-the-projects-dependencies-not-devdependencies
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: true,
},
],
'unicorn/prefer-module': 0,
},
};
12 changes: 6 additions & 6 deletions packages/eslint-config/jest.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module.exports = {
plugins: ['jest', 'jest-dom', 'jest-formatting'],
extends: [
'plugin:jest/recommended',
'plugin:jest-dom/recommended',
'plugin:jest-formatting/recommended',
],
plugins: ['jest', 'jest-dom', 'jest-formatting'],
extends: [
'plugin:jest/recommended',
'plugin:jest-dom/recommended',
'plugin:jest-formatting/recommended',
],
};
10 changes: 5 additions & 5 deletions packages/eslint-config/scripts/postinstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ const path = require('node:path');
const filePath = path.join(process.env.INIT_CWD, '.eslintrc.js');

const fileConfigObject = {
extends: '@wayofdev/eslint-config',
extends: '@wayofdev/eslint-config',
};

if (!fs.existsSync(filePath)) {
fs.writeFileSync(
filePath,
`module.exports = ${JSON.stringify(fileConfigObject, undefined, 2)}`
);
fs.writeFileSync(
filePath,
`module.exports = ${JSON.stringify(fileConfigObject, undefined, 2)}`
);
}
88 changes: 44 additions & 44 deletions packages/eslint-config/ts.js
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
module.exports = {
// Plugins that provide the processors to parse code for linting
plugins: ['sonarjs', '@typescript-eslint', 'prettier'],
/*
A parser that converts TypeScript into an ESTree-compatible
form so it can be used in ESLint.
*/
parser: '@typescript-eslint/parser',
extends: [
'plugin:unicorn/recommended',
'plugin:promise/recommended',
'plugin:sonarjs/recommended',
'plugin:security/recommended',
// Uses the recommended rules from the @typescript-eslint/eslint-plugin
'plugin:@typescript-eslint/recommended',
// Plugins that provide the processors to parse code for linting
plugins: ['sonarjs', '@typescript-eslint', 'prettier'],
/*
Uses the recommended rules from eslint-config-airbnb-typescript
depends on @typescript-eslint/eslint-plugin
and eslint-plugin-import to work
A parser that converts TypeScript into an ESTree-compatible
form so it can be used in ESLint.
*/
'airbnb-typescript/base',
/*
Enables eslint-plugin-prettier and displays prettier errors as
ESLint errors. Make sure this is always the last configuration
in the extends array.
https://github.com/prettier/eslint-plugin-prettier#recommended-configuration
*/
'plugin:prettier/recommended',
],
// @typescript-eslint/parser and prettier rules go here
rules: {
// https://github.com/prettier/eslint-config-prettier#max-len
'max-len': [
'error',
{
code: 80,
ignoreUrls: true,
},
],
// https://stackoverflow.com/questions/44939304/eslint-should-be-listed-in-the-projects-dependencies-not-devdependencies
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: true,
},
parser: '@typescript-eslint/parser',
extends: [
'plugin:unicorn/recommended',
'plugin:promise/recommended',
'plugin:sonarjs/recommended',
'plugin:security/recommended',
// Uses the recommended rules from the @typescript-eslint/eslint-plugin
'plugin:@typescript-eslint/recommended',
/*
Uses the recommended rules from eslint-config-airbnb-typescript
depends on @typescript-eslint/eslint-plugin
and eslint-plugin-import to work
*/
'airbnb-typescript/base',
/*
Enables eslint-plugin-prettier and displays prettier errors as
ESLint errors. Make sure this is always the last configuration
in the extends array.
https://github.com/prettier/eslint-plugin-prettier#recommended-configuration
*/
'plugin:prettier/recommended',
],
'unicorn/prefer-module': 0,
},
// @typescript-eslint/parser and prettier rules go here
rules: {
// https://github.com/prettier/eslint-config-prettier#max-len
'max-len': [
'error',
{
code: 80,
ignoreUrls: true,
},
],
// https://stackoverflow.com/questions/44939304/eslint-should-be-listed-in-the-projects-dependencies-not-devdependencies
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: true,
},
],
'unicorn/prefer-module': 0,
},
};
2 changes: 1 addition & 1 deletion packages/lint-staged-config/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable sonarjs/no-duplicate-string */
module.exports = {
'*.{js,jsx,ts,tsx}': ['prettier --cache --write', 'eslint --cache --fix'],
'*.{js,jsx,ts,tsx}': ['prettier --cache --write', 'eslint --cache --fix'],
};
8 changes: 4 additions & 4 deletions packages/lint-staged-config/scripts/postinstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ const path = require('node:path');
const filePath = path.join(process.env.INIT_CWD, 'lint-staged.config.js');

if (!fs.existsSync(filePath)) {
fs.writeFileSync(
filePath,
`module.exports = require('@wayofdev/lint-staged-config');`
);
fs.writeFileSync(
filePath,
`module.exports = require('@wayofdev/lint-staged-config');`
);
}
4 changes: 2 additions & 2 deletions packages/lint-staged-config/yml.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
'*.{yml,yaml}': ['prettier --cache --write', 'yamllint --strict .'],
'.github/workflows/*.{yml,yaml}': ['actionlint'],
'*.{yml,yaml}': ['prettier --cache --write', 'yamllint --strict .'],
'.github/workflows/*.{yml,yaml}': ['actionlint'],
};
10 changes: 5 additions & 5 deletions packages/markdownlint-config/scripts/postinstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ const path = require('node:path');
const filePath = path.join(process.env.INIT_CWD, '.markdownlint.json');

const fileConfigObject = {
extends: './node_modules/@wayofdev/markdownlint-config/index.json',
extends: './node_modules/@wayofdev/markdownlint-config/index.json',
};

if (!fs.existsSync(filePath)) {
fs.writeFileSync(
filePath,
`${JSON.stringify(fileConfigObject, undefined, 2)}`
);
fs.writeFileSync(
filePath,
`${JSON.stringify(fileConfigObject, undefined, 2)}`
);
}
42 changes: 21 additions & 21 deletions packages/prettier-config/index.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
module.exports = {
endOfLine: 'auto',
// https://prettier.io/docs/en/options.html#print-width
printWidth: 80,
tabWidth: 2,
arrowParens: 'avoid',
singleQuote: true,
semi: true,
trailingComma: 'es5',
bracketSpacing: true,
overrides: [
{
files: ['*.html'],
options: {
// disable to prevent conflicts with html-validate
trailingComma: 'none',
// https://prettier.io/blog/2018/11/07/1.15.0.html#whitespace-sensitive-formatting
htmlWhitespaceSensitivity: 'css',
singleAttributePerLine: true,
},
},
],
endOfLine: 'auto',
// https://prettier.io/docs/en/options.html#print-width
printWidth: 80,
tabWidth: 2,
arrowParens: 'avoid',
singleQuote: true,
semi: true,
trailingComma: 'es5',
bracketSpacing: true,
overrides: [
{
files: ['*.html'],
options: {
// disable to prevent conflicts with html-validate
trailingComma: 'none',
// https://prettier.io/blog/2018/11/07/1.15.0.html#whitespace-sensitive-formatting
htmlWhitespaceSensitivity: 'css',
singleAttributePerLine: true,
},
},
],
};
10 changes: 5 additions & 5 deletions packages/secretlint-config/index.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"rules": [
{
"id": "@secretlint/secretlint-rule-preset-recommend"
}
]
"rules": [
{
"id": "@secretlint/secretlint-rule-preset-recommend"
}
]
}
Loading

0 comments on commit 89ee0b7

Please sign in to comment.