Skip to content

Commit 751162d

Browse files
committed
Set up linters
1 parent 1f22eb5 commit 751162d

31 files changed

+5675
-271
lines changed

.browserslistrc

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
last 2 Chrome versions
2+
last 2 Edge versions
3+
last 2 Firefox versions
4+
last 2 Safari versions

.github/workflows/lint.yml

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Linting
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
cache-keys:
9+
name: Setup – Cache keys
10+
runs-on: ubuntu-latest
11+
12+
outputs:
13+
build: build-${{ steps.build.outputs.hash }}-v2
14+
dot-cache: dot-cache-${{ github.event.number }}-v1
15+
node-modules: node-modules-${{ steps.node-modules.outputs.hash }}-v1
16+
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- id: build
22+
run: echo "::set-output name=hash::${{ hashFiles('assets/**', 'content/**', 'layouts/**', 'static/**', '**/package.json', '**/package-lock.json') }}"
23+
24+
- id: node-modules
25+
run: echo "::set-output name=hash::${{ hashFiles('**/package-lock.json') }}"
26+
27+
test-lint:
28+
name: Test – Lint
29+
needs: cache-keys
30+
runs-on: ubuntu-latest
31+
32+
steps:
33+
- name: Checkout
34+
uses: actions/checkout@v4
35+
36+
- uses: actions/setup-node@v4
37+
with:
38+
node-version: '20'
39+
40+
- name: Get cached dependencies
41+
uses: actions/cache@v4
42+
with:
43+
path: |
44+
node_modules
45+
key: ${{ needs.cache-keys.outputs.node-modules }}
46+
47+
- name: Check that package-lock.json is valid JSON
48+
run: jq empty package-lock.json
49+
50+
- name: Install dependencies
51+
run: npm ci
52+
53+
- name: Run linters
54+
run: npm run lint

.github/workflows/prettier.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Prettier
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
prettier:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v4
14+
with:
15+
persist-credentials: false
16+
17+
- name: Prettify code
18+
uses: creyD/[email protected]
19+
with:
20+
dry: True
21+
prettier_options: --check assets/js/**

.precious.toml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
[commands.lint-scripts]
2+
type = "lint"
3+
cmd = [
4+
"npm",
5+
"run",
6+
"lint:scripts"
7+
]
8+
invoke = "once"
9+
include = ["assets/js/**/*.{ts}"]
10+
ok-exit-codes = 0
11+
12+
[commands.stylelint-styles]
13+
type="both"
14+
cmd = [
15+
"npx",
16+
"stylelint"
17+
]
18+
lint-flags = []
19+
tidy-flags = ["--fix"]
20+
path-args = "absolute-file"
21+
include = ["assets/scss/**"]
22+
ok-exit-codes = 0
23+
24+
[commands.prettier-scripts]
25+
type = "both"
26+
cmd = [
27+
"npx",
28+
"prettier",
29+
"--write"
30+
]
31+
lint-flags = ["--check"]
32+
tidy-flags = ["--write"]
33+
path-args = "absolute-file"
34+
include = ["assets/js/**"]
35+
ok-exit-codes = 0
36+

.stylelintrc.js

