-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from salesforce/scaffold
Setup eslint plugin scaffold and basic CI actions
- Loading branch information
Showing
17 changed files
with
5,345 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"root": true, | ||
"extends": [ | ||
"eslint:recommended", | ||
"plugin:node/recommended" | ||
], | ||
"env": { | ||
"jest": true, | ||
"node": true | ||
}, | ||
"rules": { | ||
"strict": ["error", "global"] | ||
}, | ||
"ignorePatterns": ["test/**/test.js"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: lint | ||
run-name: Installs project and runs linting | ||
on: [ push, pull_request ] | ||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node: [ 18, 20 ] | ||
name: Linting on Ubuntu with Node ${{ matrix.node }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node }} | ||
cache: 'npm' | ||
- run: npm install | ||
- run: npm run lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: prettier | ||
run-name: Installs project and runs prettier checks | ||
on: [ push, pull_request ] | ||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node: [ 18, 20 ] | ||
name: Prettier on Ubuntu with Node ${{ matrix.node }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node }} | ||
cache: 'npm' | ||
- run: npm install | ||
- run: npm run format |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: run-tests | ||
run-name: Installs project and runs tests | ||
on: [ push, pull_request ] | ||
jobs: | ||
run-tests-nix: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node: [ 18, 20 ] | ||
name: Run tests on Ubuntu with Node ${{ matrix.node }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node }} | ||
cache: 'npm' | ||
- run: npm install | ||
- run: npm run test | ||
run-tests-win: | ||
runs-on: windows-latest | ||
strategy: | ||
matrix: | ||
node: [ 18, 20 ] | ||
name: Run tests on Windows with Node ${{ matrix.node }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node }} | ||
cache: 'npm' | ||
- run: npm install | ||
- run: npm run test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/node_modules | ||
/reports | ||
test-report.xml | ||
junit.xml | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Debug Jest Tests", | ||
"type": "node", | ||
"request": "launch", | ||
"runtimeArgs": [ | ||
"--inspect-brk", | ||
"${workspaceRoot}/node_modules/.bin/jest", | ||
"--runInBand" | ||
], | ||
"console": "integratedTerminal", | ||
"internalConsoleOptions": "neverOpen" | ||
} | ||
] | ||
} |
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# Comment line immediately above ownership line is reserved for related other information. Please be careful while editing. | ||
#ECCN:Open Source | ||
* @khawkins @sfdctaka @maliroteh-sf | ||
* @khawkins @sfdctaka @maliroteh-sf @ben-zhang-at-salesforce @haifeng-li-at-salesforce |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,27 @@ | ||
# @salesforce/eslint-plugin-lwc-mobile | ||
# @salesforce/eslint-plugin-lwc-mobile | ||
|
||
## Installation | ||
|
||
To add this plugin to your package/project, install it with your favorite Node.js package manager. | ||
|
||
### yarn | ||
|
||
```sh | ||
$ yarn add --dev @salesforce/eslint-plugin-lwc-mobile | ||
``` | ||
|
||
### npm | ||
|
||
```sh | ||
$ npm install --save-dev @salesforce/eslint-plugin-lwc-mobile | ||
``` | ||
|
||
## Configuration | ||
|
||
Here's an example snippet of a `.eslintrc.json` configuration file, that will configure the `eslint-plugin-lwc-mobile` plugin. Extending the `plugin:@salesforce/lwc-mobile/recommended` ESLint configuration will enable static analysis on all `.js` files used in your Lightning web components. | ||
|
||
```json | ||
{ | ||
"extends": ["eslint:recommended", "plugin:@salesforce/lwc-mobile/recommended"] | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright (c) 2024, salesforce.com, inc. | ||
* All rights reserved. | ||
* SPDX-License-Identifier: MIT | ||
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT | ||
*/ | ||
|
||
'use strict'; | ||
|
||
module.exports = { | ||
displayName: 'Unit Tests', | ||
setupFilesAfterEnv: ['jest-extended', 'jest-chain'], | ||
testMatch: [ | ||
'<rootDir>/test/plugin.js', | ||
'<rootDir>/test/lib/rules/**/*.js', | ||
'!**/test/lib/rules/shared.js' | ||
], | ||
moduleFileExtensions: ['js', 'json'], | ||
testResultsProcessor: 'jest-sonar-reporter', | ||
testPathIgnorePatterns: ['/node_modules/', '<rootDir>/lib/'], | ||
moduleDirectories: ['node_modules'], | ||
collectCoverage: true, | ||
collectCoverageFrom: ['lib/**/*.js'], | ||
coverageDirectory: 'reports/coverage', | ||
reporters: [ | ||
'default', | ||
[ | ||
'jest-junit', | ||
{ | ||
suiteName: 'Unit Tests', | ||
output: './reports/junit/jest-results.xml' | ||
} | ||
] | ||
] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* | ||
* Copyright (c) 2024, salesforce.com, inc. | ||
* All rights reserved. | ||
* SPDX-License-Identifier: MIT | ||
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT | ||
*/ | ||
|
||
'use strict'; | ||
|
||
module.exports = { | ||
plugins: ['@salesforce/lwc-mobile'] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
* Copyright (c) 2024, salesforce.com, inc. | ||
* All rights reserved. | ||
* SPDX-License-Identifier: MIT | ||
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT | ||
*/ | ||
|
||
'use strict'; | ||
|
||
module.exports = { | ||
extends: ['./configs/base'], | ||
rules: { | ||
'@salesforce/lwc-mobile/enforce-foo-bar': 'warn' | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright (c) 2024, salesforce.com, inc. | ||
* All rights reserved. | ||
* SPDX-License-Identifier: MIT | ||
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const base = require('./configs/base'); | ||
const recommended = require('./configs/recommended'); | ||
|
||
const enforceFooBar = require('./rules/enforce-foo-bar'); | ||
|
||
module.exports = { | ||
rules: { | ||
'enforce-foo-bar': enforceFooBar | ||
}, | ||
config: { | ||
base, | ||
recommended | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright (c) 2024, salesforce.com, inc. | ||
* All rights reserved. | ||
* SPDX-License-Identifier: MIT | ||
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT | ||
*/ | ||
|
||
'use strict'; | ||
|
||
// TODO: This sample rule would be removed. | ||
// The enforce-foo-bar rule definition | ||
module.exports = { | ||
meta: { | ||
type: 'problem', | ||
docs: { | ||
description: | ||
"Enforce that a variable named `foo` can only be assigned a value of 'bar'." | ||
}, | ||
fixable: 'code', | ||
schema: [] | ||
}, | ||
create(context) { | ||
return { | ||
// Performs action in the function on every variable declarator | ||
VariableDeclarator(node) { | ||
// Check if a `const` variable declaration | ||
if (node.parent.kind === 'const') { | ||
// Check if variable name is `foo` | ||
if (node.id.type === 'Identifier' && node.id.name === 'foo') { | ||
// Check if value of variable is "bar" | ||
if ( | ||
node.init && | ||
node.init.type === 'Literal' && | ||
node.init.value !== 'bar' | ||
) { | ||
/* | ||
* Report error to ESLint. Error message uses | ||
* a message placeholder to include the incorrect value | ||
* in the error message. | ||
* Also includes a `fix(fixer)` function that replaces | ||
* any values assigned to `const foo` with "bar". | ||
*/ | ||
context.report({ | ||
node, | ||
message: | ||
'Value other than "bar" assigned to `const foo`. Unexpected value: {{ notBar }}.', | ||
data: { | ||
notBar: node.init.value | ||
}, | ||
fix(fixer) { | ||
return fixer.replaceText(node.init, '"bar"'); | ||
} | ||
}); | ||
} | ||
} | ||
} | ||
} | ||
}; | ||
} | ||
}; |
Oops, something went wrong.