Skip to content

Commit 78e40ce

Browse files
Merge pull request #336 from NordicSemiconductor/breaking_changes
Breaking changes
2 parents cc71618 + cd51422 commit 78e40ce

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+3284
-2167
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
/node_modules
2-
/jest.json
32
/pc-nrfconnect-shared-*.tgz
43
/coverage

Changelog.md

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to
77
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
88

9-
## Unreleased
9+
## 6.0.0 - 2022-04-11
1010

1111
### Added
1212

@@ -20,10 +20,80 @@ and this project adheres to
2020
- Type of `getPersistentStore` was changed to match more that from
2121
electron-store.
2222
- Bundle shared with the apps.
23+
- ESlint config file changed to `config/eslintrc.js`.
24+
- Ignore all entries from `.gitignore` in linting.
2325

2426
### Removed
2527

2628
- Support for `nrfconnect/core` as mocked or external module.
29+
- Obsolete `lint-init`.
30+
- `nrfconnect-scripts`.
31+
- Plugin `add-module-exports` from babel config because it caused problems
32+
with the latest version of `electron-store` (or, more concrete, with the
33+
dependency `atomically` which that pulled in.)
34+
- Running ESLint during build.
35+
36+
### Steps to upgrade when using this package
37+
38+
- Because this version removed `nrfconnect-scripts`, all invocations of it
39+
have to be replaced with direct invocations of the corresponding tools. So
40+
in `package.json` these entries in the `scripts` property should replace the
41+
previous entries:
42+
43+
```json
44+
{
45+
"scripts": {
46+
"dev": "webpack watch --mode development",
47+
"webpack": "webpack build --mode development",
48+
"build": "webpack build",
49+
"test": "jest",
50+
"check": "run-p --silent --continue-on-error --print-label 'check:*'",
51+
"check:lint": "eslint --color .",
52+
"check:types": "check-for-typescript tsc --noEmit --pretty",
53+
"check:license": "nrfconnect-license check",
54+
"nordic-publish": "nordic-publish"
55+
}
56+
}
57+
```
58+
59+
- A file `webpack.config.js` must be added with this content:
60+
61+
```js
62+
module.exports = require('pc-nrfconnect-shared/config/webpack.config');
63+
```
64+
65+
- A file `jest.config.js` must be added with this content, unless you want to
66+
have a special jest configuration:
67+
68+
```js
69+
module.exports = require('pc-nrfconnect-shared/config/jest.config')();
70+
```
71+
72+
- Because the name of the ESLint config file was changed from `eslintrc.json`
73+
to `eslintrc.js`, the reference to it needs to be changed in `package.json`
74+
(The correct extension will be chosen automatically, so you can omit that):
75+
76+
```json
77+
{
78+
"eslintConfig": {
79+
"extends": "./node_modules/pc-nrfconnect-shared/config/eslintrc"
80+
}
81+
}
82+
```
83+
84+
- The above change renames the script `lint` to `check` (because it does not
85+
only linting but runs multiple static checks). In `azure-pipelines.yml`
86+
there are probably still invocations like `npm run lint` and these need to
87+
be updated to `npm run check`. If there are other references to `lint`, they
88+
need to be updated too.
89+
90+
- The scripts require at least Ubuntu 20 in the Azure pipelines. So check
91+
which image is configured in `azure-pipelines.yml` and if it is still
92+
`ubuntu-18.04` update that, best to `ubuntu-latest`.
93+
94+
- The enzyme-to-json serializer was added to the jest config which might
95+
change some jest snapshots. You might have to run `jest --updateSnapshot` to
96+
update them.
2797

2898
## 5.18.0 - 2022-03-24
2999

azure-pipelines.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
pool:
2-
vmImage: 'Ubuntu-18.04'
2+
vmImage: 'ubuntu-latest'
33
steps:
44
- task: NodeTool@0
55
inputs:
66
versionSpec: 14
77
- bash: |
88
set -o errexit -o pipefail
99
npm ci
10-
npm run lint
10+
npm run check
1111
npm test -- --coverage --coverageReporters=cobertura
1212
displayName: "Lint & test"
1313
- task: PublishCodeCoverageResults@1

bin/nrfconnect-scripts.js

Lines changed: 0 additions & 36 deletions
This file was deleted.

