Skip to content

Commit

Permalink
chore: remove linting on git commit (#4566)
Browse files Browse the repository at this point in the history
* chore: remove linting on git commit

* chore: remove unused eslint disables

* chore: fix typo
Lukas Holzer authored Oct 5, 2022
1 parent bfc9792 commit ea23640
Showing 75 changed files with 4,721 additions and 6,644 deletions.
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

158 changes: 49 additions & 109 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,132 +1,72 @@
module.exports = {
extends: ['plugin:fp/recommended', '@netlify/eslint-config-node/.eslintrc_esm.cjs'],
/** @type {import('eslint').Linter.Config} */
const config = {
env: {
es2021: true,
node: true,
},
settings: {
'import/extensions': ['.js'],
},
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'plugin:ava/recommended', 'prettier'],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
},
plugins: ['import', '@typescript-eslint'],

ignorePatterns: [
// TODO: remove when they are migrated to typescript
'packages/build/test-d/**',
'packages/build/types/**',
// don't lint fixtures
'packages/*/tests/**/fixtures/**',
],
rules: {
strict: 2,
'max-lines': 'off',
// eslint-plugin-ava needs to know where test files are located
'ava/no-ignored-test-files': [
2,
{ files: ['tests/**/*.{cjs,mjs,js}', '!tests/{helpers,fixtures}/**/*.{cjs,mjs,js,json}'] },
],
'ava/no-import-test-files': [
2,
{ files: ['tests/**/*.{cjs,mjs,js}', '!tests/{helpers,fixtures}/**/*.{cjs,mjs,js,json}'] },
],
// -----------------------------------------------------------
// General rules
strict: 'error',

// -----------------------------------------------------------
// Typescript rules
'@typescript-eslint/no-explicit-any': ['off'],

// `eslint-plugin-node` seems to have a bug finding `chalk`
// 'n/no-missing-import': [2, { allowModules: ['chalk'] }],
'n/no-missing-import': 'off',
'import/no-unresolved': 'off',
'n/no-unpublished-require': 'off',
'n/no-missing-require': 'off',
'unicorn/no-process-exit': 'off',
'fp/no-mutating-methods': 'off',
'no-param-reassign': 'off',
'fp/no-mutation': 'off',
'fp/no-delete': 'off',
// -----------------------------------------------------------
// Import rules
'import/extensions': ['error', 'ignorePackages'], // This requires for esm modules .js file extensions on relative paths
'import/no-absolute-path': ['error'],
'import/no-cycle': ['error', { ignoreExternal: true }],
'import/no-duplicates': ['error', { considerQueryString: true }],
'import/no-self-import': ['error'],
'import/no-mutable-exports': ['error'],
'import/no-useless-path-segments': ['error'],
'import/order': [
'error',
{
'newlines-between': 'always',
alphabetize: {
order: 'asc',
caseInsensitive: true,
},
},
],
},
overrides: [
// ...overrides,
{
files: ['**/fixtures/**/*.{cjs,mjs,js}'],
rules: {
'import/no-unresolved': 0,
'n/no-missing-import': 0,
},
},
// @todo As it stands, this rule is problematic with methods that get+send
// many parameters, such as `runStep` in `src/steps/run_step.js`.
// We should discuss whether we want to keep this rule or discontinue it.
{
files: ['packages/build/**/*.{cjs,mjs,js}'],
rules: {
'max-lines-per-function': 'off',
},
},
{
files: ['**/test-d/**/*.ts'],
rules: {
// We use `tsd` which sometimes require declaring variables without
// using them
'@typescript-eslint/no-unused-vars': 0,
// Allow self-imports
'n/no-extraneous-import': 0,
},
},
{
// **/*.md/*.js references code blocks inside markdown files
files: ['**/*.md/*.js'],
rules: {
// Allow self-imports
'n/no-extraneous-import': 0,
},
},
// `@netlify/config` currently imports some test helpers from
// `@netlify/build`.
// This is creating linting issues, but only on Windows for some reason.
{
files: ['packages/config/tests/helpers/main.js'],
rules: {
'import/named': 0,
},
},
// TODO: remove once we use named exports in test fixtures
{
files: ['packages/build/tests/**/fixtures/**/*.{mjs,js}'],
rules: {
'import/no-anonymous-default-export': 0,
},
},
// Disabling certain rules for test files.
{
files: ['packages/build/tests/**/*.{mjs,js}'],
rules: {
'import/no-named-as-default-member': 'off',
'max-statements': 'off',
'no-magic-numbers': 'off',
},
},
{
files: ['packages/*/tests/**/*.{mjs,js}'],
files: ['packages/*/tests/**'],
rules: {
// @netlify/testing is a private package and therefore hoisted to the root without the need to ad it to devDependencies
'import/no-extraneous-dependencies': 'off',
'n/no-extraneous-import': 'off',
'import/no-unresolved': 'off',
'n/no-missing-import': 'off',
},
},
{ files: ['**/*.js'], rules: { 'import/extensions': ['error', 'ignorePackages', { ts: 'never' }] } },
{
files: ['**/*.ts'],
rules: {
'import/no-absolute-path': ['error'],
'import/no-cycle': ['error', { ignoreExternal: true }],
'import/no-duplicates': ['error', { considerQueryString: true }],
'import/no-self-import': ['error'],
'import/no-mutable-exports': ['error'],
'import/no-useless-path-segments': ['error'],
'n/no-missing-import': 'off',
'fp/no-this': 'off',
'fp/no-mutation': 'off',
'fp/no-class': 'off',
'fp/no-mutating-methods': 'off',
// this is some weird override as the base rules are doing strange stuff should be: 'import/extensions': ['error', 'ignorePackages'],
'import/extensions': ['error', 'ignorePackages', { ts: 'never' }],
'@typescript-eslint/no-empty-function': 'off',
'ava/no-ignored-test-files': [
2,
{ files: ['**/tests.js', 'tests/**/*.js', '!tests/{helpers,fixtures}/**/*.{cjs,mjs,js,json}'] },
],
'ava/no-import-test-files': [
2,
{ files: ['**/tests.js', 'tests/**/*.js', '!tests/{helpers,fixtures}/**/*.{cjs,mjs,js,json}'] },
],
},
},
],
}