+160
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
/* eslint-disable @typescript-eslint/no-require-imports */
2+
const path = require('path');
3+
4+
module.exports = {
5+
configBasedir: path.resolve(__dirname),
6+
defaultSeverity: 'error',
7+
extends: [
8+
'stylelint-config-recommended',
9+
'stylelint-config-sass-guidelines',
10+
],
11+
plugins: [
12+
'stylelint-no-unsupported-browser-features',
13+
'stylelint-order',
14+
],
15+
rules: {
16+
'max-nesting-depth': 4,
17+
'order/order': [
18+
'custom-properties',
19+
'declarations',
20+
],
21+
'order/properties-alphabetical-order': true,
22+
'plugin/no-unsupported-browser-features': [
23+
true,
24+
{
25+
ignore: [
26+
/**
27+
* Partial support - IE11
28+
*
29+
* Partial support in IE11 refers to calc not working properly
30+
* with various use cases mentioned in known issues
31+
*
32+
* https://caniuse.com/calc
33+
*/
34+
'calc',
35+
36+
/**
37+
* Not supported - IE 11
38+
* Partial support - Safari
39+
*
40+
* https://caniuse.com/?search=appearance
41+
*/
42+
'css-appearance',
43+
44+
/**
45+
* Not supported - IE11
46+
*
47+
* https://caniuse.com/?search=css-featurequeries
48+
*/
49+
'css-featurequeries',
50+
51+
/**
52+
* Not supported - IE11
53+
*
54+
* https://caniuse.com/?search=css%20filters
55+
*/
56+
'css-filters',
57+
58+
/**
59+
* Partial support - Safari
60+
*
61+
* Partial support in Safari and Older Firefox versions refers to
62+
* not using premultiplied colors which results in unexpected
63+
* behavior when using the transparent keyword as advised by the
64+
* spec.
65+
*
66+
* https://caniuse.com/?search=css-gradients
67+
*/
68+
'css-gradients',
69+
70+
/**
71+
* Not supported - IE11
72+
*
73+
* https://caniuse.com/?search=css-initial-value
74+
*/
75+
'css-initial-value',
76+
77+
/**
78+
* Not supported - IE11
79+
*
80+
* Partial support - Chromium
81+
*
82+
* Supported on th elements, but not thead or tr
83+
*
84+
* Partial support - Firefox
85+
*
86+
* Not supported on any table parts
87+
*
88+
* https://caniuse.com/?search=css-sticky
89+
*/
90+
'css-sticky',
91+
92+
/**
93+
* Partial support - IE11
94+
*
95+
* Partial support is due to large amount of bugs present.
96+
*
97+
* https://caniuse.com/?search=flexbox
98+
*/
99+
'flexbox',
100+
101+
/**
102+
* Partial support - Chromium, Firefox
103+
*
104+
* Partial support refers to not supporting the avoid-column,
105+
* column, and avoid (in the column context) values for the
106+
* properties break-before, break-after, and break-inside.
107+
*
108+
* https://caniuse.com/?search=multicolumn
109+
*/
110+
'multicolumn',
111+
112+
/**
113+
* Partial support - IE11
114+
*
115+
* Supports the value of invert for outline-color.
116+
* Does not support outline-offset.
117+
*
118+
* https://caniuse.com/?search=outline
119+
*/
120+
'outline',
121+
122+
/**
123+
* Partial support - IE11
124+
*
125+
* Partial support in IE refers to not supporting the
126+
* `transform-style: preserve-3d` property. This prevents nesting 3D
127+
* transformed elements.
128+
*
129+
* https://caniuse.com/?search=transforms3d
130+
*/
131+
'transforms3d',
132+
133+
/**
134+
* Partial support - IE11
135+
*
136+
* Partial support refers to not supporting the "vmax" unit.
137+
*
138+
* https://caniuse.com/viewport-units
139+
*/
140+
'viewport-units',
141+
],
142+
},
143+
],
144+
'selector-class-pattern': [
145+
'[a-z]([a-zA-Z0-9]+)?$',
146+
{
147+
resolveNestedSelectors: true,
148+
},
149+
],
150+
'selector-max-compound-selectors': 5,
151+
'selector-pseudo-class-no-unknown': [
152+
true,
153+
{
154+
ignorePseudoClasses: [
155+
'global',
156+
],
157+
},
158+
],
159+
},
160+
};

README.md

+35-21
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<h3 align="center">
1+
<h1 align="center">
22
<img
33
alt="MaxMind"
44
src="assets/maxmind-logo.svg"
@@ -7,9 +7,9 @@
77
<br>
88
<br>
99
<small>Developer Documentation Static Site Generator</small>
10-
</h3>
10+
</h1>
1111
12-
* * *
12+
---
1313

1414
## Overview
1515

