Skip to content

Commit bfb1a8f

Browse files
Fix input value not being set if the value was '0'
Fixes #4669. Input component now uses govukAttributes macro to validate and format attributes. Test and example added for edge case outlined in issue #4669. Co-authored-by: Colin Rotherham <[email protected]>
1 parent 281e39a commit bfb1a8f

File tree

7 files changed

+621
-10
lines changed

7 files changed

+621
-10
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ We've made fixes to GOV.UK Frontend in the following pull requests:
4343

4444
- [#4942: Remove duplicate `errorMessage` argument for the password input component](https://github.com/alphagov/govuk-frontend/pull/4942) - thanks to [Tim South](https://github.com/tim-s-ccs) for contributing this change
4545
- [#4961: Fix tree-shaking when importing `govuk-frontend`](https://github.com/alphagov/govuk-frontend/pull/4961)
46+
- [#4963: Fix input value not being set if the value was '0'](https://github.com/alphagov/govuk-frontend/pull/4963) – thanks to [@dwp-dmitri-algazin](https://github.com/dwp-dmitri-algazin) for reporting this issue
4647

4748
## 5.3.1 (Fix release)
4849

eslint.config.mjs

+185
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
import prettier from 'eslint-config-prettier';
2+
import standard from 'eslint-config-standard';
3+
import js from "@eslint/js";
4+
5+
import * as importPlugin from 'eslint-plugin-import';
6+
import jest from 'eslint-plugin-jest';
7+
import promise from 'eslint-plugin-promise';
8+
import markdown from 'eslint-plugin-markdown';
9+
10+
const nodePlugin = require("eslint-plugin-n");
11+
12+
13+
export default [
14+
standard,
15+
prettier,
16+
js.configs.recommended,
17+
nodePlugin.configs["flat/recommended-script"],
18+
{
19+
ignores: [
20+
'**/dist/**',
21+
'**/vendor/**',
22+
23+
// Enable dotfile linting
24+
'!.*',
25+
'node_modules',
26+
'node_modules/.*',
27+
28+
// Prevent CHANGELOG history changes
29+
'CHANGELOG.md'
30+
],
31+
},
32+
{
33+
files: [
34+
'**/*.{cjs,js,mjs}',
35+
36+
// Check markdown `*.md` contains valid code blocks
37+
// https://github.com/eslint/eslint-plugin-markdown#advanced-configuration
38+
'**/*.md/*.{cjs,js,mjs}'
39+
],
40+
plugins: {
41+
jest,
42+
promise,
43+
importPlugin,
44+
markdown
45+
},
46+
rules: {
47+
// Check import or require statements are A-Z ordered
48+
'import/order': [
49+
'error',
50+
{
51+
alphabetize: { order: 'asc' },
52+
'newlines-between': 'always'
53+
}
54+
],
55+
56+
// Check for valid formatting
57+
'jsdoc/check-line-alignment': [
58+
'warn',
59+
'never',
60+
{
61+
wrapIndent: ' '
62+
}
63+
],
64+
65+
// JSDoc blocks can use `@preserve` to prevent removal
66+
'jsdoc/check-tag-names': [
67+
'warn',
68+
{
69+
definedTags: ['preserve']
70+
}
71+
],
72+
73+
// JSDoc blocks are optional by default
74+
'jsdoc/require-jsdoc': 'off',
75+
76+
// JSDoc @param required in (optional) blocks but
77+
// @param description is not necessary by default
78+
'jsdoc/require-param-description': 'off',
79+
'jsdoc/require-param': 'error',
80+
81+
// Require hyphens before param description
82+
// Aligns with TSDoc style: https://tsdoc.org/pages/tags/param/
83+
'jsdoc/require-hyphen-before-param-description': 'warn',
84+
85+
// Maintain new line after description
86+
'jsdoc/tag-lines': [
87+
'warn',
88+
'never',
89+
{
90+
startLines: 1
91+
}
92+
],
93+
94+
// Ignore `govuk-frontend` exports as they require auto-generated files
95+
'import/no-unresolved': ['error', { ignore: ['govuk-frontend'] }],
96+
'n/no-missing-import': ['error', { allowModules: ['govuk-frontend'] }],
97+
'n/no-missing-require': ['error', { allowModules: ['govuk-frontend'] }],
98+
99+
// Automatically use template strings
100+
'no-useless-concat': 'error',
101+
'prefer-template': 'error',
102+
103+
// Flow control – avoid continue and else blocks after return statements
104+
// in if statements
105+
'no-continue': 'error',
106+
'no-else-return': 'error',
107+
108+
// Avoid hard to read multi assign statements
109+
'no-multi-assign': 'error',
110+
111+
settings: {
112+
jsdoc: {
113+
// Allows us to use type declarations that exist in our dependencies
114+
mode: 'typescript'
115+
}
116+
}
117+
},
118+
},
119+
{
120+
// Extensions required for ESM import
121+
files: ['**/*.mjs'],
122+
rules: {
123+
'import/extensions': [
124+
'error',
125+
'always',
126+
{
127+
ignorePackages: true,
128+
pattern: {
129+
cjs: 'always',
130+
js: 'always',
131+
mjs: 'always'
132+
}
133+
}
134+
]
135+
}
136+
},
137+
{
138+
files: ['**/*.test.{cjs,js,mjs}'],
139+
env: {
140+
jest: true
141+
}
142+
},
143+
{
144+
// Matches Puppeteer environment in jest.config.mjs
145+
// to ignore unknown Jest Puppeteer globals
146+
files: ['**/*.puppeteer.test.{js,mjs}'],
147+
globals: {
148+
page: 'readonly',
149+
browser: 'readonly',
150+
jestPuppeteer: 'readonly'
151+
}
152+
},
153+
{
154+
files: ['**/*.md'],
155+
processor: 'markdown/markdown'
156+
},
157+
{
158+
files: [
159+
'**/coding-standards/component-options.md/*.{cjs,js,mjs}',
160+
'**/coding-standards/js.md/*.{cjs,js,mjs}'
161+
],
162+
env: {
163+
browser: true
164+
},
165+
rules: {
166+
// Ignore unused example code
167+
'no-new': 'off',
168+
'no-undef': 'off',
169+
'no-unused-expressions': 'off',
170+
'no-unused-vars': 'off',
171+
'no-useless-constructor': 'off',
172+
173+
// Ignore paths to example modules
174+
'import/no-unresolved': 'off',
175+
'n/no-missing-import': 'off'
176+
}
177+
},
178+
{
179+
languageOptions: {
180+
parserOptions: {
181+
project: './tsconfig.json'
182+
},
183+
},
184+
}
185+
]

nothing

+177
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
module.exports = {
2+
extends: ['standard', 'prettier'],
3+
ignorePatterns: [
4+
'**/dist/**',
5+
'**/vendor/**',
6+
7+
// Enable dotfile linting
8+
'!.*',
9+
'node_modules',
10+
'node_modules/.*',
11+
12+
// Prevent CHANGELOG history changes
13+
'CHANGELOG.md'
14+
],
15+
overrides: [
16+
{
17+
extends: [
18+
'eslint:recommended',
19+
'plugin:import/recommended',
20+
'plugin:jest/style',
21+
'plugin:jsdoc/recommended-typescript-flavor',
22+
'plugin:n/recommended',
23+
'plugin:promise/recommended',
24+
'prettier'
25+
],
26+
files: [
27+
'**/*.{cjs,js,mjs}',
28+
29+
// Check markdown `*.md` contains valid code blocks
30+
// https://github.com/eslint/eslint-plugin-markdown#advanced-configuration
31+
'**/*.md/*.{cjs,js,mjs}'
32+
],
33+
parserOptions: {
34+
ecmaVersion: 'latest'
35+
},
36+
plugins: ['import', 'jsdoc', 'n', 'promise', 'jest'],
37+
rules: {
38+
// Check import or require statements are A-Z ordered
39+
'import/order': [
40+
'error',
41+
{
42+
alphabetize: { order: 'asc' },
43+
'newlines-between': 'always'
44+
}
45+
],
46+
47+
// Check for valid formatting
48+
'jsdoc/check-line-alignment': [
49+
'warn',
50+
'never',
51+
{
52+
wrapIndent: ' '
53+
}
54+
],
55+
56+
// JSDoc blocks can use `@preserve` to prevent removal
57+
'jsdoc/check-tag-names': [
58+
'warn',
59+
{
60+
definedTags: ['preserve']
61+
}
62+
],
63+
64+
// JSDoc blocks are optional by default
65+
'jsdoc/require-jsdoc': 'off',
66+
67+
// JSDoc @param required in (optional) blocks but
68+
// @param description is not necessary by default
69+
'jsdoc/require-param-description': 'off',
70+
'jsdoc/require-param': 'error',
71+
72+
// Require hyphens before param description
73+
// Aligns with TSDoc style: https://tsdoc.org/pages/tags/param/
74+
'jsdoc/require-hyphen-before-param-description': 'warn',
75+
76+
// Maintain new line after description
77+
'jsdoc/tag-lines': [
78+
'warn',
79+
'never',
80+
{
81+
startLines: 1
82+
}
83+
],
84+
85+
// Ignore `govuk-frontend` exports as they require auto-generated files
86+
'import/no-unresolved': ['error', { ignore: ['govuk-frontend'] }],
87+
'n/no-missing-import': ['error', { allowModules: ['govuk-frontend'] }],
88+
'n/no-missing-require': ['error', { allowModules: ['govuk-frontend'] }],
89+
90+
// Automatically use template strings
91+
'no-useless-concat': 'error',
92+
'prefer-template': 'error',
93+
94+
// Flow control – avoid continue and else blocks after return statements
95+
// in if statements
96+
'no-continue': 'error',
97+
'no-else-return': 'error',
98+
99+
// Avoid hard to read multi assign statements
100+
'no-multi-assign': 'error'
101+
},
102+
settings: {
103+
jsdoc: {
104+
// Allows us to use type declarations that exist in our dependencies
105+
mode: 'typescript'
106+
}
107+
}
108+
},
109+
{
110+
// Extensions required for ESM import
111+
files: ['**/*.mjs'],
112+
rules: {
113+
'import/extensions': [
114+
'error',
115+
'always',
116+
{
117+
ignorePackages: true,
118+
pattern: {
119+
cjs: 'always',
120+
js: 'always',
121+
mjs: 'always'
122+
}
123+
}
124+
]
125+
}
126+
},
127+
{
128+
files: ['**/*.test.{cjs,js,mjs}'],
129+
env: {
130+
jest: true
131+
}
132+
},
133+
{
134+
// Matches Puppeteer environment in jest.config.mjs
135+
// to ignore unknown Jest Puppeteer globals
136+
files: ['**/*.puppeteer.test.{js,mjs}'],
137+
globals: {
138+
page: 'readonly',
139+
browser: 'readonly',
140+
jestPuppeteer: 'readonly'
141+
}
142+
},
143+
{
144+
// Add plugin for markdown `*.md` code blocks. Its config is in the new
145+
// "flat" format, so we need to use the legacy config
146+
extends: ['plugin:markdown/recommended-legacy'],
147+
files: ['**/*.md'],
148+
plugins: ['markdown'],
149+
processor: 'markdown/markdown'
150+
},
151+
{
152+
files: [
153+
'**/coding-standards/component-options.md/*.{cjs,js,mjs}',
154+
'**/coding-standards/js.md/*.{cjs,js,mjs}'
155+
],
156+
env: {
157+
browser: true
158+
},
159+
rules: {
160+
// Ignore unused example code
161+
'no-new': 'off',
162+
'no-undef': 'off',
163+
'no-unused-expressions': 'off',
164+
'no-unused-vars': 'off',
165+
'no-useless-constructor': 'off',
166+
167+
// Ignore paths to example modules
168+
'import/no-unresolved': 'off',
169+
'n/no-missing-import': 'off'
170+
}
171+
}
172+
],
173+
parserOptions: {
174+
project: './tsconfig.json'
175+
},
176+
root: true
177+
}

0 commit comments

Comments
 (0)