config/babel.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ module.exports = api => {
99
return {
1010
presets: ['@babel/preset-react', '@babel/preset-typescript'],
1111
plugins: [
12-
'add-module-exports',
1312
'@babel/plugin-proposal-class-properties',
1413
'@babel/plugin-transform-destructuring',
1514
'@babel/plugin-transform-modules-commonjs',

config/eslintrc.js

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
/*
2+
* Copyright (c) 2022 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
5+
*/
6+
7+
const fs = require('fs');
8+
9+
const entriesInGitignore = fs
10+
.readFileSync('.gitignore', 'utf8')
11+
.split('\n')
12+
.filter(Boolean);
13+
14+
module.exports = {
15+
reportUnusedDisableDirectives: true,
16+
parser: '@typescript-eslint/parser',
17+
extends: [
18+
'eslint:recommended',
19+
'airbnb',
20+
'plugin:@typescript-eslint/recommended',
21+
'plugin:import/recommended',
22+
'plugin:import/typescript',
23+
'prettier',
24+
'prettier/react',
25+
'prettier/@typescript-eslint',
26+
],
27+
ignorePatterns: ['package-lock.json', ...entriesInGitignore],
28+
rules: {
29+
'@typescript-eslint/ban-ts-comment': [
30+
'error',
31+
{ 'ts-expect-error': 'allow-with-description' },
32+
],
33+
'@typescript-eslint/no-empty-function': 'off',
34+
'@typescript-eslint/no-shadow': 'error',
35+
'@typescript-eslint/no-var-requires': 'off',
36+
'arrow-parens': ['error', 'as-needed'],
37+
'import/default': 'error',
38+
'import/extensions': 'off',
39+
'import/named': 'error',
40+
'import/no-extraneous-dependencies': 'off',
41+
'import/no-unresolved': [
42+
'error',
43+
{
44+
ignore: [
45+
'pc-ble-driver-js',
46+
'serialport',
47+
'electron',
48+
'pc-nrfconnect-shared',
49+
'@electron/remote',
50+
],
51+
},
52+
],
53+
'import/prefer-default-export': 'off',
54+
'jsx-a11y/control-has-associated-label': 'off',
55+
'linebreak-style': 'off',
56+
'lines-between-class-members': 'off',
57+
'md/remark': [
58+
'error',
59+
{
60+
plugins: [
61+
'preset-lint-markdown-style-guide',
62+
'frontmatter',
63+
['lint-no-duplicate-headings', false],
64+
['lint-list-item-indent', false],
65+
['lint-emphasis-marker', false],
66+
['lint-list-item-spacing', false],
67+
['lint-no-literal-urls', false],
68+
],
69+
},
70+
],
71+
'no-console': 'off',
72+
'no-param-reassign': 'off',
73+
'no-shadow': 'off',
74+
'no-undef': 'error',
75+
'no-unused-expressions': 'off',
76+
'no-unused-vars': 'off',
77+
'no-use-before-define': 'off',
78+
'prettier/prettier': 'error',
79+
'react-hooks/exhaustive-deps': 'error',
80+
'react-hooks/rules-of-hooks': 'error',
81+
'react/jsx-filename-extension': [
82+
'error',
83+
{ extensions: ['.jsx', '.tsx'] },
84+
],
85+
'react/jsx-indent-props': ['error', 4],
86+
'react/jsx-indent': ['error', 4],
87+
'react/jsx-key': ['error', { checkFragmentShorthand: true }],
88+
'react/jsx-one-expression-per-line': 'off',
89+
'react/jsx-props-no-spreading': 'off',
90+
'react/require-default-props': 'off',
91+
'require-await': 'error',
92+
'simple-import-sort/imports': [
93+
'error',
94+
{
95+
/* This configures the order of the imports.
96+
The obscure format using regexps is described at
97+
https://github.com/lydell/eslint-plugin-simple-import-sort#custom-grouping
98+
and there are examples at
99+
https://github.com/lydell/eslint-plugin-simple-import-sort/blob/main/examples/.eslintrc.js
100+
*/
101+
groups: [
102+
// First all side effect imports. That strange token is
103+
// described in the eslint-plugin-simple-import-sort docs
104+
['^\\u0000'],
105+
106+
// All package imports (starting with a letter, optionally
107+
// prepended by an '@'), with React packages coming first.
108+
['^react', '^@?\\w'],
109+
110+
// All relative imports (starting with a '.')
111+
['^\\.'],
112+
113+
// All styles imports (ending with '.css' or '.scss')
114+
['^.+\\.s?css$'],
115+
],
116+
},
117+
],
118+
'valid-jsdoc': ['error', { prefer: { return: 'returns' } }],
119+
},
120+
overrides: [
121+
{
122+
files: ['*.d.ts'],
123+
rules: {
124+
'max-classes-per-file': 'off',
125+
'react/prefer-stateless-function': 'off',
126+
'@typescript-eslint/no-explicit-any': 'off',
127+
},
128+
},
129+
{
130+
files: ['*.ts', '*.tsx'],
131+
rules: {
132+
'default-case': 'off',
133+
'consistent-return': 'off',
134+
'react/prop-types': 'off',
135+
},
136+
},
137+
{
138+
files: ['*.md'],
139+
parser: 'markdown-eslint-parser',
140+
rules: {
141+
'prettier/prettier': ['error', { parser: 'markdown' }],
142+
},
143+
},
144+
{
145+
files: ['*.test.*'],
146+
rules: {
147+
'@typescript-eslint/no-non-null-assertion': 'off',
148+
},
149+
},
150+
{
151+
files: ['*.json'],
152+
rules: {
153+
'no-template-curly-in-string': 'off',
154+
},
155+
},
156+
],
157+
plugins: [
158+
'react',
159+
'import',
160+
'react-hooks',
161+
'prettier',
162+
'simple-import-sort',
163+
'md',
164+
],
165+
env: {
166+
es6: true,
167+
browser: true,
168+
node: true,
169+
jasmine: true,
170+
jest: true,
171+
},
172+
globals: {
173+
NodeJS: true,
174+
React: true,
175+
},
176+
};

0 commit comments

Comments
 (0)