@@ -23,16 +23,15 @@
2323
- [Installation](#installation)
2424
- [Development](#development)
2525
- [Development Server](#development-server)
26-
- [Static Server](#static-server)
27-
- [Testing](#testing)
28-
- [Deployments](#deployments)
2926
- [Updating Release Notes for the New Year](#updating-release-notes-for-the-new-year)
3027

3128
### Minimum Requirements
3229

33-
The minimum Node and NPM versions can be found in the [package.json file](package.json) under `engines`.
30+
The minimum Node and NPM versions can be found in the
31+
[package.json file](package.json) under `engines`.
3432

35-
If you need help installing and/or managing Node and NPM versions, check out [NVM](https://github.com/nvm-sh/nvm).
33+
If you need help installing and/or managing Node and NPM versions, check out
34+
[NVM](https://github.com/nvm-sh/nvm).
3635

3736
### Installation
3837

@@ -42,6 +41,12 @@ npm install
4241

4342
- `npm install` installs the necessary node modules for development.
4443

44+
#### Install Precious
45+
46+
You should install our pre-commit hook. You can do this from your checkout
47+
by running `git/setup.sh`. These hooks do things like ensure that the code you
48+
commit is tidy and passes various linter checks.
49+
4550
#### Install Hugo
4651

4752
##### Homebrew (macOS)
@@ -86,15 +91,18 @@ Whenever you create your first release note for a product category for a new
8691
year:
8792

8893
1. Add a file called `<year>.md` to the `/content/<product>/release-notes`
89-
folder. (e.g., `/content/geoip/release-notes/2024.md`)
90-
- Add the header to your new release note file with the title: `<Product> Release Notes`
91-
(e.g., `GeoIP2 Release Notes`) and draft to `false`.
92-
- Add the RSS notification to the top of the new file.
93-
2. Change the `title:` field in the previous year's `md` file to read: `<Product> Release Notes - <Year> Archive`
94-
(e.g., `GeoIP2 Release Notes - 2023 Archive`)
95-
- Remove the RSS notification from the top of the archived file.
96-
3. Update link to the release notes in the navigation menu (`hugo.toml`) to point to the current year's path.
97-
4. Update the URLs in the redirects file (`static/_redirects`) to the current year's path.
94+
folder. (e.g., `/content/geoip/release-notes/2024.md`) - Add the header to
95+
your new release note file with the title: `<Product> Release Notes` (e.g.,
96+
`GeoIP2 Release Notes`) and draft to `false`. - Add the RSS notification to
97+
the top of the new file.
98+
2. Change the `title:` field in the previous year's `md` file to read:
99+
`<Product> Release Notes - <Year> Archive` (e.g.,
100+
`GeoIP2 Release Notes - 2023 Archive`) - Remove the RSS notification from the
101+
top of the archived file.
102+
3. Update link to the release notes in the navigation menu (`hugo.toml`) to
103+
point to the current year's path.
104+
4. Update the URLs in the redirects file (`static/_redirects`) to the current
105+
year's path.
98106

99107
### Updating Example CSVs
100108

@@ -104,8 +112,11 @@ internal oneoffs repository.
104112
### Adding Page Metadata for SEO and Social Sharing
105113

106114
#### Adding a description
107-
In the markdown (mdx) file, add a `description` to the frontmatter located at the top of the file:
108-
```
115+
116+
In the markdown (mdx) file, add a `description` to the frontmatter located at
117+
the top of the file:
118+
119+
```md
109120
---
110121
draft: false
111122
title: GeoIP2 is the best
@@ -117,9 +128,12 @@ description: GeoIP2 is the bestest IP Intelligence product suite ever made
117128

118129
1. Add your image to the [static/images](static/images) directory.
119130

120-
2. In the markdown (mdx) file, add the path to the `image` key in the frontmatter located at the top of the file. **Do not include `static` to the path.** For example, if your file is at `static/images/geoip2-so-cool.gif`, your frontmatter would look like:
131+
2. In the markdown (mdx) file, add the path to the `image` key in the
132+
frontmatter located at the top of the file. **Do not include `static` to the
133+
path.** For example, if your file is at `static/images/geoip2-so-cool.gif`,
134+
your frontmatter would look like:
121135

122-
```
136+
```md
123137
---
124138
draft: false
125139
title: GeoIP2 is the best

0 commit comments

Comments
 (0)