module.exports = config
4 changes: 3 additions & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -12,7 +12,9 @@ Explain the **motivation** for making this change. What existing problem does th

For us to review and ship your PR efficiently, please perform the following steps:

- [ ] Open a [bug/issue](https://github.com/netlify/build/issues/new/choose) before writing your code 🧑‍💻. This ensures we can discuss the changes and get feedback from everyone that should be involved. If you\`re fixing a typo or something that\`s on fire 🔥 (e.g. incident related), you can skip this step.
- [ ] Open a [bug/issue](https://github.com/netlify/build/issues/new/choose) before writing your code 🧑‍💻. This ensures
we can discuss the changes and get feedback from everyone that should be involved. If you\`re fixing a typo or
something that\`s on fire 🔥 (e.g. incident related), you can skip this step.
- [ ] Read the [contribution guidelines](../CONTRIBUTING.md) 📖. This ensures your code follows our style guide and
passes our tests.
- [ ] Update or add tests (if any source code was changed or added) 🧪
8 changes: 5 additions & 3 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
@@ -32,10 +32,12 @@ jobs:
run: npm ci
if: ${{ !steps.release-check.outputs.IS_RELEASE }}
- name: Build workspaces
run: npx lerna run build
run: npm run build
if: ${{ !steps.release-check.outputs.IS_RELEASE }}
- name: Linting
run: npm run format:ci
run: |
npm run format:ci
npm run lint:ci
if: ${{ !steps.release-check.outputs.IS_RELEASE }}
test:
runs-on: ${{ matrix.os }}
@@ -113,7 +115,7 @@ jobs:
run: ${{ matrix.install-command }}
if: ${{ !steps.release-check.outputs.IS_RELEASE }}
- name: Build workspaces
run: npx lerna run build
run: npm run build
if: ${{ !steps.release-check.outputs.IS_RELEASE }}
- name: Tests
run: npm run test:ci
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx --no -- commitlint --edit
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# don't format fixtures (sometimes faulty behaviour is desired)
packages/*/tests/**/fixtures/**
# don't lint outputs
packages/*/lib
8 changes: 7 additions & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
"@netlify/eslint-config-node/.prettierrc.json"
{
"semi": false,
"singleQuote": true,
"printWidth": 120,
"proseWrap": "always",
"trailingComma": "all"
}
9 changes: 8 additions & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
{"packages/build":"27.20.1","packages/cache-utils":"4.1.5","packages/config":"18.2.4","packages/functions-utils":"4.2.10","packages/git-utils":"4.1.2","packages/run-utils":"4.0.2"}
{
"packages/build": "27.20.1",
"packages/cache-utils": "4.1.5",
"packages/config": "18.2.4",
"packages/functions-utils": "4.2.10",
"packages/git-utils": "4.1.2",
"packages/run-utils": "4.0.2"
}
5 changes: 3 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -53,8 +53,9 @@ After submitting the pull request, please make sure the Continuous Integration c

### Testing in CI

To speed up CI, we load balance the tests across multiple machines. The information required to load balance the tests is stored in `tests-metadata.json`, and later used by our test [runner](ava.config.js#L10).
To regenerate the data (e.g. when adding a new test file) run `npm test:measure` and commit the changes to GitHub.
To speed up CI, we load balance the tests across multiple machines. The information required to load balance the tests
is stored in `tests-metadata.json`, and later used by our test [runner](ava.config.js#L10). To regenerate the data (e.g.
when adding a new test file) run `npm test:measure` and commit the changes to GitHub.

## Releasing

2 changes: 0 additions & 2 deletions ava.base.js
Original file line number Diff line number Diff line change
@@ -3,11 +3,9 @@ import path from 'path'
import process from 'process'
import { fileURLToPath } from 'url'

// eslint-disable-next-line n/no-unpublished-import
import { isCI } from 'ci-info'

// `tests-metadata.json` is created by running `npm run test:measure`
// eslint-disable-next-line n/no-sync
const testData = JSON.parse(fs.readFileSync(fileURLToPath(new URL('tests-metadata.json', import.meta.url))))

const getOrder = (file) => {
Loading

0 comments on commit ea23640

Please sign in to comment.